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

Fix nested async imports from a shared module #1724

Merged
merged 1 commit into from Jul 13, 2018
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
2 changes: 1 addition & 1 deletion src/packagers/JSConcatPackager.js
Expand Up @@ -151,7 +151,7 @@ class JSConcatPackager extends Packager {
}

for (let [dep, mod] of asset.depAssets) {
if (dep.dynamic && this.bundle.childBundles.has(mod.parentBundle)) {
if (dep.dynamic) {
for (let child of mod.parentBundle.siblingBundles) {
if (!child.isEmpty) {
await this.addBundleLoader(child.type, asset);
Expand Down
2 changes: 1 addition & 1 deletion src/packagers/JSPackager.js
Expand Up @@ -49,7 +49,7 @@ class JSPackager extends Packager {
let deps = {};
for (let [dep, mod] of asset.depAssets) {
// For dynamic dependencies, list the child bundles to load along with the module id
if (dep.dynamic && this.bundle.childBundles.has(mod.parentBundle)) {
if (dep.dynamic) {
let bundles = [this.getBundleSpecifier(mod.parentBundle)];
for (let child of mod.parentBundle.siblingBundles) {
if (!child.isEmpty) {
Expand Down
Empty file.
1 change: 1 addition & 0 deletions test/integration/dynamic-hoist-deep/a.js
@@ -0,0 +1 @@
import './c';
1 change: 1 addition & 0 deletions test/integration/dynamic-hoist-deep/b.js
@@ -0,0 +1 @@
import './c';
1 change: 1 addition & 0 deletions test/integration/dynamic-hoist-deep/c.js
@@ -0,0 +1 @@
import('./1');
6 changes: 6 additions & 0 deletions test/integration/dynamic-hoist-deep/index.js
@@ -0,0 +1,6 @@
import('./a');
import('./b');

export default {
asdf: 1,
};
38 changes: 38 additions & 0 deletions test/javascript.js
Expand Up @@ -396,6 +396,44 @@ describe('javascript', function() {
assert.equal(await output(), 5);
});

it('should support hoisting shared modules with async imports up multiple levels', async function() {
let b = await bundle(
__dirname + '/integration/dynamic-hoist-deep/index.js',
{
sourceMaps: false
}
);

await assertBundleTree(b, {
name: 'index.js',
assets: [
'index.js',
'c.js',
'bundle-loader.js',
'bundle-url.js',
'js-loader.js'
],
childBundles: [
{
assets: ['a.js'],
childBundles: [
{
assets: ['1.js'],
childBundles: []
}
]
},
{
assets: ['b.js'],
childBundles: []
}
]
});

let output = await run(b);
assert.deepEqual(output, {default: {asdf: 1}});
});

it('should support requiring JSON files', async function() {
let b = await bundle(__dirname + '/integration/json/index.js');

Expand Down