Skip to content

Commit 8851427

Browse files
committed
use chunk ids in entry chunks too
this fixes a unnecessary download in mutli-entry compilations
1 parent 63f40c0 commit 8851427

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

lib/JsonpMainTemplate.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,14 @@ JsonpMainTemplate.prototype.renderLocalVars = function(hash, chunk) {
2020
"// object to store loaded and loading chunks",
2121
'// "0" means "already loaded"',
2222
'// Array means "loading", array contains callbacks',
23-
chunk.modules.some(function(m) { return m.id === 0; }) ?
24-
"var installedChunks = {0:0};" :
25-
"var installedChunks = {0:[function(require){require(0);}]};"
23+
"var installedChunks = {",
24+
this.indent(
25+
(chunk.ids.indexOf(0) < 0 ? "0:[function(require){require(0);}],\n" : "") +
26+
chunk.ids.map(function(id) {
27+
return id + ":0"
28+
}).join(",\n")
29+
),
30+
"};"
2631
);
2732
}
2833
return buf;

lib/node/NodeMainTemplate.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ NodeMainTemplate.prototype.renderLocalVars = function(hash, chunk) {
2020
"",
2121
"// object to store loaded chunks",
2222
'// "1" means "already loaded"',
23-
"var installedChunks = {0:1};"
23+
"var installedChunks = {",
24+
this.indent(
25+
chunk.ids.map(function(id) {
26+
return id + ":1"
27+
}).join(",\n")
28+
),
29+
"};"
2430
);
2531
}
2632
return buf;

lib/webworker/WebWorkerMainTemplate.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@ WebWorkerMainTemplate.prototype.renderLocalVars = function(hash, chunk) {
1919
"",
2020
"// object to store loaded chunks",
2121
'// "1" means "already loaded"',
22-
"var installedChunks = {0:1};"
22+
"var installedChunks = {",
23+
this.indent(
24+
chunk.ids.map(function(id) {
25+
return id + ":1"
26+
}).join(",\n")
27+
),
28+
"};"
2329
);
2430
}
2531
return buf;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webpack",
3-
"version": "0.11.11",
3+
"version": "0.11.12",
44
"author": "Tobias Koppers @sokra",
55
"description": "Packs CommonJs/AMD/Labeled Modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jade, coffee, css, less, ... and your custom stuff.",
66
"dependencies": {

0 commit comments

Comments
 (0)