Skip to content

Commit

Permalink
Add unstable manual shared bundles (#9251)
Browse files Browse the repository at this point in the history
  • Loading branch information
AGawrys authored Oct 4, 2023
1 parent b882b43 commit 3027926
Show file tree
Hide file tree
Showing 55 changed files with 1,415 additions and 199 deletions.
534 changes: 508 additions & 26 deletions packages/bundlers/default/src/DefaultBundler.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions packages/core/core/src/public/Bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ export class Bundle implements IBundle {
return this.#bundle.isSplittable;
}

get manualSharedBundle(): ?string {
return this.#bundle.manualSharedBundle;
}

get target(): ITarget {
return new Target(this.#bundle.target, this.#options);
}
Expand Down
9 changes: 7 additions & 2 deletions packages/core/core/src/public/MutableBundleGraph.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import type {
MutableBundleGraph as IMutableBundleGraph,
Target,
} from '@parcel/types';
import type {ParcelOptions, BundleGroup as InternalBundleGroup} from '../types';
import type {
ParcelOptions,
BundleGroup as InternalBundleGroup,
BundleNode,
} from '../types';

import invariant from 'assert';
import nullthrows from 'nullthrows';
Expand Down Expand Up @@ -204,7 +208,7 @@ export default class MutableBundleGraph
isPlaceholder = entryAssetNode.requested === false;
}

let bundleNode = {
let bundleNode: BundleNode = {
type: 'bundle',
id: bundleId,
value: {
Expand Down Expand Up @@ -232,6 +236,7 @@ export default class MutableBundleGraph
name: null,
displayName: null,
publicId,
manualSharedBundle: opts.manualSharedBundle,
},
};

Expand Down
1 change: 1 addition & 0 deletions packages/core/core/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ export type Bundle = {|
name: ?string,
displayName: ?string,
pipeline: ?string,
manualSharedBundle?: ?string,
|};
export type BundleNode = {|
Expand Down
10 changes: 10 additions & 0 deletions packages/core/graph/src/BitSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,16 @@ export class BitSet {
return Boolean(this.bits[i] & (1 << b));
}

empty(): boolean {
for (let k = 0; k < this.bits.length; k++) {
if (this.bits[k] !== 0) {
return false;
}
}

return true;
}

clear() {
this.bits.fill(0);
}
Expand Down
12 changes: 12 additions & 0 deletions packages/core/graph/test/BitSet.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@ describe('BitSet', () => {
assertValues(set1, [1, 5]);
});

it('empty should check if there are no values set', () => {
let set1 = new BitSet(5);

assert(set1.empty());

set1.add(3);
assert(!set1.empty());

set1.delete(3);
assert(set1.empty());
});

it('should intersect with another BitSet', () => {
let set1 = new BitSet(5);
set1.add(1);
Expand Down
Loading

0 comments on commit 3027926

Please sign in to comment.