-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Recursively check reachability when removing asset graphs from bundles in deduplication #6004
Conversation
|
Benchmark ResultsKitchen Sink ✅
Timings
Cold Bundles
Cached Bundles
React HackerNews ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. AtlasKit Editor ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. Three.js ✅
Timings
Cold BundlesNo bundle changes detected. Cached BundlesNo bundle changes detected. |
@@ -435,7 +438,11 @@ function deduplicate(bundleGraph: MutableBundleGraph) { | |||
bundle.hasAsset(asset) && | |||
bundleGraph.isAssetReachableFromBundle(asset, bundle) | |||
) { | |||
bundleGraph.removeAssetGraphFromBundle(asset, bundle); | |||
if (isSiblingDedupe) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should be treating these differently
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these tests fail if we do not treat them differently 😞: https://dev.azure.com/devongovett/devongovett/_build/results?buildId=15550&view=logs&j=81a0a40d-e1c6-55f1-066f-a450d17357d3&t=9ab6c9af-8c9a-51e6-60c5-00f9d8182a4a&l=1404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense — they're no longer reachable because the context changes across those sibling bundles. Let's get #5398 landed, which includes support for multiple contexts per environment [0], which will allow these cross-context shared bundles to have both contexts.
Removal should always be implemented in one way though.
cc @devongovett
f28c04b
to
9774f40
Compare
The test cases pass with the current v2 branch. Should we add the test cases (without the outdated fix) though? @gorakong @AGawrys @devongovett |
@mischnic sounds good to me! i've updated the PR to only include the test cases. |
Looks like you removed too much, these actual tests are missing now: diff --git packages/core/integration-tests/test/javascript.js packages/core/integration-tests/test/javascript.js
index bceb92c15..22b92cf59 100644
--- packages/core/integration-tests/test/javascript.js
+++ packages/core/integration-tests/test/javascript.js
@@ -6242,6 +6215,23 @@ describe('javascript', function () {
assert.deepEqual(o2, ['UIIcon', 'Icon']);
});
+ it('should not deduplicate an asset if it will become unreachable', async function () {
+ let b = await bundle(
+ path.join(
+ __dirname,
+ 'integration/sibling-deduplicate-unreachable/index.js',
+ ),
+ {
+ mode: 'production',
+ defaultTargetOptions: {
+ shouldScopeHoist: false,
+ },
+ },
+ );
+ let res = await run(b);
+ assert.equal(await res.default, 'target');
+ });
+
for (let shouldScopeHoist of [false, true]) {
let options = {
defaultTargetOptions: {
diff --git packages/core/integration-tests/test/scope-hoisting.js packages/core/integration-tests/test/scope-hoisting.js
index 985d5b672..0c22614ba 100644
--- packages/core/integration-tests/test/scope-hoisting.js
+++ packages/core/integration-tests/test/scope-hoisting.js
@@ -5586,4 +5586,16 @@ describe('scope hoisting', function () {
await workerFarm.end();
}
});
+
+ it('should not deduplicate an asset if it will become unreachable', async function() {
+ let b = await bundle(
+ path.join(
+ __dirname,
+ 'integration/sibling-deduplicate-unreachable/index.js',
+ ),
+ {mode: 'production'},
+ );
+ let res = await run(b);
+ assert.equal(res, 'target');
+ });
}); |
@mischnic oops good catch! i've added them back 😅 |
* upstream/v2: (33 commits) v2.8.3 Changelog for v2.8.3 Address bug by updating an asset reference and merge conditions (parcel-bundler#8762) Fix CSS order when merging type change bundles (parcel-bundler#8766) fixing failing build for contributors on Linux using Node 18 (parcel-bundler#8763) Extension: Importers View and separate LSP protocol package (parcel-bundler#8747) Bump swc to fix sourcemaps with Windows line endings (parcel-bundler#8756) Apply HMR updates in topological order (parcel-bundler#8752) Make extension packaging work (parcel-bundler#8730) Typed api.storeResult (parcel-bundler#8732) Refactor LSP to use vscode-jsonrpc (parcel-bundler#8728) Bump swc (parcel-bundler#8742) Recursively check reachability when removing asset graphs from bundles in deduplication (parcel-bundler#6004) Fix tsc sourcemaps metadata (parcel-bundler#8734) Assigning to `this` in CommonJS (parcel-bundler#8737) Don't retarget dependencies if a symbol is imported multiple times with different local names (parcel-bundler#8738) Add a note about using flow in CONTRIBUTING.md (parcel-bundler#8731) filter out title execArgv to workers (parcel-bundler#8719) Document more of the BundleGraph class (parcel-bundler#8711) Fixed the hmr connection with host 0.0.0.0 (parcel-bundler#7357) ...
↪️ Pull Request
Fixes some
No reachable bundle found containing...
errors that occur in scope-hoisted builds.Before:
During sibling deduplication,
unreachable
is first removed from Shared Bundle 2 because it is reachable via its sibling bundle (Shared Bundle 1).common
(and its subgraph) is then removed from Shared Bundle 1 because it is reachable via Shared Bundle 2. As a result,unreachable
is no longer in any of the bundleGroups Shared Bundle 1 is in (thereby becoming unreachable from Shared Bundle 1).After:
Recursively check reachability when removing asset graphs from bundles in deduplication.
Will be checking to see if this addresses #5770
✔️ PR Todo
Optimizing (avg time)
Before: 3.62s
After: 13.21s
265% slower
Bundling (avg time)
Before: 19.46s
After: 36.70s
88.6% slower
Overall build time, avg:
Before: 438s
After: 464s
5.9% slower