Skip to content

Commit

Permalink
Disable splitting dependencies on symbols for non-scope hoisted bundl…
Browse files Browse the repository at this point in the history
…es (#8565)
  • Loading branch information
devongovett committed Oct 23, 2022
1 parent e168a78 commit 4ba031a
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/core/core/src/BundleGraph.js
Expand Up @@ -181,7 +181,11 @@ export default class BundleGraph {
walkVisited.add(nodeId);

let node = nullthrows(assetGraph.getNode(nodeId));
if (node.type === 'dependency' && node.value.symbols != null) {
if (
node.type === 'dependency' &&
node.value.symbols != null &&
node.value.env.shouldScopeHoist
) {
// asset -> symbols that should be imported directly from that asset
let targets = new DefaultMap<ContentKey, Map<Symbol, Symbol>>(
() => new Map(),
Expand Down

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.

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

@@ -0,0 +1,15 @@
{
"source": "test.js",
"scope-hoist": "dist/scope-hoist.js",
"no-scope-hoist": "dist/no-scope-hoist.js",
"targets": {
"scope-hoist": {
"scopeHoist": true,
"optimize": false
},
"no-scope-hoist": {
"scopeHoist": false,
"optimize": false
}
}
}
@@ -0,0 +1,3 @@
import {UIIcon, Icon} from 'icon';

output(UIIcon(), Icon());
24 changes: 24 additions & 0 deletions packages/core/integration-tests/test/javascript.js
Expand Up @@ -6219,6 +6219,30 @@ describe('javascript', function () {
assert.strictEqual(output.default, '4returned from bar');
});

it('should produce working output with both scope hoisting and non scope hoisting targets', async function () {
let b = await bundle(
path.join(__dirname, '/integration/re-export-no-scope-hoist'),
{
defaultTargetOptions: {
shouldScopeHoist: true,
},
},
);
let bundles = b.getBundles();

let o1, o2;
await runBundle(b, bundles[0], {
output: (...o) => (o1 = o),
});

await runBundle(b, bundles[1], {
output: (...o) => (o2 = o),
});

assert.deepEqual(o1, ['UIIcon', 'Icon']);
assert.deepEqual(o2, ['UIIcon', 'Icon']);
});

for (let shouldScopeHoist of [false, true]) {
let options = {
defaultTargetOptions: {
Expand Down

0 comments on commit 4ba031a

Please sign in to comment.