diff --git a/src/Bundler.js b/src/Bundler.js index b9918d1b2fe..1530aca4060 100644 --- a/src/Bundler.js +++ b/src/Bundler.js @@ -375,10 +375,9 @@ class Bundler extends EventEmitter { asset.parentBundle.type === commonBundle.type ) { this.moveAssetToBundle(asset, commonBundle); + return; } - } - - return; + } else return; } // Create the root bundle if it doesn't exist diff --git a/test/html.js b/test/html.js index c877ffb2570..59763725948 100644 --- a/test/html.js +++ b/test/html.js @@ -15,10 +15,20 @@ describe('html', function() { assets: ['index.css'], childBundles: [] }, + { + type: 'js', + assets: ['index.js'], + childBundles: [] + }, { type: 'html', assets: ['other.html'], childBundles: [ + { + type: 'css', + assets: ['index.css'], + childBundles: [] + }, { type: 'js', assets: ['index.js'], @@ -156,4 +166,33 @@ describe('html', function() { let html = fs.readFileSync(__dirname + '/dist/index.html', 'utf8'); assert(/hello<\/i> world<\/i>/.test(html)); }); + + it('should support child bundles of different types', async function() { + let b = await bundle( + __dirname + '/integration/child-bundle-different-types/index.html' + ); + + assertBundleTree(b, { + name: 'index.html', + assets: ['index.html'], + childBundles: [ + { + type: 'js', + assets: ['main.js', 'util.js', 'other.js'], + childBundles: [] + }, + { + type: 'html', + assets: ['other.html'], + childBundles: [ + { + type: 'js', + assets: ['index.js', 'util.js', 'other.js'], + childBundles: [] + } + ] + } + ] + }); + }); }); diff --git a/test/integration/child-bundle-different-types/index.html b/test/integration/child-bundle-different-types/index.html new file mode 100644 index 00000000000..369affb5284 --- /dev/null +++ b/test/integration/child-bundle-different-types/index.html @@ -0,0 +1,17 @@ + + + + + + + +
+ Hello World Main2 +
+
+ Hello World Main1 +
+ + GOOO + + diff --git a/test/integration/child-bundle-different-types/index.js b/test/integration/child-bundle-different-types/index.js new file mode 100644 index 00000000000..7f95e872d30 --- /dev/null +++ b/test/integration/child-bundle-different-types/index.js @@ -0,0 +1,5 @@ +var util = require('./util'); + +document.getElementById("main").innerHTML= util.hello(); + +document.getElementById("main1").innerHTML= util.b(); diff --git a/test/integration/child-bundle-different-types/main.js b/test/integration/child-bundle-different-types/main.js new file mode 100644 index 00000000000..90e4fa1c243 --- /dev/null +++ b/test/integration/child-bundle-different-types/main.js @@ -0,0 +1,5 @@ +var util = require('./util'); + +document.getElementById("main").innerHTML= util.hi(); + +document.getElementById("main1").innerHTML= util.b(); diff --git a/test/integration/child-bundle-different-types/other.html b/test/integration/child-bundle-different-types/other.html new file mode 100644 index 00000000000..039877f1c75 --- /dev/null +++ b/test/integration/child-bundle-different-types/other.html @@ -0,0 +1,17 @@ + + + + + + + + +
+ Heelo +
+
+ Heelo +
+ + + diff --git a/test/integration/child-bundle-different-types/other.js b/test/integration/child-bundle-different-types/other.js new file mode 100644 index 00000000000..954911eb5c7 --- /dev/null +++ b/test/integration/child-bundle-different-types/other.js @@ -0,0 +1,3 @@ +module.exports = { + hello: () => "HELLO", +} diff --git a/test/integration/child-bundle-different-types/util.js b/test/integration/child-bundle-different-types/util.js new file mode 100644 index 00000000000..588ccbc8a2a --- /dev/null +++ b/test/integration/child-bundle-different-types/util.js @@ -0,0 +1,7 @@ +var test = require('./other'); + +module.exports = { + hi: () => "Hi", + hello: () => "HELLO", + b: () => test.hello() +}