Skip to content

Commit

Permalink
Fix parcel bundling issues when asset parent & commonBundle types dif…
Browse files Browse the repository at this point in the history
…fer (#380)
  • Loading branch information
ssuman authored and devongovett committed Dec 30, 2017
1 parent 494fafc commit 127c9b7
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions test/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down Expand Up @@ -156,4 +166,33 @@ describe('html', function() {
let html = fs.readFileSync(__dirname + '/dist/index.html', 'utf8');
assert(/<i>hello<\/i> <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: []
}
]
}
]
});
});
});
17 changes: 17 additions & 0 deletions test/integration/child-bundle-different-types/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- First page -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="main">
Hello World Main2
</div>
<div id="main1">
Hello World Main1
</div>
<script src="./main.js"></script>
<a href="./other.html">GOOO</a>
</body>
</html>
5 changes: 5 additions & 0 deletions test/integration/child-bundle-different-types/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var util = require('./util');

document.getElementById("main").innerHTML= util.hello();

document.getElementById("main1").innerHTML= util.b();
5 changes: 5 additions & 0 deletions test/integration/child-bundle-different-types/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
var util = require('./util');

document.getElementById("main").innerHTML= util.hi();

document.getElementById("main1").innerHTML= util.b();
17 changes: 17 additions & 0 deletions test/integration/child-bundle-different-types/other.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- First page -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">

</head>
<body>
<div id="main">
Heelo
</div>
<div id="main1">
Heelo
</div>
<script src="./index.js"></script>
</body>
</html>
3 changes: 3 additions & 0 deletions test/integration/child-bundle-different-types/other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
hello: () => "HELLO",
}
7 changes: 7 additions & 0 deletions test/integration/child-bundle-different-types/util.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var test = require('./other');

module.exports = {
hi: () => "Hi",
hello: () => "HELLO",
b: () => test.hello()
}

0 comments on commit 127c9b7

Please sign in to comment.