Skip to content

Commit

Permalink
Fix circular deps in isolated bundles (e.g. workers)
Browse files Browse the repository at this point in the history
Closes #1669.
  • Loading branch information
devongovett committed Jul 9, 2018
1 parent 7b38f4f commit f2deb5c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Bundler.js
Expand Up @@ -607,6 +607,12 @@ class Bundler extends EventEmitter {
}
}

// Skip this asset if it's already in the bundle.
// Happens when circular dependencies are placed in an isolated bundle (e.g. a worker).
if (bundle.isolated && bundle.assets.has(asset)) {
return;
}

let isEntryAsset =
asset.parentBundle && asset.parentBundle.entryAsset === asset;

Expand Down
1 change: 1 addition & 0 deletions test/integration/worker-circular/index.js
@@ -0,0 +1 @@
new Worker('worker.js');
1 change: 1 addition & 0 deletions test/integration/worker-circular/worker-dep.js
@@ -0,0 +1 @@
require('./worker');
1 change: 1 addition & 0 deletions test/integration/worker-circular/worker.js
@@ -0,0 +1 @@
require('./worker-dep');
16 changes: 16 additions & 0 deletions test/javascript.js
Expand Up @@ -250,6 +250,22 @@ describe('javascript', function() {
});
});

it('should support bundling workers with circular dependencies', async function() {
let b = await bundle(__dirname + '/integration/worker-circular/index.js', {
sourceMaps: false
});

await assertBundleTree(b, {
name: 'index.js',
assets: ['index.js'],
childBundles: [
{
assets: ['worker.js', 'worker-dep.js']
}
]
});
});

it('should dynamic import files which import raw files', async function() {
let b = await bundle(
__dirname + '/integration/dynamic-references-raw/index.js'
Expand Down

0 comments on commit f2deb5c

Please sign in to comment.