Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential fix to parcel bundling issues when asset parent & commonBundle types differ #380

Merged
merged 1 commit into from
Dec 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Bundler.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,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
2 changes: 1 addition & 1 deletion src/assets/LESSAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function urlPlugin(asset) {
return {
install: (less, pluginManager) => {
let visitor = new less.visitors.Visitor({
visitUrl: (node) => {
visitUrl: node => {
node.value.value = asset.addURLDependency(
node.value.value,
node.currentFileInfo.filename
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()
}