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

More experimental bundler fixes #7783

Merged
merged 55 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
55 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:/…
AGawrys Mar 17, 2022
81ffca5
remove eager bundle reuse and related lending code
AGawrys Mar 22, 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
7478eae
Merge remote-tracking branch 'origin/v2' into more-experimental-bundl…
thebriando Apr 6, 2022
31e58d9
merge in v2
AGawrys Apr 27, 2022
e87347d
skip assets for reachable if isolated or inline fix invariant
AGawrys Apr 27, 2022
e5c4c8a
Use bundleGroup instead of bundle root for determining needsStableName
Apr 29, 2022
fe4efb4
Add bundle.mainEntryAsset
Apr 29, 2022
195d041
Merge branch 'v2' into more-experimental-bundler-fixes
May 10, 2022
bc6aedd
fixup! Add bundle.mainEntryAsset
May 10, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
412 changes: 223 additions & 189 deletions packages/bundlers/experimental/src/ExperimentalBundler.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions packages/core/integration-tests/test/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -2835,4 +2835,34 @@ describe('html', function () {
},
);
});

it('extracts shared bundles that load referenced bundle roots across entries', async () => {
let b = await bundle(
['index1.html', 'index2.html'].map(entry =>
path.join(__dirname, 'integration/html-shared-referenced', entry),
),
{
mode: 'production',
defaultTargetOptions: {
shouldOptimize: false,
},
},
);

await run(b);
});

it('should not skip bundleRoots if an asset is both async required and static required', async function () {
let b = await bundle(
path.join(__dirname, 'integration/html-sync-async-asset/index.html'),
{
mode: 'production',
defaultTargetOptions: {
shouldOptimize: false,
},
},
);

await run(b, {output: null}, {require: false});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import './async2.js';

import('./async2.js');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script type="module" src="index1.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './shared';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script type="module" src="index2.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import './async.js';
import './shared.js';

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"@parcel/bundler-default": {
"minBundleSize": 0
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import('./async.js');
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<script type="module" src="./index.js"></script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import t from "./test.js";

import("./other.js")
.then((v) => v.default)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default import("./test.js");
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default "test";
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<!DOCTYPE html>
<html>
<body>
<script type="module" src="./index.mjs"></script>
</body>
</html>
46 changes: 32 additions & 14 deletions packages/core/integration-tests/test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -1020,25 +1020,43 @@ describe('javascript', function () {
},
);

assertBundles(b, [
{
assets: ['dedicated-worker.js', 'index.js'],
},
{
name: 'index.js',
assets: ['index.js', 'bundle-url.js', 'get-worker-url.js'],
},
{
assets: ['shared-worker.js', 'index.js'],
},
]);
if (process.env.PARCEL_TEST_EXPERIMENTAL_BUNDLER) {
assertBundles(b, [
{
assets: ['dedicated-worker.js'],
},
{
name: 'index.js',
assets: ['index.js', 'bundle-url.js', 'get-worker-url.js'],
},
{
assets: ['shared-worker.js'],
},
{
assets: ['index.js'],
},
]);
} else {
assertBundles(b, [
{
assets: ['dedicated-worker.js', 'index.js'],
},
{
name: 'index.js',
assets: ['index.js', 'bundle-url.js', 'get-worker-url.js'],
},
{
assets: ['shared-worker.js', 'index.js'],
},
]);
}

let dedicated, shared;
b.traverseBundles((bundle, ctx, traversal) => {
if (bundle.getMainEntry().filePath.endsWith('shared-worker.js')) {
if (bundle.getMainEntry()?.filePath.endsWith('shared-worker.js')) {
shared = bundle;
} else if (
bundle.getMainEntry().filePath.endsWith('dedicated-worker.js')
bundle.getMainEntry()?.filePath.endsWith('dedicated-worker.js')
) {
dedicated = bundle;
}
Expand Down
6 changes: 5 additions & 1 deletion packages/core/integration-tests/test/scope-hoisting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5008,7 +5008,11 @@ describe('scope hoisting', function () {
],
},
{assets: ['dep.js']},
{assets: ['async-has-dep.js', 'dep.js', 'get-dep.js']},
{
assets: process.env.PARCEL_TEST_EXPERIMENTAL_BUNDLER
Copy link
Contributor

Choose a reason for hiding this comment

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

We now share assets between workers, so this is an improvement over the prior bundler.

? ['async-has-dep.js']
: ['async-has-dep.js', 'dep.js', 'get-dep.js'],
},
{assets: ['get-dep.js']},
]);

Expand Down
5 changes: 5 additions & 0 deletions packages/runtimes/js/src/JSRuntime.js
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ function getRegisterCode(
idToName[bundle.publicId] = path.basename(nullthrows(bundle.name));

if (bundle !== entryBundle && isNewContext(bundle, bundleGraph)) {
for (let referenced of bundleGraph.getReferencedBundles(bundle)) {
idToName[referenced.publicId] = path.basename(
nullthrows(referenced.name),
);
}
// New contexts have their own manifests, so there's no need to continue.
actions.skipChildren();
}
Expand Down