Skip to content

Commit

Permalink
Recursively check reachability when removing asset graphs from bundle…
Browse files Browse the repository at this point in the history
…s in deduplication (#6004)
  • Loading branch information
gorakong authored Jan 3, 2023
1 parent ea61ad9 commit b82f592
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import bar from './intermediate';
import foo from './intermediate-2';
import baz from './intermediate-3';

export default baz;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import bar from './intermediate';
import barx from './intermediate-2';
import barz from './intermediate-3';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import bar from './unreachable';
import foo from './intermediate-2';

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import baz from './unreachable';
import bar from './foo';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import foo from './unreachable';
export default 4;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import('./d');
import('./c');
import('./b');
output = import('./a').then(res => res.default);
export default output;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@parcel/bundler-default": {
"minBundleSize": 200,
"maxParallelRequests": 3
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file.
17 changes: 17 additions & 0 deletions packages/core/integration-tests/test/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -6242,6 +6242,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: {
Expand Down
12 changes: 12 additions & 0 deletions packages/core/integration-tests/test/scope-hoisting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5585,5 +5585,17 @@ describe('scope hoisting', function () {
} finally {
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');
});
});
});

0 comments on commit b82f592

Please sign in to comment.