diff --git a/src/builtins/bundle-loader.js b/src/builtins/bundle-loader.js index f4a90695050..16323dff036 100644 --- a/src/builtins/bundle-loader.js +++ b/src/builtins/bundle-loader.js @@ -32,7 +32,10 @@ function loadBundle(bundle) { } var type = bundle.match(/\.(.+)$/)[1].toLowerCase(); - return bundles[bundle] = bundleLoaders[type](getBundleURL() + bundle); + var bundleLoader = bundleLoaders[type]; + if (bundleLoader) { + return bundles[bundle] = bundleLoader(getBundleURL() + bundle); + } } function loadJSBundle(bundle) { diff --git a/test/integration/dynamic-references-raw/index.js b/test/integration/dynamic-references-raw/index.js new file mode 100644 index 00000000000..ce3822c64fa --- /dev/null +++ b/test/integration/dynamic-references-raw/index.js @@ -0,0 +1,7 @@ +var local = import('./local'); + +module.exports = function () { + return local.then(function (l) { + return l.a + l.b; + }); +}; diff --git a/test/integration/dynamic-references-raw/local.js b/test/integration/dynamic-references-raw/local.js new file mode 100644 index 00000000000..f4051903ac4 --- /dev/null +++ b/test/integration/dynamic-references-raw/local.js @@ -0,0 +1,4 @@ +import raw from './test.txt'; + +exports.a = 1; +exports.b = 2; diff --git a/test/integration/dynamic-references-raw/test.txt b/test/integration/dynamic-references-raw/test.txt new file mode 100644 index 00000000000..c1d880f37d6 --- /dev/null +++ b/test/integration/dynamic-references-raw/test.txt @@ -0,0 +1 @@ +raw file diff --git a/test/javascript.js b/test/javascript.js index eeb39e6c36b..761d1dd7a5a 100644 --- a/test/javascript.js +++ b/test/javascript.js @@ -58,6 +58,27 @@ describe('javascript', function() { assert.equal(await output(), 3); }); + it('should dynamic import files which import raw files', async function() { + let b = await bundle( + __dirname + '/integration/dynamic-references-raw/index.js' + ); + + assertBundleTree(b, { + name: 'index.js', + assets: ['index.js', 'bundle-loader.js', 'bundle-url.js'], + childBundles: [ + { + assets: ['local.js', 'test.txt'], + childBundles: ['test.txt'] + } + ] + }); + + let output = run(b); + assert.equal(typeof output, 'function'); + assert.equal(await output(), 3); + }); + it('should return all exports as an object when using ES modules', async function() { let b = await bundle(__dirname + '/integration/dynamic-esm/index.js');