Skip to content

Commit 5e18c1c

Browse files
committed
WIP7
1 parent 995ceab commit 5e18c1c

File tree

20 files changed

+286
-157
lines changed

20 files changed

+286
-157
lines changed

lib/ChunkGroup.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ class ChunkGroup {
220220
}
221221

222222
addOrigin(module, loc, request) {
223-
if(!module) throw new Error("No origin module");
224223
this.origins.push({
225224
module,
226225
loc,
@@ -279,8 +278,8 @@ class ChunkGroup {
279278

280279
sortItems() {
281280
this.origins.sort((a, b) => {
282-
const aIdent = a.module.identifier();
283-
const bIdent = b.module.identifier();
281+
const aIdent = a.module ? a.module.identifier() : "";
282+
const bIdent = b.module ? b.module.identifier() : "";
284283
if(aIdent < bIdent) return -1;
285284
if(aIdent > bIdent) return 1;
286285
return compareLocations(a.loc, b.loc);

lib/Compilation.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ class Compilation extends Tapable {
650650
addEntry(context, entry, name, callback) {
651651
const slot = {
652652
name: name,
653+
request: entry.request,
653654
module: null
654655
};
655656
this._preparedEntrypoints.push(slot);
@@ -753,6 +754,7 @@ class Compilation extends Tapable {
753754
const name = preparedEntrypoint.name;
754755
const chunk = this.addChunk(name);
755756
const entrypoint = new Entrypoint(name);
757+
entrypoint.addOrigin(null, name, preparedEntrypoint.request);
756758
this.namedChunkGroups.set(name, entrypoint);
757759
this.entrypoints.set(name, entrypoint);
758760
this.chunkGroups.push(entrypoint);
@@ -1063,6 +1065,7 @@ class Compilation extends Tapable {
10631065
// Start with the provided modules/chunks
10641066
const queue = inputChunkGroups.map(chunkGroup => ({
10651067
block: chunkGroup.chunks[0].entryModule,
1068+
module: chunkGroup.chunks[0].entryModule,
10661069
chunk: chunkGroup.chunks[0],
10671070
chunkGroup
10681071
}));

lib/Stats.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,9 @@ class Stats {
940940
colors.bold(module.name);
941941
colors.normal(" ");
942942
}
943-
if(origin.loc) {
944-
colors.normal(origin.loc);
945-
}
943+
}
944+
if(origin.loc) {
945+
colors.normal(origin.loc);
946946
}
947947
newline();
948948
});

lib/optimize/AggressiveSplittingPlugin.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ class AggressiveSplittingPlugin {
8888
if(splitData.id !== null && splitData.id !== undefined) {
8989
newChunk.id = splitData.id;
9090
}
91-
newChunk.origins = chunk.origins.map(copyWithReason);
92-
chunk.origins = chunk.origins.map(copyWithReason);
9391
return true;
9492
} else { // chunk is identical to the split
9593
if(j < savedSplits.length)
@@ -141,8 +139,6 @@ class AggressiveSplittingPlugin {
141139
if(newChunk.getNumberOfModules() > 0) {
142140
chunk.split(newChunk);
143141
chunk.name = null;
144-
newChunk.origins = chunk.origins.map(copyWithReason);
145-
chunk.origins = chunk.origins.map(copyWithReason);
146142
compilation._aggressiveSplittingSplits = (compilation._aggressiveSplittingSplits || []).concat({
147143
modules: newChunk.mapModules(m => identifierUtils.makePathsRelative(compiler.context, m.identifier(), compilation.cache))
148144
});

lib/web/JsonpMainTemplatePlugin.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,16 @@ class JsonpMainTemplatePlugin {
162162
});
163163
mainTemplate.hooks.bootstrap.tap("JsonpMainTemplatePlugin", (source, chunk, hash) => {
164164
if(needChunkLoadingCode(chunk)) {
165+
const withDefer = needEntryDeferringCode(chunk);
165166
return Template.asString([
166167
source,
167168
"",
168169
"// install a JSONP callback for chunk loading",
169170
"function webpackJsonpCallback(data) {",
170171
Template.indent([
171-
"var chunkIds = data[0], moreModules = data[1], executeModules = data[2];",
172+
"var chunkIds = data[0];",
173+
"var moreModules = data[1]",
174+
withDefer ? "var executeModules = data[2];" : "",
172175
"// add \"moreModules\" to the modules object,",
173176
"// then flag all \"chunkIds\" as loaded and fire callback",
174177
"var moduleId, chunkId, i = 0, resolves = [];",
@@ -192,7 +195,7 @@ class JsonpMainTemplatePlugin {
192195
"while(resolves.length) {",
193196
Template.indent("resolves.shift()();"),
194197
"}",
195-
needEntryDeferringCode(chunk) ? Template.asString([
198+
withDefer ? Template.asString([
196199
"",
197200
"// add entry modules from loaded chunk to deferred list",
198201
"deferredModules.push.apply(deferredModules, executeModules || []);",
@@ -202,7 +205,7 @@ class JsonpMainTemplatePlugin {
202205
]) : ""
203206
]),
204207
"};",
205-
needEntryDeferringCode(chunk) ? Template.asString([
208+
withDefer ? Template.asString([
206209
"function checkDeferredModules() {",
207210
Template.indent([
208211
"var result;",

test/statsCases/async-commons-chunk-all-selected/a.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/statsCases/async-commons-chunk-all-selected/b.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/statsCases/async-commons-chunk-all-selected/c.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/statsCases/async-commons-chunk-all-selected/expected.txt

Lines changed: 0 additions & 15 deletions
This file was deleted.

test/statsCases/async-commons-chunk-all-selected/index.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)