Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental bundler integration #8180

Merged
merged 113 commits into from Jun 30, 2022
Merged
Show file tree
Hide file tree
Changes from 107 commits
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
3860eca
internalization bug
gorakong Feb 9, 2022
406cacb
Cleanup
Feb 9, 2022
c69e6d2
Always add assets to reachable bundles
lettertwo Feb 9, 2022
a5b5ed5
Merge branch 'v2' of github.com:parcel-bundler/parcel into internaliz…
gorakong Feb 9, 2022
51ab20f
cleanup
gorakong Feb 9, 2022
febecde
fixed test regressions
gorakong Feb 10, 2022
c403cda
add ref edges whenever there are bundle edges
gorakong Feb 10, 2022
8ac0701
add edge from bundlegroups to bundles wip
gorakong Feb 15, 2022
a474413
* Get inline bundles in bundle group in HTML packager
thebriando Feb 15, 2022
0a9f32d
use and follow reference edges again
gorakong Feb 16, 2022
73ad828
set env whenever we create bundles
gorakong Feb 17, 2022
eb3703b
Check to add parallel edges from all paths to an asset from a bundle
Feb 19, 2022
463bed0
Always register referenced bundles before pruning when building bundl…
Feb 22, 2022
d775731
Merge remote-tracking branch 'origin/v2' into internalization-bug
Feb 22, 2022
dbfab75
Revert "set env whenever we create bundles"
Feb 23, 2022
757eff8
Add test for referenced roots in bundle manifest
Feb 23, 2022
6e22065
Add reused sibling bundles to asyncBundleRootGraph
Feb 28, 2022
f347cac
Add test case for asset that has both an async and sync import
thebriando Mar 1, 2022
a4162b2
ExperimentalBundler: stop at isolated bundles
Mar 1, 2022
2a02631
ExperimentalBundler: fix step 7 comment
Mar 1, 2022
0d20d02
ExperimentalBundler: initialize entry bundles with no ancestors
Mar 1, 2022
22ba3bb
ExperimentalBundler: accept shared bundles extracted from workers
Mar 1, 2022
df5a741
Remove unused async bundles if needed
Mar 2, 2022
d03348d
Merge remote-tracking branch 'origin/v2' into more-experimental-bundl…
Mar 2, 2022
731c07b
Scope-hositing with new bundler: allow less duplication
Mar 2, 2022
345e0cc
Uncomment line in getSymbolResolution
thebriando Mar 3, 2022
727dde7
Consider sibling availability before removing from ancestorAssets
Mar 3, 2022
2032542
Uncomment line in getSymbolResolution
thebriando Mar 3, 2022
37e5c6a
Upgrade flow to 0.173.0 (#7809)
Mar 8, 2022
ae3ee14
Remove reachableBundles
thebriando Mar 9, 2022
7a98f04
Bump lmdb (#7797)
mischnic Mar 9, 2022
968fde6
Replace typeof before DCE (#7788)
mischnic Mar 9, 2022
8136500
Consider sibling availability before removing from ancestorAssets
Mar 3, 2022
a5d9610
Consider assets in siblings before duplicating
Mar 3, 2022
fd4e7db
Merge remote-tracking branch 'github/v2' into more-experimental-bundl…
Mar 10, 2022
a7946d9
Remove unrelated change
Mar 10, 2022
eab212a
Don't consider any of parent's async bundles as sibling
Mar 14, 2022
07cb7fc
Merge branch 'v2' into more-experimental-bundler-fixes
thebriando Mar 16, 2022
0cbd1f3
Remove unused structure
Mar 16, 2022
8feaea7
Merge branch 'more-experimental-bundler-fixes' of https://github.com/…
AGawrys Mar 17, 2022
81ffca5
remove eager bundle reuse and related lending code
AGawrys Mar 22, 2022
1c30b0a
implement parallel request limits
gorakong Mar 24, 2022
f8a8e65
cleanup
gorakong Mar 24, 2022
a6f3065
Merge branch 'v2' of github.com:parcel-bundler/parcel into parallel-r…
gorakong Mar 28, 2022
892edd3
create all shared bundles first then remove later
gorakong Mar 29, 2022
b971d75
Alter tests with mode production and correct assets with logic for sp…
AGawrys Mar 29, 2022
f887d71
Merge branch 'v2' into more-experimental-bundler-fixes
Mar 29, 2022
01dd511
Skip unused dependencies in experimental bundler
devongovett Mar 29, 2022
d9049a1
Implement getBundleFromBundleRoot
Mar 29, 2022
76214cb
Only add dependencies to CSS module JS, not CSS
devongovett Mar 26, 2022
7d20342
Handle multiple assets on dependencies in reachability
Mar 30, 2022
5107bd5
ScopeHoistingPackager: Handle different wrapped ancestries in wrappin…
Mar 31, 2022
403ae53
move reachable root creation earlier to prevent unnecessary async bundle
AGawrys Apr 5, 2022
4e04010
Merge branch 'v2' of github.com:parcel-bundler/parcel into parallel-r…
gorakong Apr 5, 2022
7478eae
Merge remote-tracking branch 'origin/v2' into more-experimental-bundl…
thebriando Apr 6, 2022
d27025e
replace reachableroots with syncAssetsRequired and skip sync deps for…
AGawrys Apr 11, 2022
91170c3
Revert "replace reachableroots with syncAssetsRequired and skip sync …
AGawrys Apr 26, 2022
364f081
Revert "move reachable root creation earlier to prevent unnecessary a…
AGawrys Apr 26, 2022
fb426b1
Implement cleanup for internalized deps from entrys
AGawrys Apr 26, 2022
30de01d
flow and clean up and comments
AGawrys Apr 27, 2022
239bb91
forgot to add the test files
AGawrys Apr 27, 2022
137801c
skip assets for reachable if isolated or inline fix invariant
AGawrys Apr 27, 2022
31e58d9
merge in v2
AGawrys Apr 27, 2022
e87347d
skip assets for reachable if isolated or inline fix invariant
AGawrys Apr 27, 2022
c09957e
Merge branch 'v2' of github.com:parcel-bundler/parcel into parallel-r…
gorakong Apr 28, 2022
e5c4c8a
Use bundleGroup instead of bundle root for determining needsStableName
Apr 29, 2022
7faa3d7
remove asset references for deleted bundles + minor fixes
gorakong May 2, 2022
5f734f6
Merge branch 'v2' of github.com:parcel-bundler/parcel into parallel-r…
gorakong May 3, 2022
1ca53e0
Merge branch 'v2' into parallel-request-limit
gorakong May 3, 2022
8091e67
Merge branch 'v2' into parallel-request-limit
gorakong May 3, 2022
955fb67
Filter out bundleroots from reacable if they are subgraphs, consider …
AGawrys May 4, 2022
fe4efb4
Add bundle.mainEntryAsset
Apr 29, 2022
95b8588
ExperimentalBundler: merge bundleBehavior and needsStableName
May 3, 2022
e289ef5
Merge branch 'v2' into parallel-request-limit
May 4, 2022
7a4a0f4
Merge remote-tracking branch 'origin/wbinnssmith/multiple-bundles-sam…
AGawrys May 4, 2022
7934257
Merge remote-tracking branch 'origin/parallel-request-limit' into exp…
AGawrys May 4, 2022
59f4ef4
don't remove bundles depended on by url
AGawrys May 4, 2022
c36daf0
don't flatted bundle to bundlegroup edges
AGawrys May 4, 2022
c7a80fa
point config to default bundler, crete type change bundle regardless …
AGawrys May 10, 2022
183e9e7
extract shared bundles from inline bundles
AGawrys May 11, 2022
7ee8435
Internalize all async bundle before placing assets into bundles, add …
AGawrys May 12, 2022
ec2ec0a
add assert bundles to test
AGawrys May 13, 2022
335e31e
Reverse merge asset insertion order to maintain dep order for css, re…
AGawrys May 13, 2022
f7a2296
Forked tests which rely on size calculation for shared bundles which …
AGawrys May 23, 2022
770bc1f
Addedge support to toposort, use edges to differentiate parallel and …
AGawrys May 24, 2022
82c6d43
Alter test description
AGawrys May 24, 2022
bd26b85
Merge in v2
AGawrys May 24, 2022
58dfd51
remove numbered steps & remove parallel request limit since subject t…
AGawrys May 24, 2022
0226dc4
Add support for multiple targets by bundling per entries per target
AGawrys Jun 1, 2022
0c3a653
clean up
AGawrys Jun 1, 2022
f851eb7
parallel request limits + test
gorakong Jun 2, 2022
36c647c
Merge branch 'experimental-bundler-integration' of https://github.com…
gorakong Jun 2, 2022
de2085a
add test and assert on number of bundles instead
gorakong Jun 2, 2022
d43c3b6
add test and assert on number of bundles instead
gorakong Jun 2, 2022
1ed5a4e
Merge branch 'experimental-bundler-integration' of https://github.com…
gorakong Jun 2, 2022
361bda0
Fix
mischnic Jun 2, 2022
9445ca0
clean up logic and naming
AGawrys Jun 9, 2022
3c18f9c
typo
AGawrys Jun 10, 2022
4718cae
Merge remote-tracking branch 'origin/v2' into experimental-bundler-in…
AGawrys Jun 14, 2022
c635729
parallel request limit wip
gorakong Jun 16, 2022
4bbad88
Dont allow multiple bundles of entry type in entry bundlegroups
AGawrys Jun 21, 2022
0caa81b
Merge remote-tracking branch 'origin/v2' into experimental-bundler-in…
AGawrys Jun 21, 2022
b415d1e
fix
gorakong Jun 21, 2022
a2a87c1
Comments
AGawrys Jun 24, 2022
d3d11b5
Merge branch 'experimental-bundler-integration' of https://github.com…
gorakong Jun 24, 2022
3323602
fixed bugs in parallel request limit implementation & update related …
gorakong Jun 24, 2022
81b9da3
Merge branch 'v2' of https://github.com/parcel-bundler/parcel into ex…
gorakong Jun 24, 2022
15085a2
flow
AGawrys Jun 24, 2022
10f09e9
Fork diagnostic bundler config test to say correct bundler
AGawrys Jun 27, 2022
fc9e55b
typos
AGawrys Jun 27, 2022
7e74049
flow reverse
AGawrys Jun 27, 2022
2df0724
Add parallel step for running integration tests with experimental bun…
thebriando Jun 29, 2022
1662eb7
Merge branch 'v2' into experimental-bundler-integration
AGawrys Jun 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -27,7 +27,7 @@ yarn install
yarn build-native
```

If you want, you can create a temporary example for debugging in the folder `packages/examples`. You can start by copying the `simple` example and try to reproduce the bug. It has everything set up for working on local changes and you can run `yarn build` to build the project. If you're re-using another example or creating one from scratch, make sure to use the `--no-cache` flag for `parcel build` to see your local changes reflected. *Please don't commit this example.*
If you want, you can create a temporary example for debugging in the folder `packages/examples`. You can start by copying the `simple` example and try to reproduce the bug. It has everything set up for working on local changes and you can run `yarn build` to build the project. If you're re-using another example or creating one from scratch, make sure to use the `--no-cache` flag for `parcel build` to see your local changes reflected. _Please don't commit this example._

After you've figured out where the issue originated from and found a fix, try to add a test case or ask for help on how to proceed if the use case is more complex.

Expand Down
774 changes: 588 additions & 186 deletions packages/bundlers/experimental/src/ExperimentalBundler.js

Large diffs are not rendered by default.

20 changes: 11 additions & 9 deletions packages/core/core/src/BundleGraph.js
Expand Up @@ -732,12 +732,13 @@ export default class BundleGraph {
if (
inboundDependencies.every(
dependency =>
!this.bundleHasDependency(bundle, dependency) ||
this._graph.hasEdge(
bundleNodeId,
this._graph.getNodeIdByContentKey(dependency.id),
bundleGraphEdgeTypes.internal_async,
),
dependency.specifierType !== SpecifierType.url &&
(!this.bundleHasDependency(bundle, dependency) ||
this._graph.hasEdge(
bundleNodeId,
this._graph.getNodeIdByContentKey(dependency.id),
bundleGraphEdgeTypes.internal_async,
)),
)
) {
this._graph.removeEdge(
Expand Down Expand Up @@ -1307,9 +1308,10 @@ export default class BundleGraph {
// Shared bundles seem to depend on being used in the opposite order
// they were added.
// TODO: Should this be the case?
this._graph
.getNodeIdsConnectedFrom(nodeId, bundleGraphEdgeTypes.references)
.reverse(),
this._graph.getNodeIdsConnectedFrom(
nodeId,
bundleGraphEdgeTypes.references,
),
});

return [...referencedBundles];
Expand Down
14 changes: 9 additions & 5 deletions packages/core/graph/src/Graph.js
Expand Up @@ -407,13 +407,17 @@ export default class Graph<TNode, TEdgeType: number = 1> {
return null;
}

topoSort(): Array<NodeId> {
topoSort(type?: TEdgeType): Array<NodeId> {
let sorted: Array<NodeId> = [];
this.traverse({
exit: nodeId => {
sorted.push(nodeId);
this.traverse(
{
exit: nodeId => {
sorted.push(nodeId);
},
},
});
null,
type,
);
return sorted.reverse();
}

Expand Down
236 changes: 192 additions & 44 deletions packages/core/integration-tests/test/cache.js
Expand Up @@ -4360,7 +4360,7 @@ describe('cache', function () {
it('should support adding bundler config', async function () {
let b = await testCache(
{
entries: ['*.html'],
entries: ['index.js'],
mode: 'production',
async setup() {
let pkgFile = path.join(inputDir, 'package.json');
Expand All @@ -4374,85 +4374,217 @@ describe('cache', function () {
);
},
async update(b) {
let html = await overlayFS.readFile(
b.bundleGraph.getBundles().find(b => b.name === 'b.html')
?.filePath,
'utf8',
);
assert.equal(html.match(/<script/g)?.length, 7);

assertBundles(b.bundleGraph, [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did these cache tests change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We changed the cache tests because they didn't seem to test the config properly, now the test for adding a config and removing determine if minBundleSize was upheld, for bundles with a large asset.

The previous test was testing script tags within a bundle, so it didn't seem like it was just testing bundler config.

{
assets: ['a.js'],
},
{
assets: ['b.js'],
},
{
name: 'index.js',
assets: [
'index.js',
'c.js',
'bundle-url.js',
'cacheLoader.js',
'js-loader.js',
'bundle-manifest.js',
],
},
{
assets: ['common.js', 'lodash.js'],
},
]);
let pkgFile = path.join(inputDir, 'package.json');
let pkg = JSON.parse(await overlayFS.readFile(pkgFile));
await overlayFS.writeFile(
pkgFile,
JSON.stringify({
...pkg,
'@parcel/bundler-default': {
http: 1,
minBundleSize: 9000000,
},
}),
);
},
},
'shared-many',
'dynamic-common-large',
);

let html = await overlayFS.readFile(
b.bundleGraph.getBundles().find(b => b.name === 'b.html')?.filePath,
'utf8',
);
assert.equal(html.match(/<script/g)?.length, 5);
assertBundles(b.bundleGraph, [
{
assets: ['a.js', 'common.js', 'lodash.js'],
},
{
assets: ['b.js', 'common.js', 'lodash.js'],
},
{
name: 'index.js',
assets: [
'index.js',
'c.js',
'bundle-url.js',
'cacheLoader.js',
'js-loader.js',
'bundle-manifest.js',
],
},
]);
});

it('should support updating bundler config', async function () {
it('should support adding bundler config for parallel request limits', async function () {
let b = await testCache(
{
entries: ['*.html'],
entries: ['index.js'],
mode: 'production',
async setup() {
let pkgFile = path.join(inputDir, 'package.json');
let pkg = JSON.parse(await overlayFS.readFile(pkgFile));
await overlayFS.writeFile(
pkgFile,
JSON.stringify({
...pkg,
'@parcel/bundler-default': undefined,
}),
);
},
async update(b) {
let html = await overlayFS.readFile(
b.bundleGraph.getBundles().find(b => b.name === 'b.html')
?.filePath,
'utf8',
assert.deepEqual(b.bundleGraph.getBundles().length, 7);
let pkgFile = path.join(inputDir, 'package.json');
let pkg = JSON.parse(await overlayFS.readFile(pkgFile));
await overlayFS.writeFile(
pkgFile,
JSON.stringify({
...pkg,
'@parcel/bundler-default': {
maxParallelRequests: 0,
},
}),
);
assert.equal(html.match(/<script/g)?.length, 5);
},
},
'large-bundlegroup',
);
assert.deepEqual(b.bundleGraph.getBundles().length, 5);
});

it('should support updating bundler config', async function () {
let b = await testCache(
{
entries: ['index.js'],
mode: 'production',
async setup() {
let pkgFile = path.join(inputDir, 'package.json');
let pkg = JSON.parse(await overlayFS.readFile(pkgFile));
await overlayFS.writeFile(
pkgFile,
JSON.stringify({
...pkg,
'@parcel/bundler-default': {
http: 2,
minBundleSize: 8000,
},
}),
);
},
async update(b) {
assertBundles(b.bundleGraph, [
{
assets: ['a.js'],
},
{
assets: ['b.js'],
},
{
name: 'index.js',
assets: [
'index.js',
'c.js',
'bundle-url.js',
'cacheLoader.js',
'js-loader.js',
'bundle-manifest.js',
],
},
{
assets: ['common.js', 'lodash.js'],
},
]);
let pkgFile = path.join(inputDir, 'package.json');
let pkg = JSON.parse(await overlayFS.readFile(pkgFile));
await overlayFS.writeFile(
pkgFile,
JSON.stringify({
...pkg,
'@parcel/bundler-default': {
minBundleSize: 9000000,
},
}),
);
},
},
'shared-many',
'dynamic-common-large',
);

let html = await overlayFS.readFile(
b.bundleGraph.getBundles().find(b => b.name === 'b.html')?.filePath,
'utf8',
);
assert.equal(html.match(/<script/g)?.length, 7);
assertBundles(b.bundleGraph, [
{
assets: ['a.js', 'common.js', 'lodash.js'],
},
{
assets: ['b.js', 'common.js', 'lodash.js'],
},
{
name: 'index.js',
assets: [
'index.js',
'c.js',
'bundle-url.js',
'cacheLoader.js',
'js-loader.js',
'bundle-manifest.js',
],
},
]);
});

it('should support removing bundler config', async function () {
let b = await testCache(
{
entries: ['*.html'],
entries: ['index.js'],
mode: 'production',
async update(b) {
let html = await overlayFS.readFile(
b.bundleGraph.getBundles().find(b => b.name === 'b.html')
?.filePath,
'utf8',
async setup() {
let pkgFile = path.join(inputDir, 'package.json');
let pkg = JSON.parse(await overlayFS.readFile(pkgFile));
await overlayFS.writeFile(
pkgFile,
JSON.stringify({
...pkg,
'@parcel/bundler-default': {
minBundleSize: 9000000,
},
}),
);
assert.equal(html.match(/<script/g)?.length, 5);

},
async update(b) {
assertBundles(b.bundleGraph, [
{
assets: ['a.js', 'common.js', 'lodash.js'],
},
{
assets: ['b.js', 'common.js', 'lodash.js'],
},
{
name: 'index.js',
assets: [
'index.js',
'c.js',
'bundle-url.js',
'cacheLoader.js',
'js-loader.js',
'bundle-manifest.js',
],
},
]);
let pkgFile = path.join(inputDir, 'package.json');
let pkg = JSON.parse(await overlayFS.readFile(pkgFile));
await overlayFS.writeFile(
Expand All @@ -4464,14 +4596,30 @@ describe('cache', function () {
);
},
},
'shared-many',
'dynamic-common-large',
);

let html = await overlayFS.readFile(
b.bundleGraph.getBundles().find(b => b.name === 'b.html')?.filePath,
'utf8',
);
assert.equal(html.match(/<script/g)?.length, 7);
assertBundles(b.bundleGraph, [
{
assets: ['a.js'],
},
{
assets: ['b.js'],
},
{
name: 'index.js',
assets: [
'index.js',
'c.js',
'bundle-url.js',
'cacheLoader.js',
'js-loader.js',
'bundle-manifest.js',
],
},
{
assets: ['common.js', 'lodash.js'],
},
]);
});
});
});
Expand Down