Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix generating names when outside of the entry directory (#1206)
  • Loading branch information
fathyb authored and devongovett committed Jul 7, 2018
1 parent cae25f6 commit 2bc6ed9
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Bundle.js
Expand Up @@ -142,7 +142,7 @@ class Bundle {
Path.dirname(entryAsset.name)
),
name + ext
);
).replace(/\.\.(\/|\\)/g, '__$1');
}

// If this is an index file, use the parent directory name instead
Expand Down
3 changes: 3 additions & 0 deletions test/integration/service-worker/a/index.js
@@ -0,0 +1,3 @@
import '../b/nested'

navigator.serviceWorker.register('../b/worker-outside.js');
1 change: 1 addition & 0 deletions test/integration/service-worker/b/nested/index.js
@@ -0,0 +1 @@
navigator.serviceWorker.register('worker-nested.js', { scope: './' });
File renamed without changes.
1 change: 1 addition & 0 deletions test/integration/service-worker/b/worker-outside.js
@@ -0,0 +1 @@
self.addEventListener('message', () => {});
1 change: 0 additions & 1 deletion test/integration/service-worker/index.js

This file was deleted.

30 changes: 30 additions & 0 deletions test/javascript.js
Expand Up @@ -220,6 +220,36 @@ describe('javascript', function() {
});
});

it('should support bundling service-workers', async function() {
let b = await bundle(__dirname + '/integration/service-worker/a/index.js');

assertBundleTree(b, {
name: 'index.js',
assets: ['index.js', 'index.js'],
childBundles: [
{
type: 'map'
},
{
assets: ['worker-nested.js'],
childBundles: [
{
type: 'map'
}
]
},
{
assets: ['worker-outside.js'],
childBundles: [
{
type: 'map'
}
]
}
]
});
});

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 2bc6ed9

Please sign in to comment.