webpack 4.3.0 → 4.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/webpack.js +69 -10
- package/lib/APIPlugin.js +2 -2
- package/lib/AmdMainTemplatePlugin.js +4 -6
- package/lib/AsyncDependencyToInitialChunkError.js +1 -3
- package/lib/Compilation.js +8 -4
- package/lib/Compiler.js +7 -10
- package/lib/ContextModule.js +19 -7
- package/lib/DefinePlugin.js +2 -2
- package/lib/Dependency.js +53 -52
- package/lib/EnvironmentPlugin.js +1 -3
- package/lib/ExternalModule.js +3 -3
- package/lib/HotUpdateChunkTemplate.js +1 -1
- package/lib/JavascriptGenerator.js +7 -7
- package/lib/JavascriptModulesPlugin.js +6 -6
- package/lib/MainTemplate.js +2 -2
- package/lib/Module.js +343 -340
- package/lib/ModuleFilenameHelpers.js +1 -1
- package/lib/MultiModule.js +4 -1
- package/lib/NoModeWarning.js +23 -21
- package/lib/NormalModule.js +9 -0
- package/lib/NormalModuleFactory.js +1 -1
- package/lib/Parser.js +7 -3
- package/lib/ProgressPlugin.js +231 -231
- package/lib/RecordIdsPlugin.js +2 -2
- package/lib/RuntimeTemplate.js +15 -45
- package/lib/Stats.js +2 -0
- package/lib/Template.js +1 -1
- package/lib/TemplatedPathPlugin.js +1 -3
- package/lib/UmdMainTemplatePlugin.js +41 -45
- package/lib/WebAssemblyParser.js +1 -5
- package/lib/WebpackOptionsApply.js +2 -2
- package/lib/WebpackOptionsDefaulter.js +10 -8
- package/lib/WebpackOptionsValidationError.js +6 -8
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +13 -13
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +1 -1
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +5 -11
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +3 -3
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +4 -6
- package/lib/dependencies/ImportParserPlugin.js +2 -6
- package/lib/dependencies/RequireIncludeDependency.js +1 -1
- package/lib/dependencies/WebpackMissingModule.js +1 -3
- package/lib/node/ReadFileCompileWasmMainTemplatePlugin.js +1 -3
- package/lib/optimize/ConcatenatedModule.js +19 -20
- package/lib/optimize/SplitChunksPlugin.js +30 -14
- package/lib/performance/SizeLimitsPlugin.js +105 -105
- package/lib/web/JsonpChunkTemplatePlugin.js +5 -5
- package/lib/web/JsonpMainTemplatePlugin.js +2 -2
- package/package.json +7 -6
- package/schemas/WebpackOptions.json +23 -16
- package/schemas/ajv.absolutePath.js +1 -1
package/lib/MultiModule.js
CHANGED
@@ -15,10 +15,13 @@ class MultiModule extends Module {
|
|
15
15
|
// Info from Factory
|
16
16
|
this.dependencies = dependencies;
|
17
17
|
this.name = name;
|
18
|
+
this._identifier = `multi ${this.dependencies
|
19
|
+
.map(d => d.request)
|
20
|
+
.join(" ")}`;
|
18
21
|
}
|
19
22
|
|
20
23
|
identifier() {
|
21
|
-
return
|
24
|
+
return this._identifier;
|
22
25
|
}
|
23
26
|
|
24
27
|
readableIdentifier(requestShortener) {
|
package/lib/NoModeWarning.js
CHANGED
@@ -1,21 +1,23 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const WebpackError = require("./WebpackError");
|
8
|
-
|
9
|
-
module.exports = class NoModeWarning extends WebpackError {
|
10
|
-
constructor(modules) {
|
11
|
-
super();
|
12
|
-
|
13
|
-
this.name = "NoModeWarning";
|
14
|
-
this.message =
|
15
|
-
"configuration\n" +
|
16
|
-
"The 'mode' option has not been set. " +
|
17
|
-
"Set 'mode' option to 'development' or 'production' to enable defaults for
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const WebpackError = require("./WebpackError");
|
8
|
+
|
9
|
+
module.exports = class NoModeWarning extends WebpackError {
|
10
|
+
constructor(modules) {
|
11
|
+
super();
|
12
|
+
|
13
|
+
this.name = "NoModeWarning";
|
14
|
+
this.message =
|
15
|
+
"configuration\n" +
|
16
|
+
"The 'mode' option has not been set, webpack will fallback to 'production' for this value. " +
|
17
|
+
"Set 'mode' option to 'development' or 'production' to enable defaults for each environment.\n" +
|
18
|
+
"You can also set it to 'none' to disable any default behavior. " +
|
19
|
+
"Learn more: https://webpack.js.org/concepts/mode/";
|
20
|
+
|
21
|
+
Error.captureStackTrace(this, this.constructor);
|
22
|
+
}
|
23
|
+
};
|
package/lib/NormalModule.js
CHANGED
@@ -122,6 +122,15 @@ class NormalModule extends Module {
|
|
122
122
|
return this.resource;
|
123
123
|
}
|
124
124
|
|
125
|
+
updateCacheModule(module) {
|
126
|
+
this.userRequest = module.userRequest;
|
127
|
+
this.parser = module.parser;
|
128
|
+
this.generator = module.generator;
|
129
|
+
this.resource = module.resource;
|
130
|
+
this.loaders = module.loaders;
|
131
|
+
this.resolveOptions = module.resolveOptions;
|
132
|
+
}
|
133
|
+
|
125
134
|
createSourceForAsset(name, content, sourceMap) {
|
126
135
|
if (!sourceMap) {
|
127
136
|
return new RawSource(content);
|
package/lib/Parser.js
CHANGED
@@ -1178,7 +1178,11 @@ class Parser extends Tapable {
|
|
1178
1178
|
|
1179
1179
|
walkExportDefaultDeclaration(statement) {
|
1180
1180
|
this.hooks.export.call(statement);
|
1181
|
-
if (
|
1181
|
+
if (
|
1182
|
+
statement.declaration.id &&
|
1183
|
+
statement.declaration.type !== "FunctionExpression" &&
|
1184
|
+
statement.declaration.type !== "ClassExpression"
|
1185
|
+
) {
|
1182
1186
|
if (
|
1183
1187
|
!this.hooks.exportDeclaration.call(statement, statement.declaration)
|
1184
1188
|
) {
|
@@ -1647,7 +1651,7 @@ class Parser extends Tapable {
|
|
1647
1651
|
expression.arguments &&
|
1648
1652
|
expression.arguments.length > 0
|
1649
1653
|
) {
|
1650
|
-
// (function(
|
1654
|
+
// (function(…) { }.call/bind(?, …))
|
1651
1655
|
walkIIFE.call(
|
1652
1656
|
this,
|
1653
1657
|
expression.callee.object,
|
@@ -1658,7 +1662,7 @@ class Parser extends Tapable {
|
|
1658
1662
|
expression.callee.type === "FunctionExpression" &&
|
1659
1663
|
expression.arguments
|
1660
1664
|
) {
|
1661
|
-
// (function(
|
1665
|
+
// (function(…) { }(…))
|
1662
1666
|
walkIIFE.call(this, expression.callee, expression.arguments);
|
1663
1667
|
} else if (expression.callee.type === "Import") {
|
1664
1668
|
result = this.hooks.importCall.call(expression);
|
package/lib/ProgressPlugin.js
CHANGED
@@ -1,231 +1,231 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const createDefaultHandler = profile => {
|
8
|
-
let lineCaretPosition = 0;
|
9
|
-
let lastState;
|
10
|
-
let lastStateTime;
|
11
|
-
|
12
|
-
const defaultHandler = (percentage, msg, ...args) => {
|
13
|
-
let state = msg;
|
14
|
-
const details = args;
|
15
|
-
if (percentage < 1) {
|
16
|
-
percentage = Math.floor(percentage * 100);
|
17
|
-
msg = `${percentage}% ${msg}`;
|
18
|
-
if (percentage < 100) {
|
19
|
-
msg = ` ${msg}`;
|
20
|
-
}
|
21
|
-
if (percentage < 10) {
|
22
|
-
msg = ` ${msg}`;
|
23
|
-
}
|
24
|
-
for (let detail of details) {
|
25
|
-
if (!detail) continue;
|
26
|
-
if (detail.length > 40) {
|
27
|
-
detail =
|
28
|
-
}
|
29
|
-
msg += ` ${detail}`;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
if (profile) {
|
33
|
-
state = state.replace(/^\d+\/\d+\s+/, "");
|
34
|
-
if (percentage === 0) {
|
35
|
-
lastState = null;
|
36
|
-
lastStateTime = Date.now();
|
37
|
-
} else if (state !== lastState || percentage === 1) {
|
38
|
-
const now = Date.now();
|
39
|
-
if (lastState) {
|
40
|
-
const stateMsg = `${now - lastStateTime}ms ${lastState}`;
|
41
|
-
goToLineStart(stateMsg);
|
42
|
-
process.stderr.write(stateMsg + "\n");
|
43
|
-
lineCaretPosition = 0;
|
44
|
-
}
|
45
|
-
lastState = state;
|
46
|
-
lastStateTime = now;
|
47
|
-
}
|
48
|
-
}
|
49
|
-
goToLineStart(msg);
|
50
|
-
process.stderr.write(msg);
|
51
|
-
};
|
52
|
-
|
53
|
-
const goToLineStart = nextMessage => {
|
54
|
-
let str = "";
|
55
|
-
for (; lineCaretPosition > nextMessage.length; lineCaretPosition--) {
|
56
|
-
str += "\b \b";
|
57
|
-
}
|
58
|
-
for (var i = 0; i < lineCaretPosition; i++) {
|
59
|
-
str += "\b";
|
60
|
-
}
|
61
|
-
lineCaretPosition = nextMessage.length;
|
62
|
-
if (str) process.stderr.write(str);
|
63
|
-
};
|
64
|
-
|
65
|
-
return defaultHandler;
|
66
|
-
};
|
67
|
-
|
68
|
-
class ProgressPlugin {
|
69
|
-
constructor(options) {
|
70
|
-
if (typeof options === "function") {
|
71
|
-
options = {
|
72
|
-
handler: options
|
73
|
-
};
|
74
|
-
}
|
75
|
-
options = options || {};
|
76
|
-
this.profile = options.profile;
|
77
|
-
this.handler = options.handler;
|
78
|
-
}
|
79
|
-
|
80
|
-
apply(compiler) {
|
81
|
-
const handler = this.handler || createDefaultHandler(this.profile);
|
82
|
-
if (compiler.compilers) {
|
83
|
-
const states = new Array(compiler.compilers.length);
|
84
|
-
compiler.compilers.forEach((compiler, idx) => {
|
85
|
-
new ProgressPlugin((p, msg, ...args) => {
|
86
|
-
states[idx] = args;
|
87
|
-
handler(
|
88
|
-
states
|
89
|
-
.map(state => (state && state[0]) || 0)
|
90
|
-
.reduce((a, b) => a + b) / states.length,
|
91
|
-
`[${idx}] ${msg}`,
|
92
|
-
...args
|
93
|
-
);
|
94
|
-
}).apply(compiler);
|
95
|
-
});
|
96
|
-
} else {
|
97
|
-
let lastModulesCount = 0;
|
98
|
-
let moduleCount = 500;
|
99
|
-
let doneModules = 0;
|
100
|
-
const activeModules = [];
|
101
|
-
|
102
|
-
const update = module => {
|
103
|
-
handler(
|
104
|
-
0.1 + doneModules / Math.max(lastModulesCount, moduleCount) * 0.6,
|
105
|
-
"building modules",
|
106
|
-
`${doneModules}/${moduleCount} modules`,
|
107
|
-
`${activeModules.length} active`,
|
108
|
-
activeModules[activeModules.length - 1]
|
109
|
-
);
|
110
|
-
};
|
111
|
-
|
112
|
-
const moduleDone = module => {
|
113
|
-
doneModules++;
|
114
|
-
const ident = module.identifier();
|
115
|
-
if (ident) {
|
116
|
-
const idx = activeModules.indexOf(ident);
|
117
|
-
if (idx >= 0) activeModules.splice(idx, 1);
|
118
|
-
}
|
119
|
-
update();
|
120
|
-
};
|
121
|
-
compiler.hooks.compilation.tap("ProgressPlugin", compilation => {
|
122
|
-
if (compilation.compiler.isChild()) return;
|
123
|
-
lastModulesCount = moduleCount;
|
124
|
-
moduleCount = 0;
|
125
|
-
doneModules = 0;
|
126
|
-
handler(0, "compiling");
|
127
|
-
compilation.hooks.buildModule.tap("ProgressPlugin", module => {
|
128
|
-
moduleCount++;
|
129
|
-
const ident = module.identifier();
|
130
|
-
if (ident) {
|
131
|
-
activeModules.push(ident);
|
132
|
-
}
|
133
|
-
update();
|
134
|
-
});
|
135
|
-
compilation.hooks.failedModule.tap("ProgressPlugin", moduleDone);
|
136
|
-
compilation.hooks.succeedModule.tap("ProgressPlugin", moduleDone);
|
137
|
-
const hooks = {
|
138
|
-
finishModules: "finish module graph",
|
139
|
-
seal: "sealing",
|
140
|
-
optimizeDependenciesBasic: "basic dependencies optimization",
|
141
|
-
optimizeDependencies: "dependencies optimization",
|
142
|
-
optimizeDependenciesAdvanced: "advanced dependencies optimization",
|
143
|
-
afterOptimizeDependencies: "after dependencies optimization",
|
144
|
-
optimize: "optimizing",
|
145
|
-
optimizeModulesBasic: "basic module optimization",
|
146
|
-
optimizeModules: "module optimization",
|
147
|
-
optimizeModulesAdvanced: "advanced module optimization",
|
148
|
-
afterOptimizeModules: "after module optimization",
|
149
|
-
optimizeChunksBasic: "basic chunk optimization",
|
150
|
-
optimizeChunks: "chunk optimization",
|
151
|
-
optimizeChunksAdvanced: "advanced chunk optimization",
|
152
|
-
afterOptimizeChunks: "after chunk optimization",
|
153
|
-
optimizeTree: "module and chunk tree optimization",
|
154
|
-
afterOptimizeTree: "after module and chunk tree optimization",
|
155
|
-
optimizeChunkModulesBasic: "basic chunk modules optimization",
|
156
|
-
optimizeChunkModules: "chunk modules optimization",
|
157
|
-
optimizeChunkModulesAdvanced: "advanced chunk modules optimization",
|
158
|
-
afterOptimizeChunkModules: "after chunk modules optimization",
|
159
|
-
reviveModules: "module reviving",
|
160
|
-
optimizeModuleOrder: "module order optimization",
|
161
|
-
advancedOptimizeModuleOrder: "advanced module order optimization",
|
162
|
-
beforeModuleIds: "before module ids",
|
163
|
-
moduleIds: "module ids",
|
164
|
-
optimizeModuleIds: "module id optimization",
|
165
|
-
afterOptimizeModuleIds: "module id optimization",
|
166
|
-
reviveChunks: "chunk reviving",
|
167
|
-
optimizeChunkOrder: "chunk order optimization",
|
168
|
-
beforeChunkIds: "before chunk ids",
|
169
|
-
optimizeChunkIds: "chunk id optimization",
|
170
|
-
afterOptimizeChunkIds: "after chunk id optimization",
|
171
|
-
recordModules: "record modules",
|
172
|
-
recordChunks: "record chunks",
|
173
|
-
beforeHash: "hashing",
|
174
|
-
afterHash: "after hashing",
|
175
|
-
recordHash: "record hash",
|
176
|
-
beforeModuleAssets: "module assets processing",
|
177
|
-
beforeChunkAssets: "chunk assets processing",
|
178
|
-
additionalChunkAssets: "additional chunk assets processing",
|
179
|
-
record: "recording",
|
180
|
-
additionalAssets: "additional asset processing",
|
181
|
-
optimizeChunkAssets: "chunk asset optimization",
|
182
|
-
afterOptimizeChunkAssets: "after chunk asset optimization",
|
183
|
-
optimizeAssets: "asset optimization",
|
184
|
-
afterOptimizeAssets: "after asset optimization",
|
185
|
-
afterSeal: "after seal"
|
186
|
-
};
|
187
|
-
const numberOfHooks = Object.keys(hooks).length;
|
188
|
-
Object.keys(hooks).forEach((name, idx) => {
|
189
|
-
const title = hooks[name];
|
190
|
-
const percentage = idx / numberOfHooks * 0.25 + 0.7;
|
191
|
-
compilation.hooks[name].intercept({
|
192
|
-
name: "ProgressPlugin",
|
193
|
-
context: true,
|
194
|
-
call: () => {
|
195
|
-
handler(percentage, title);
|
196
|
-
},
|
197
|
-
tap: (context, tap) => {
|
198
|
-
if (context) {
|
199
|
-
// p is percentage from 0 to 1
|
200
|
-
// args is any number of messages in a hierarchical matter
|
201
|
-
context.reportProgress = (p, ...args) => {
|
202
|
-
handler(percentage, title, tap.name, ...args);
|
203
|
-
};
|
204
|
-
}
|
205
|
-
handler(percentage, title, tap.name);
|
206
|
-
}
|
207
|
-
});
|
208
|
-
});
|
209
|
-
});
|
210
|
-
compiler.hooks.emit.intercept({
|
211
|
-
name: "ProgressPlugin",
|
212
|
-
context: true,
|
213
|
-
call: () => {
|
214
|
-
handler(0.95, "emitting");
|
215
|
-
},
|
216
|
-
tap: (context, tap) => {
|
217
|
-
if (context) {
|
218
|
-
context.reportProgress = (p, ...args) => {
|
219
|
-
handler(0.95, "emitting", tap.name, ...args);
|
220
|
-
};
|
221
|
-
}
|
222
|
-
handler(0.95, "emitting", tap.name);
|
223
|
-
}
|
224
|
-
});
|
225
|
-
compiler.hooks.done.tap("ProgressPlugin", () => {
|
226
|
-
handler(1, "");
|
227
|
-
});
|
228
|
-
}
|
229
|
-
}
|
230
|
-
}
|
231
|
-
module.exports = ProgressPlugin;
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const createDefaultHandler = profile => {
|
8
|
+
let lineCaretPosition = 0;
|
9
|
+
let lastState;
|
10
|
+
let lastStateTime;
|
11
|
+
|
12
|
+
const defaultHandler = (percentage, msg, ...args) => {
|
13
|
+
let state = msg;
|
14
|
+
const details = args;
|
15
|
+
if (percentage < 1) {
|
16
|
+
percentage = Math.floor(percentage * 100);
|
17
|
+
msg = `${percentage}% ${msg}`;
|
18
|
+
if (percentage < 100) {
|
19
|
+
msg = ` ${msg}`;
|
20
|
+
}
|
21
|
+
if (percentage < 10) {
|
22
|
+
msg = ` ${msg}`;
|
23
|
+
}
|
24
|
+
for (let detail of details) {
|
25
|
+
if (!detail) continue;
|
26
|
+
if (detail.length > 40) {
|
27
|
+
detail = `…${detail.substr(detail.length - 39)}`;
|
28
|
+
}
|
29
|
+
msg += ` ${detail}`;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
if (profile) {
|
33
|
+
state = state.replace(/^\d+\/\d+\s+/, "");
|
34
|
+
if (percentage === 0) {
|
35
|
+
lastState = null;
|
36
|
+
lastStateTime = Date.now();
|
37
|
+
} else if (state !== lastState || percentage === 1) {
|
38
|
+
const now = Date.now();
|
39
|
+
if (lastState) {
|
40
|
+
const stateMsg = `${now - lastStateTime}ms ${lastState}`;
|
41
|
+
goToLineStart(stateMsg);
|
42
|
+
process.stderr.write(stateMsg + "\n");
|
43
|
+
lineCaretPosition = 0;
|
44
|
+
}
|
45
|
+
lastState = state;
|
46
|
+
lastStateTime = now;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
goToLineStart(msg);
|
50
|
+
process.stderr.write(msg);
|
51
|
+
};
|
52
|
+
|
53
|
+
const goToLineStart = nextMessage => {
|
54
|
+
let str = "";
|
55
|
+
for (; lineCaretPosition > nextMessage.length; lineCaretPosition--) {
|
56
|
+
str += "\b \b";
|
57
|
+
}
|
58
|
+
for (var i = 0; i < lineCaretPosition; i++) {
|
59
|
+
str += "\b";
|
60
|
+
}
|
61
|
+
lineCaretPosition = nextMessage.length;
|
62
|
+
if (str) process.stderr.write(str);
|
63
|
+
};
|
64
|
+
|
65
|
+
return defaultHandler;
|
66
|
+
};
|
67
|
+
|
68
|
+
class ProgressPlugin {
|
69
|
+
constructor(options) {
|
70
|
+
if (typeof options === "function") {
|
71
|
+
options = {
|
72
|
+
handler: options
|
73
|
+
};
|
74
|
+
}
|
75
|
+
options = options || {};
|
76
|
+
this.profile = options.profile;
|
77
|
+
this.handler = options.handler;
|
78
|
+
}
|
79
|
+
|
80
|
+
apply(compiler) {
|
81
|
+
const handler = this.handler || createDefaultHandler(this.profile);
|
82
|
+
if (compiler.compilers) {
|
83
|
+
const states = new Array(compiler.compilers.length);
|
84
|
+
compiler.compilers.forEach((compiler, idx) => {
|
85
|
+
new ProgressPlugin((p, msg, ...args) => {
|
86
|
+
states[idx] = args;
|
87
|
+
handler(
|
88
|
+
states
|
89
|
+
.map(state => (state && state[0]) || 0)
|
90
|
+
.reduce((a, b) => a + b) / states.length,
|
91
|
+
`[${idx}] ${msg}`,
|
92
|
+
...args
|
93
|
+
);
|
94
|
+
}).apply(compiler);
|
95
|
+
});
|
96
|
+
} else {
|
97
|
+
let lastModulesCount = 0;
|
98
|
+
let moduleCount = 500;
|
99
|
+
let doneModules = 0;
|
100
|
+
const activeModules = [];
|
101
|
+
|
102
|
+
const update = module => {
|
103
|
+
handler(
|
104
|
+
0.1 + doneModules / Math.max(lastModulesCount, moduleCount) * 0.6,
|
105
|
+
"building modules",
|
106
|
+
`${doneModules}/${moduleCount} modules`,
|
107
|
+
`${activeModules.length} active`,
|
108
|
+
activeModules[activeModules.length - 1]
|
109
|
+
);
|
110
|
+
};
|
111
|
+
|
112
|
+
const moduleDone = module => {
|
113
|
+
doneModules++;
|
114
|
+
const ident = module.identifier();
|
115
|
+
if (ident) {
|
116
|
+
const idx = activeModules.indexOf(ident);
|
117
|
+
if (idx >= 0) activeModules.splice(idx, 1);
|
118
|
+
}
|
119
|
+
update();
|
120
|
+
};
|
121
|
+
compiler.hooks.compilation.tap("ProgressPlugin", compilation => {
|
122
|
+
if (compilation.compiler.isChild()) return;
|
123
|
+
lastModulesCount = moduleCount;
|
124
|
+
moduleCount = 0;
|
125
|
+
doneModules = 0;
|
126
|
+
handler(0, "compiling");
|
127
|
+
compilation.hooks.buildModule.tap("ProgressPlugin", module => {
|
128
|
+
moduleCount++;
|
129
|
+
const ident = module.identifier();
|
130
|
+
if (ident) {
|
131
|
+
activeModules.push(ident);
|
132
|
+
}
|
133
|
+
update();
|
134
|
+
});
|
135
|
+
compilation.hooks.failedModule.tap("ProgressPlugin", moduleDone);
|
136
|
+
compilation.hooks.succeedModule.tap("ProgressPlugin", moduleDone);
|
137
|
+
const hooks = {
|
138
|
+
finishModules: "finish module graph",
|
139
|
+
seal: "sealing",
|
140
|
+
optimizeDependenciesBasic: "basic dependencies optimization",
|
141
|
+
optimizeDependencies: "dependencies optimization",
|
142
|
+
optimizeDependenciesAdvanced: "advanced dependencies optimization",
|
143
|
+
afterOptimizeDependencies: "after dependencies optimization",
|
144
|
+
optimize: "optimizing",
|
145
|
+
optimizeModulesBasic: "basic module optimization",
|
146
|
+
optimizeModules: "module optimization",
|
147
|
+
optimizeModulesAdvanced: "advanced module optimization",
|
148
|
+
afterOptimizeModules: "after module optimization",
|
149
|
+
optimizeChunksBasic: "basic chunk optimization",
|
150
|
+
optimizeChunks: "chunk optimization",
|
151
|
+
optimizeChunksAdvanced: "advanced chunk optimization",
|
152
|
+
afterOptimizeChunks: "after chunk optimization",
|
153
|
+
optimizeTree: "module and chunk tree optimization",
|
154
|
+
afterOptimizeTree: "after module and chunk tree optimization",
|
155
|
+
optimizeChunkModulesBasic: "basic chunk modules optimization",
|
156
|
+
optimizeChunkModules: "chunk modules optimization",
|
157
|
+
optimizeChunkModulesAdvanced: "advanced chunk modules optimization",
|
158
|
+
afterOptimizeChunkModules: "after chunk modules optimization",
|
159
|
+
reviveModules: "module reviving",
|
160
|
+
optimizeModuleOrder: "module order optimization",
|
161
|
+
advancedOptimizeModuleOrder: "advanced module order optimization",
|
162
|
+
beforeModuleIds: "before module ids",
|
163
|
+
moduleIds: "module ids",
|
164
|
+
optimizeModuleIds: "module id optimization",
|
165
|
+
afterOptimizeModuleIds: "module id optimization",
|
166
|
+
reviveChunks: "chunk reviving",
|
167
|
+
optimizeChunkOrder: "chunk order optimization",
|
168
|
+
beforeChunkIds: "before chunk ids",
|
169
|
+
optimizeChunkIds: "chunk id optimization",
|
170
|
+
afterOptimizeChunkIds: "after chunk id optimization",
|
171
|
+
recordModules: "record modules",
|
172
|
+
recordChunks: "record chunks",
|
173
|
+
beforeHash: "hashing",
|
174
|
+
afterHash: "after hashing",
|
175
|
+
recordHash: "record hash",
|
176
|
+
beforeModuleAssets: "module assets processing",
|
177
|
+
beforeChunkAssets: "chunk assets processing",
|
178
|
+
additionalChunkAssets: "additional chunk assets processing",
|
179
|
+
record: "recording",
|
180
|
+
additionalAssets: "additional asset processing",
|
181
|
+
optimizeChunkAssets: "chunk asset optimization",
|
182
|
+
afterOptimizeChunkAssets: "after chunk asset optimization",
|
183
|
+
optimizeAssets: "asset optimization",
|
184
|
+
afterOptimizeAssets: "after asset optimization",
|
185
|
+
afterSeal: "after seal"
|
186
|
+
};
|
187
|
+
const numberOfHooks = Object.keys(hooks).length;
|
188
|
+
Object.keys(hooks).forEach((name, idx) => {
|
189
|
+
const title = hooks[name];
|
190
|
+
const percentage = idx / numberOfHooks * 0.25 + 0.7;
|
191
|
+
compilation.hooks[name].intercept({
|
192
|
+
name: "ProgressPlugin",
|
193
|
+
context: true,
|
194
|
+
call: () => {
|
195
|
+
handler(percentage, title);
|
196
|
+
},
|
197
|
+
tap: (context, tap) => {
|
198
|
+
if (context) {
|
199
|
+
// p is percentage from 0 to 1
|
200
|
+
// args is any number of messages in a hierarchical matter
|
201
|
+
context.reportProgress = (p, ...args) => {
|
202
|
+
handler(percentage, title, tap.name, ...args);
|
203
|
+
};
|
204
|
+
}
|
205
|
+
handler(percentage, title, tap.name);
|
206
|
+
}
|
207
|
+
});
|
208
|
+
});
|
209
|
+
});
|
210
|
+
compiler.hooks.emit.intercept({
|
211
|
+
name: "ProgressPlugin",
|
212
|
+
context: true,
|
213
|
+
call: () => {
|
214
|
+
handler(0.95, "emitting");
|
215
|
+
},
|
216
|
+
tap: (context, tap) => {
|
217
|
+
if (context) {
|
218
|
+
context.reportProgress = (p, ...args) => {
|
219
|
+
handler(0.95, "emitting", tap.name, ...args);
|
220
|
+
};
|
221
|
+
}
|
222
|
+
handler(0.95, "emitting", tap.name);
|
223
|
+
}
|
224
|
+
});
|
225
|
+
compiler.hooks.done.tap("ProgressPlugin", () => {
|
226
|
+
handler(1, "");
|
227
|
+
});
|
228
|
+
}
|
229
|
+
}
|
230
|
+
}
|
231
|
+
module.exports = ProgressPlugin;
|
package/lib/RecordIdsPlugin.js
CHANGED
@@ -26,7 +26,7 @@ class RecordIdsPlugin {
|
|
26
26
|
compiler.context,
|
27
27
|
module.identifier(),
|
28
28
|
compilation.cache
|
29
|
-
|
29
|
+
)
|
30
30
|
: module.identifier();
|
31
31
|
records.modules.byIdentifier[identifier] = module.id;
|
32
32
|
records.modules.usedIds[module.id] = module.id;
|
@@ -46,7 +46,7 @@ class RecordIdsPlugin {
|
|
46
46
|
compiler.context,
|
47
47
|
module.identifier(),
|
48
48
|
compilation.cache
|
49
|
-
|
49
|
+
)
|
50
50
|
: module.identifier();
|
51
51
|
const id = records.modules.byIdentifier[identifier];
|
52
52
|
if (id === undefined) continue;
|