webpack 4.1.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/README.md +719 -721
- package/bin/webpack.js +69 -10
- package/lib/APIPlugin.js +84 -84
- package/lib/AmdMainTemplatePlugin.js +75 -77
- package/lib/AsyncDependencyToInitialChunkError.js +21 -23
- package/lib/BannerPlugin.js +101 -101
- package/lib/Chunk.js +477 -469
- package/lib/ChunkTemplate.js +51 -53
- package/lib/Compilation.js +1858 -1851
- package/lib/Compiler.js +493 -478
- package/lib/ConcurrentCompilationError.js +19 -0
- package/lib/ContextModule.js +696 -685
- package/lib/ContextModuleFactory.js +245 -243
- package/lib/DefinePlugin.js +197 -197
- package/lib/DelegatedModule.js +101 -101
- package/lib/DependenciesBlockVariable.js +51 -52
- package/lib/Dependency.js +53 -52
- package/lib/DllModule.js +54 -54
- package/lib/DllModuleFactory.js +29 -29
- package/lib/EnvironmentPlugin.js +65 -67
- package/lib/EvalDevToolModuleTemplatePlugin.js +60 -60
- package/lib/EvalSourceMapDevToolModuleTemplatePlugin.js +105 -105
- package/lib/ExportPropertyMainTemplatePlugin.js +40 -40
- package/lib/ExternalModule.js +159 -159
- package/lib/FunctionModuleTemplatePlugin.js +98 -98
- package/lib/HotModuleReplacement.runtime.js +631 -631
- package/lib/HotModuleReplacementPlugin.js +407 -406
- package/lib/HotUpdateChunkTemplate.js +78 -80
- package/lib/JavascriptGenerator.js +228 -229
- package/lib/JavascriptModulesPlugin.js +184 -158
- package/lib/JsonGenerator.js +42 -42
- package/lib/MainTemplate.js +406 -402
- package/lib/Module.js +343 -340
- package/lib/ModuleBuildError.js +42 -42
- package/lib/ModuleError.js +28 -28
- package/lib/ModuleFilenameHelpers.js +166 -166
- package/lib/ModuleTemplate.js +77 -79
- package/lib/ModuleWarning.js +30 -30
- package/lib/MultiCompiler.js +271 -259
- package/lib/MultiModule.js +78 -75
- package/lib/MultiModuleFactory.js +23 -23
- package/lib/MultiWatching.js +38 -37
- package/lib/NoModeWarning.js +23 -21
- package/lib/NormalModule.js +478 -470
- package/lib/NormalModuleFactory.js +483 -481
- package/lib/OptionsDefaulter.js +80 -86
- package/lib/Parser.js +2074 -2071
- package/lib/ProgressPlugin.js +231 -231
- package/lib/RawModule.js +54 -55
- package/lib/RecordIdsPlugin.js +160 -160
- package/lib/RemovedPluginError.js +13 -13
- package/lib/ResolverFactory.js +64 -67
- package/lib/RuntimeTemplate.js +267 -297
- package/lib/SetVarMainTemplatePlugin.js +57 -57
- package/lib/SourceMapDevToolPlugin.js +302 -308
- package/lib/Stats.js +1234 -1212
- package/lib/Template.js +205 -205
- package/lib/TemplatedPathPlugin.js +170 -143
- package/lib/UmdMainTemplatePlugin.js +264 -269
- package/lib/Watching.js +193 -193
- package/lib/WebAssemblyParser.js +50 -54
- package/lib/WebpackOptionsApply.js +401 -401
- package/lib/WebpackOptionsDefaulter.js +337 -317
- package/lib/WebpackOptionsValidationError.js +316 -319
- package/lib/debug/ProfilingPlugin.js +409 -405
- package/lib/dependencies/AMDDefineDependencyParserPlugin.js +328 -311
- package/lib/dependencies/AMDRequireContextDependency.js +20 -20
- package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +270 -241
- package/lib/dependencies/HarmonyAcceptImportDependency.js +23 -23
- package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +620 -606
- package/lib/dependencies/HarmonyExportSpecifierDependency.js +53 -53
- package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +214 -214
- package/lib/dependencies/HarmonyImportSpecifierDependency.js +154 -156
- package/lib/dependencies/ImportDependenciesBlock.js +17 -17
- package/lib/dependencies/ImportDependency.js +34 -34
- package/lib/dependencies/ImportEagerDependency.js +32 -32
- package/lib/dependencies/ImportParserPlugin.js +175 -179
- package/lib/dependencies/ImportWeakDependency.js +34 -34
- package/lib/dependencies/JsonExportsDependency.js +25 -25
- package/lib/dependencies/ModuleDependency.js +20 -20
- package/lib/dependencies/NullDependency.js +20 -20
- package/lib/dependencies/RequireContextDependency.js +22 -22
- package/lib/dependencies/RequireIncludeDependency.js +40 -40
- package/lib/dependencies/WebpackMissingModule.js +20 -22
- package/lib/node/NodeChunkTemplatePlugin.js +31 -31
- package/lib/node/NodeHotUpdateChunkTemplatePlugin.js +36 -36
- package/lib/node/NodeMainTemplatePlugin.js +320 -273
- package/lib/node/ReadFileCompileWasmMainTemplatePlugin.js +113 -115
- package/lib/optimize/AggressiveSplittingPlugin.js +281 -281
- package/lib/optimize/ConcatenatedModule.js +1364 -1366
- package/lib/optimize/RemoveParentModulesPlugin.js +114 -114
- package/lib/optimize/SplitChunksPlugin.js +519 -491
- package/lib/performance/SizeLimitsPlugin.js +105 -105
- package/lib/util/TrackingSet.js +35 -35
- package/lib/util/objectToMap.js +10 -10
- package/lib/wasm/WasmModuleTemplatePlugin.js +106 -106
- package/lib/web/JsonpChunkTemplatePlugin.js +47 -47
- package/lib/web/JsonpExportMainTemplatePlugin.js +47 -47
- package/lib/web/JsonpHotUpdateChunkTemplatePlugin.js +39 -39
- package/lib/web/JsonpMainTemplatePlugin.js +425 -403
- package/lib/webpack.js +182 -179
- package/lib/webworker/WebWorkerChunkTemplatePlugin.js +35 -35
- package/lib/webworker/WebWorkerHotUpdateChunkTemplatePlugin.js +40 -40
- package/lib/webworker/WebWorkerMainTemplatePlugin.js +177 -154
- package/package.json +9 -8
- package/schemas/WebpackOptions.json +1973 -1951
- package/schemas/ajv.absolutePath.js +55 -29
- package/schemas/plugins/BannerPlugin.json +85 -85
- package/schemas/plugins/DllPlugin.json +28 -28
- package/schemas/plugins/DllReferencePlugin.json +99 -99
- package/schemas/plugins/HashedModuleIdsPlugin.json +24 -24
- package/schemas/plugins/LoaderOptionsPlugin.json +26 -26
- package/schemas/plugins/SourceMapDevToolPlugin.json +187 -187
- package/schemas/plugins/WatchIgnorePlugin.json +16 -16
- package/schemas/plugins/debug/ProfilingPlugin.json +12 -12
- package/schemas/plugins/optimize/AggressiveSplittingPlugin.json +22 -22
- package/schemas/plugins/optimize/LimitChunkCountPlugin.json +15 -15
- package/schemas/plugins/optimize/MinChunkSizePlugin.json +13 -13
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/RawModule.js
CHANGED
@@ -1,55 +1,54 @@
|
|
1
|
-
/*
|
2
|
-
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
-
Author Tobias Koppers @sokra
|
4
|
-
*/
|
5
|
-
"use strict";
|
6
|
-
|
7
|
-
const Module = require("./Module");
|
8
|
-
const OriginalSource = require("webpack-sources")
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
this.
|
15
|
-
this.
|
16
|
-
this.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
this.
|
38
|
-
this.
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
};
|
1
|
+
/*
|
2
|
+
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
+
Author Tobias Koppers @sokra
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
const Module = require("./Module");
|
8
|
+
const { OriginalSource, RawSource } = require("webpack-sources");
|
9
|
+
|
10
|
+
module.exports = class RawModule extends Module {
|
11
|
+
constructor(source, identifier, readableIdentifier) {
|
12
|
+
super("javascript/dynamic", null);
|
13
|
+
this.sourceStr = source;
|
14
|
+
this.identifierStr = identifier || this.sourceStr;
|
15
|
+
this.readableIdentifierStr = readableIdentifier || this.identifierStr;
|
16
|
+
this.built = false;
|
17
|
+
}
|
18
|
+
|
19
|
+
identifier() {
|
20
|
+
return this.identifierStr;
|
21
|
+
}
|
22
|
+
|
23
|
+
size() {
|
24
|
+
return this.sourceStr.length;
|
25
|
+
}
|
26
|
+
|
27
|
+
readableIdentifier(requestShortener) {
|
28
|
+
return requestShortener.shorten(this.readableIdentifierStr);
|
29
|
+
}
|
30
|
+
|
31
|
+
needRebuild() {
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
|
35
|
+
build(options, compilations, resolver, fs, callback) {
|
36
|
+
this.built = true;
|
37
|
+
this.buildMeta = {};
|
38
|
+
this.buildInfo = {
|
39
|
+
cacheable: true
|
40
|
+
};
|
41
|
+
callback();
|
42
|
+
}
|
43
|
+
|
44
|
+
source() {
|
45
|
+
if (this.useSourceMap)
|
46
|
+
return new OriginalSource(this.sourceStr, this.identifier());
|
47
|
+
else return new RawSource(this.sourceStr);
|
48
|
+
}
|
49
|
+
|
50
|
+
updateHash(hash) {
|
51
|
+
hash.update(this.sourceStr);
|
52
|
+
super.updateHash(hash);
|
53
|
+
}
|
54
|
+
};
|