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

Disable splitting dependencies on symbols for non-scope hoisted bundles #8565

Merged
merged 1 commit into from Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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