Skip to content

Commit 45fcb1f

Browse files
committed
testcase+fix for CommonsChunkPlugin and entries
1 parent a9dcf43 commit 45fcb1f

File tree

6 files changed

+34
-1
lines changed

6 files changed

+34
-1
lines changed

lib/JsonpChunkTemplatePlugin.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ JsonpChunkTemplatePlugin.prototype.apply = function(chunkTemplate) {
1414
var source = new ConcatSource();
1515
source.add(jsonpFunction + "(" + JSON.stringify(chunk.ids) + ",");
1616
source.add(modules);
17+
var entries = chunk.modules.filter(function(m) {
18+
return m.entry;
19+
}).map(function(m) {
20+
return m.id;
21+
});
22+
if(entries.length > 0) {
23+
source.add("," + JSON.stringify(entries));
24+
}
1725
source.add(")");
1826
return source;
1927
});

test/browsertest/lib/index.web.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ describe("main", function() {
2525
});
2626

2727
it("should load library2 exported as global", function() {
28+
should.exist(window.library2common);
29+
should.exist(window.library2common.ok2);
30+
window.library2common.ok2.should.be.eql(true);
2831
should.exist(window.library2);
2932
should.exist(window.library2.ok);
3033
window.library2.ok.should.be.eql(true);

test/browsertest/library2config.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
webpack = require("../../");
22
module.exports =
3+
entry:
4+
common: "library2/lib/common"
35
output:
46
hashDigestLength: 5
57
module:
@@ -15,7 +17,8 @@ module.exports =
1517
should: require.resolve "should"
1618
plugins: [
1719
new webpack.optimize.LimitChunkCountPlugin
18-
maxChunks: 2
20+
maxChunks: 3
21+
new webpack.optimize.CommonsChunkPlugin "common", "library2.commons.js"
1922
new webpack.DefinePlugin
2023
"typeof CONST_TYPEOF": JSON.stringify("typeof"),
2124
CONST_UNDEFINED: undefined,

test/browsertest/node_modules/library2/lib/common.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/browsertest/node_modules/library2/lib/main.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/browsertest/tests.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<script>
1010
mocha.setup('bdd');
1111
</script>
12+
<script src="js/library2.commons.js" charset="utf-8"></script>
1213
<script src="js/library2.js" charset="utf-8"></script>
1314
<script src="js/web.js" charset="utf-8"></script>
1415
<!-- fixtures -->

0 commit comments

Comments
 (0)