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