webpack 5.99.6 → 5.99.7

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 (107) hide show
  1. package/lib/AutomaticPrefetchPlugin.js +21 -22
  2. package/lib/BannerPlugin.js +31 -35
  3. package/lib/CleanPlugin.js +5 -3
  4. package/lib/Compilation.js +9 -8
  5. package/lib/Compiler.js +2 -1
  6. package/lib/ContextExclusionPlugin.js +4 -2
  7. package/lib/ContextReplacementPlugin.js +5 -3
  8. package/lib/DelegatedPlugin.js +4 -2
  9. package/lib/DllEntryPlugin.js +4 -2
  10. package/lib/DllPlugin.js +5 -3
  11. package/lib/DllReferencePlugin.js +56 -60
  12. package/lib/DynamicEntryPlugin.js +4 -2
  13. package/lib/EntryOptionPlugin.js +3 -1
  14. package/lib/EntryPlugin.js +4 -2
  15. package/lib/EnvironmentPlugin.js +4 -2
  16. package/lib/EvalDevToolModulePlugin.js +9 -7
  17. package/lib/EvalSourceMapDevToolPlugin.js +137 -138
  18. package/lib/ExternalsPlugin.js +3 -1
  19. package/lib/FlagDependencyExportsPlugin.js +2 -1
  20. package/lib/IgnorePlugin.js +6 -4
  21. package/lib/IgnoreWarningsPlugin.js +4 -2
  22. package/lib/LibManifestPlugin.js +3 -4
  23. package/lib/LoaderOptionsPlugin.js +4 -2
  24. package/lib/LoaderTargetPlugin.js +4 -2
  25. package/lib/Module.js +19 -12
  26. package/lib/ModuleInfoHeaderPlugin.js +11 -12
  27. package/lib/MultiCompiler.js +5 -3
  28. package/lib/NoEmitOnErrorsPlugin.js +5 -3
  29. package/lib/NormalModule.js +5 -1
  30. package/lib/NormalModuleReplacementPlugin.js +33 -36
  31. package/lib/PlatformPlugin.js +3 -1
  32. package/lib/PrefetchPlugin.js +4 -2
  33. package/lib/ProgressPlugin.js +23 -26
  34. package/lib/RecordIdsPlugin.js +72 -102
  35. package/lib/RuntimePlugin.js +34 -32
  36. package/lib/SourceMapDevToolPlugin.js +7 -5
  37. package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
  38. package/lib/WarnNoModeSetPlugin.js +3 -1
  39. package/lib/WatchIgnorePlugin.js +3 -1
  40. package/lib/WebpackError.js +11 -3
  41. package/lib/WebpackOptionsApply.js +5 -3
  42. package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
  43. package/lib/cache/IdleFileCachePlugin.js +11 -12
  44. package/lib/cache/MemoryWithGcCachePlugin.js +7 -5
  45. package/lib/cache/ResolverCachePlugin.js +8 -6
  46. package/lib/cli.js +5 -1
  47. package/lib/config/normalization.js +9 -3
  48. package/lib/container/ContainerReferencePlugin.js +24 -26
  49. package/lib/container/ModuleFederationPlugin.js +2 -1
  50. package/lib/css/CssGenerator.js +1 -1
  51. package/lib/css/CssModulesPlugin.js +6 -4
  52. package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
  53. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
  54. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
  55. package/lib/dependencies/LoaderPlugin.js +5 -3
  56. package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
  57. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
  58. package/lib/esm/ModuleChunkLoadingPlugin.js +72 -73
  59. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  60. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -1
  61. package/lib/hmr/LazyCompilationPlugin.js +17 -18
  62. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
  63. package/lib/ids/DeterministicModuleIdsPlugin.js +47 -48
  64. package/lib/ids/HashedModuleIdsPlugin.js +4 -2
  65. package/lib/ids/NamedChunkIdsPlugin.js +4 -2
  66. package/lib/ids/NamedModuleIdsPlugin.js +4 -2
  67. package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
  68. package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
  69. package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
  70. package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
  71. package/lib/javascript/JavascriptParser.js +634 -656
  72. package/lib/library/ModuleLibraryPlugin.js +60 -42
  73. package/lib/node/CommonJsChunkLoadingPlugin.js +69 -73
  74. package/lib/node/NodeEnvironmentPlugin.js +3 -1
  75. package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
  76. package/lib/optimize/ConcatenatedModule.js +12 -15
  77. package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
  78. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  79. package/lib/optimize/MangleExportsPlugin.js +15 -16
  80. package/lib/optimize/MinChunkSizePlugin.js +4 -2
  81. package/lib/optimize/ModuleConcatenationPlugin.js +4 -2
  82. package/lib/optimize/RealContentHashPlugin.js +4 -2
  83. package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
  84. package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
  85. package/lib/optimize/RuntimeChunkPlugin.js +17 -18
  86. package/lib/optimize/SplitChunksPlugin.js +7 -5
  87. package/lib/performance/SizeLimitsPlugin.js +3 -1
  88. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
  89. package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
  90. package/lib/schemes/DataUriPlugin.js +5 -3
  91. package/lib/schemes/FileUriPlugin.js +5 -3
  92. package/lib/schemes/HttpUriPlugin.js +32 -39
  93. package/lib/serialization/AggregateErrorSerializer.js +42 -0
  94. package/lib/serialization/ErrorObjectSerializer.js +7 -2
  95. package/lib/serialization/ObjectMiddleware.js +13 -0
  96. package/lib/sharing/ProvideSharedPlugin.js +6 -4
  97. package/lib/stats/DefaultStatsFactoryPlugin.js +89 -33
  98. package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
  99. package/lib/stats/DefaultStatsPrinterPlugin.js +306 -341
  100. package/lib/util/concatenate.js +4 -2
  101. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
  102. package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
  103. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
  104. package/package.json +4 -3
  105. package/schemas/WebpackOptions.check.js +1 -1
  106. package/schemas/WebpackOptions.json +24 -2
  107. package/types.d.ts +148 -55
@@ -17,128 +17,122 @@ const getFunctionExpression = require("./getFunctionExpression");
17
17
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
18
18
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
19
19
 
20
+ const PLUGIN_NAME = "RequireEnsureDependenciesBlockParserPlugin";
21
+
20
22
  module.exports = class RequireEnsureDependenciesBlockParserPlugin {
21
23
  /**
22
24
  * @param {JavascriptParser} parser the parser
23
25
  * @returns {void}
24
26
  */
25
27
  apply(parser) {
26
- parser.hooks.call
27
- .for("require.ensure")
28
- .tap("RequireEnsureDependenciesBlockParserPlugin", expr => {
29
- /** @type {string | GroupOptions | null} */
30
- let chunkName = null;
31
- let errorExpressionArg = null;
32
- let errorExpression = null;
33
- switch (expr.arguments.length) {
34
- case 4: {
35
- const chunkNameExpr = parser.evaluateExpression(expr.arguments[3]);
28
+ parser.hooks.call.for("require.ensure").tap(PLUGIN_NAME, expr => {
29
+ /** @type {string | GroupOptions | null} */
30
+ let chunkName = null;
31
+ let errorExpressionArg = null;
32
+ let errorExpression = null;
33
+ switch (expr.arguments.length) {
34
+ case 4: {
35
+ const chunkNameExpr = parser.evaluateExpression(expr.arguments[3]);
36
+ if (!chunkNameExpr.isString()) return;
37
+ chunkName =
38
+ /** @type {string} */
39
+ (chunkNameExpr.string);
40
+ }
41
+ // falls through
42
+ case 3: {
43
+ errorExpressionArg = expr.arguments[2];
44
+ errorExpression = getFunctionExpression(errorExpressionArg);
45
+
46
+ if (!errorExpression && !chunkName) {
47
+ const chunkNameExpr = parser.evaluateExpression(expr.arguments[2]);
36
48
  if (!chunkNameExpr.isString()) return;
37
49
  chunkName =
38
50
  /** @type {string} */
39
51
  (chunkNameExpr.string);
40
52
  }
41
- // falls through
42
- case 3: {
43
- errorExpressionArg = expr.arguments[2];
44
- errorExpression = getFunctionExpression(errorExpressionArg);
53
+ }
54
+ // falls through
55
+ case 2: {
56
+ const dependenciesExpr = parser.evaluateExpression(expr.arguments[0]);
57
+ const dependenciesItems = /** @type {BasicEvaluatedExpression[]} */ (
58
+ dependenciesExpr.isArray()
59
+ ? dependenciesExpr.items
60
+ : [dependenciesExpr]
61
+ );
62
+ const successExpressionArg = expr.arguments[1];
63
+ const successExpression = getFunctionExpression(successExpressionArg);
45
64
 
46
- if (!errorExpression && !chunkName) {
47
- const chunkNameExpr = parser.evaluateExpression(
48
- expr.arguments[2]
49
- );
50
- if (!chunkNameExpr.isString()) return;
51
- chunkName =
52
- /** @type {string} */
53
- (chunkNameExpr.string);
54
- }
65
+ if (successExpression) {
66
+ parser.walkExpressions(successExpression.expressions);
67
+ }
68
+ if (errorExpression) {
69
+ parser.walkExpressions(errorExpression.expressions);
55
70
  }
56
- // falls through
57
- case 2: {
58
- const dependenciesExpr = parser.evaluateExpression(
59
- expr.arguments[0]
60
- );
61
- const dependenciesItems =
62
- /** @type {BasicEvaluatedExpression[]} */ (
63
- dependenciesExpr.isArray()
64
- ? dependenciesExpr.items
65
- : [dependenciesExpr]
66
- );
67
- const successExpressionArg = expr.arguments[1];
68
- const successExpression =
69
- getFunctionExpression(successExpressionArg);
70
-
71
- if (successExpression) {
72
- parser.walkExpressions(successExpression.expressions);
73
- }
74
- if (errorExpression) {
75
- parser.walkExpressions(errorExpression.expressions);
76
- }
77
71
 
78
- const depBlock = new RequireEnsureDependenciesBlock(
79
- chunkName,
80
- /** @type {DependencyLocation} */
81
- (expr.loc)
82
- );
83
- const errorCallbackExists =
84
- expr.arguments.length === 4 ||
85
- (!chunkName && expr.arguments.length === 3);
86
- const dep = new RequireEnsureDependency(
87
- /** @type {Range} */ (expr.range),
88
- /** @type {Range} */ (expr.arguments[1].range),
89
- errorCallbackExists &&
90
- /** @type {Range} */ (expr.arguments[2].range)
91
- );
92
- dep.loc = /** @type {DependencyLocation} */ (expr.loc);
93
- depBlock.addDependency(dep);
94
- const old = parser.state.current;
95
- parser.state.current = /** @type {TODO} */ (depBlock);
96
- try {
97
- let failed = false;
98
- parser.inScope([], () => {
99
- for (const ee of dependenciesItems) {
100
- if (ee.isString()) {
101
- const ensureDependency = new RequireEnsureItemDependency(
102
- /** @type {string} */ (ee.string)
103
- );
104
- ensureDependency.loc =
105
- /** @type {DependencyLocation} */
106
- (expr.loc);
107
- depBlock.addDependency(ensureDependency);
108
- } else {
109
- failed = true;
110
- }
111
- }
112
- });
113
- if (failed) {
114
- return;
115
- }
116
- if (successExpression) {
117
- if (successExpression.fn.body.type === "BlockStatement") {
118
- parser.walkStatement(successExpression.fn.body);
72
+ const depBlock = new RequireEnsureDependenciesBlock(
73
+ chunkName,
74
+ /** @type {DependencyLocation} */
75
+ (expr.loc)
76
+ );
77
+ const errorCallbackExists =
78
+ expr.arguments.length === 4 ||
79
+ (!chunkName && expr.arguments.length === 3);
80
+ const dep = new RequireEnsureDependency(
81
+ /** @type {Range} */ (expr.range),
82
+ /** @type {Range} */ (expr.arguments[1].range),
83
+ errorCallbackExists &&
84
+ /** @type {Range} */ (expr.arguments[2].range)
85
+ );
86
+ dep.loc = /** @type {DependencyLocation} */ (expr.loc);
87
+ depBlock.addDependency(dep);
88
+ const old = parser.state.current;
89
+ parser.state.current = /** @type {TODO} */ (depBlock);
90
+ try {
91
+ let failed = false;
92
+ parser.inScope([], () => {
93
+ for (const ee of dependenciesItems) {
94
+ if (ee.isString()) {
95
+ const ensureDependency = new RequireEnsureItemDependency(
96
+ /** @type {string} */ (ee.string)
97
+ );
98
+ ensureDependency.loc =
99
+ /** @type {DependencyLocation} */
100
+ (expr.loc);
101
+ depBlock.addDependency(ensureDependency);
119
102
  } else {
120
- parser.walkExpression(successExpression.fn.body);
103
+ failed = true;
121
104
  }
122
105
  }
123
- old.addBlock(depBlock);
124
- } finally {
125
- parser.state.current = old;
126
- }
127
- if (!successExpression) {
128
- parser.walkExpression(successExpressionArg);
106
+ });
107
+ if (failed) {
108
+ return;
129
109
  }
130
- if (errorExpression) {
131
- if (errorExpression.fn.body.type === "BlockStatement") {
132
- parser.walkStatement(errorExpression.fn.body);
110
+ if (successExpression) {
111
+ if (successExpression.fn.body.type === "BlockStatement") {
112
+ parser.walkStatement(successExpression.fn.body);
133
113
  } else {
134
- parser.walkExpression(errorExpression.fn.body);
114
+ parser.walkExpression(successExpression.fn.body);
135
115
  }
136
- } else if (errorExpressionArg) {
137
- parser.walkExpression(errorExpressionArg);
138
116
  }
139
- return true;
117
+ old.addBlock(depBlock);
118
+ } finally {
119
+ parser.state.current = old;
120
+ }
121
+ if (!successExpression) {
122
+ parser.walkExpression(successExpressionArg);
123
+ }
124
+ if (errorExpression) {
125
+ if (errorExpression.fn.body.type === "BlockStatement") {
126
+ parser.walkStatement(errorExpression.fn.body);
127
+ } else {
128
+ parser.walkExpression(errorExpression.fn.body);
129
+ }
130
+ } else if (errorExpressionArg) {
131
+ parser.walkExpression(errorExpressionArg);
140
132
  }
133
+ return true;
141
134
  }
142
- });
135
+ }
136
+ });
143
137
  }
144
138
  };
@@ -12,6 +12,8 @@ const ModuleChunkLoadingRuntimeModule = require("./ModuleChunkLoadingRuntimeModu
12
12
  /** @typedef {import("../Chunk")} Chunk */
13
13
  /** @typedef {import("../Compiler")} Compiler */
14
14
 
15
+ const PLUGIN_NAME = "ModuleChunkLoadingPlugin";
16
+
15
17
  class ModuleChunkLoadingPlugin {
16
18
  /**
17
19
  * Apply the plugin
@@ -19,88 +21,85 @@ class ModuleChunkLoadingPlugin {
19
21
  * @returns {void}
20
22
  */
21
23
  apply(compiler) {
22
- compiler.hooks.thisCompilation.tap(
23
- "ModuleChunkLoadingPlugin",
24
- compilation => {
25
- const globalChunkLoading = compilation.outputOptions.chunkLoading;
26
- /**
27
- * @param {Chunk} chunk chunk to check
28
- * @returns {boolean} true, when the plugin is enabled for the chunk
29
- */
30
- const isEnabledForChunk = chunk => {
31
- const options = chunk.getEntryOptions();
32
- const chunkLoading =
33
- options && options.chunkLoading !== undefined
34
- ? options.chunkLoading
35
- : globalChunkLoading;
36
- return chunkLoading === "import";
37
- };
38
- const onceForChunkSet = new WeakSet();
39
- /**
40
- * @param {Chunk} chunk chunk to check
41
- * @param {Set<string>} set runtime requirements
42
- */
43
- const handler = (chunk, set) => {
44
- if (onceForChunkSet.has(chunk)) return;
45
- onceForChunkSet.add(chunk);
24
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
25
+ const globalChunkLoading = compilation.outputOptions.chunkLoading;
26
+ /**
27
+ * @param {Chunk} chunk chunk to check
28
+ * @returns {boolean} true, when the plugin is enabled for the chunk
29
+ */
30
+ const isEnabledForChunk = chunk => {
31
+ const options = chunk.getEntryOptions();
32
+ const chunkLoading =
33
+ options && options.chunkLoading !== undefined
34
+ ? options.chunkLoading
35
+ : globalChunkLoading;
36
+ return chunkLoading === "import";
37
+ };
38
+ const onceForChunkSet = new WeakSet();
39
+ /**
40
+ * @param {Chunk} chunk chunk to check
41
+ * @param {Set<string>} set runtime requirements
42
+ */
43
+ const handler = (chunk, set) => {
44
+ if (onceForChunkSet.has(chunk)) return;
45
+ onceForChunkSet.add(chunk);
46
+ if (!isEnabledForChunk(chunk)) return;
47
+ set.add(RuntimeGlobals.moduleFactoriesAddOnly);
48
+ set.add(RuntimeGlobals.hasOwnProperty);
49
+ compilation.addRuntimeModule(
50
+ chunk,
51
+ new ModuleChunkLoadingRuntimeModule(set)
52
+ );
53
+ };
54
+ compilation.hooks.runtimeRequirementInTree
55
+ .for(RuntimeGlobals.ensureChunkHandlers)
56
+ .tap(PLUGIN_NAME, handler);
57
+ compilation.hooks.runtimeRequirementInTree
58
+ .for(RuntimeGlobals.baseURI)
59
+ .tap(PLUGIN_NAME, handler);
60
+ compilation.hooks.runtimeRequirementInTree
61
+ .for(RuntimeGlobals.externalInstallChunk)
62
+ .tap(PLUGIN_NAME, handler);
63
+ compilation.hooks.runtimeRequirementInTree
64
+ .for(RuntimeGlobals.onChunksLoaded)
65
+ .tap(PLUGIN_NAME, handler);
66
+ compilation.hooks.runtimeRequirementInTree
67
+ .for(RuntimeGlobals.externalInstallChunk)
68
+ .tap(PLUGIN_NAME, (chunk, set) => {
46
69
  if (!isEnabledForChunk(chunk)) return;
47
- set.add(RuntimeGlobals.moduleFactoriesAddOnly);
48
- set.add(RuntimeGlobals.hasOwnProperty);
49
70
  compilation.addRuntimeModule(
50
71
  chunk,
51
- new ModuleChunkLoadingRuntimeModule(set)
72
+ new ExportWebpackRequireRuntimeModule()
52
73
  );
53
- };
54
- compilation.hooks.runtimeRequirementInTree
55
- .for(RuntimeGlobals.ensureChunkHandlers)
56
- .tap("ModuleChunkLoadingPlugin", handler);
57
- compilation.hooks.runtimeRequirementInTree
58
- .for(RuntimeGlobals.baseURI)
59
- .tap("ModuleChunkLoadingPlugin", handler);
60
- compilation.hooks.runtimeRequirementInTree
61
- .for(RuntimeGlobals.externalInstallChunk)
62
- .tap("ModuleChunkLoadingPlugin", handler);
63
- compilation.hooks.runtimeRequirementInTree
64
- .for(RuntimeGlobals.onChunksLoaded)
65
- .tap("ModuleChunkLoadingPlugin", handler);
66
- compilation.hooks.runtimeRequirementInTree
67
- .for(RuntimeGlobals.externalInstallChunk)
68
- .tap("ModuleChunkLoadingPlugin", (chunk, set) => {
69
- if (!isEnabledForChunk(chunk)) return;
70
- compilation.addRuntimeModule(
71
- chunk,
72
- new ExportWebpackRequireRuntimeModule()
73
- );
74
- });
74
+ });
75
75
 
76
- // We need public path only when we prefetch/preload chunk or public path is not `auto`
77
- compilation.hooks.runtimeRequirementInTree
78
- .for(RuntimeGlobals.prefetchChunkHandlers)
79
- .tap("ModuleChunkLoadingPlugin", (chunk, set) => {
80
- if (!isEnabledForChunk(chunk)) return;
81
- set.add(RuntimeGlobals.publicPath);
82
- });
76
+ // We need public path only when we prefetch/preload chunk or public path is not `auto`
77
+ compilation.hooks.runtimeRequirementInTree
78
+ .for(RuntimeGlobals.prefetchChunkHandlers)
79
+ .tap(PLUGIN_NAME, (chunk, set) => {
80
+ if (!isEnabledForChunk(chunk)) return;
81
+ set.add(RuntimeGlobals.publicPath);
82
+ });
83
83
 
84
- compilation.hooks.runtimeRequirementInTree
85
- .for(RuntimeGlobals.preloadChunkHandlers)
86
- .tap("ModuleChunkLoadingPlugin", (chunk, set) => {
87
- if (!isEnabledForChunk(chunk)) return;
88
- set.add(RuntimeGlobals.publicPath);
89
- });
84
+ compilation.hooks.runtimeRequirementInTree
85
+ .for(RuntimeGlobals.preloadChunkHandlers)
86
+ .tap(PLUGIN_NAME, (chunk, set) => {
87
+ if (!isEnabledForChunk(chunk)) return;
88
+ set.add(RuntimeGlobals.publicPath);
89
+ });
90
90
 
91
- compilation.hooks.runtimeRequirementInTree
92
- .for(RuntimeGlobals.ensureChunkHandlers)
93
- .tap("ModuleChunkLoadingPlugin", (chunk, set) => {
94
- if (!isEnabledForChunk(chunk)) return;
91
+ compilation.hooks.runtimeRequirementInTree
92
+ .for(RuntimeGlobals.ensureChunkHandlers)
93
+ .tap(PLUGIN_NAME, (chunk, set) => {
94
+ if (!isEnabledForChunk(chunk)) return;
95
95
 
96
- if (compilation.outputOptions.publicPath !== "auto") {
97
- set.add(RuntimeGlobals.publicPath);
98
- }
96
+ if (compilation.outputOptions.publicPath !== "auto") {
97
+ set.add(RuntimeGlobals.publicPath);
98
+ }
99
99
 
100
- set.add(RuntimeGlobals.getChunkScriptFilename);
101
- });
102
- }
103
- );
100
+ set.add(RuntimeGlobals.getChunkScriptFilename);
101
+ });
102
+ });
104
103
  }
105
104
  }
106
105
 
@@ -69,7 +69,6 @@ module.exports = function () {
69
69
  me.children.push(request);
70
70
  }
71
71
  } else {
72
- // eslint-disable-next-line no-console
73
72
  console.warn(
74
73
  "[HMR] unexpected require(" +
75
74
  request +
@@ -109,7 +109,6 @@ module.exports = function () {
109
109
  var appliedUpdate = {};
110
110
 
111
111
  var warnUnexpectedRequire = function warnUnexpectedRequire(module) {
112
- // eslint-disable-next-line no-console
113
112
  console.warn(
114
113
  "[HMR] unexpected require(" + module.id + ") to disposed module"
115
114
  );
@@ -353,6 +353,8 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
353
353
  * @property {(RegExp | string | ((module: Module) => boolean))=} test additional filter for lazy compiled entrypoint modules
354
354
  */
355
355
 
356
+ const PLUGIN_NAME = "LazyCompilationPlugin";
357
+
356
358
  class LazyCompilationPlugin {
357
359
  /**
358
360
  * @param {Options} options options
@@ -372,28 +374,25 @@ class LazyCompilationPlugin {
372
374
  apply(compiler) {
373
375
  /** @type {BackendApi} */
374
376
  let backend;
375
- compiler.hooks.beforeCompile.tapAsync(
376
- "LazyCompilationPlugin",
377
- (params, callback) => {
378
- if (backend !== undefined) return callback();
379
- const promise = this.backend(compiler, (err, result) => {
380
- if (err) return callback(err);
381
- backend = /** @type {BackendApi} */ (result);
377
+ compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, (params, callback) => {
378
+ if (backend !== undefined) return callback();
379
+ const promise = this.backend(compiler, (err, result) => {
380
+ if (err) return callback(err);
381
+ backend = /** @type {BackendApi} */ (result);
382
+ callback();
383
+ });
384
+ if (promise && promise.then) {
385
+ promise.then(b => {
386
+ backend = b;
382
387
  callback();
383
- });
384
- if (promise && promise.then) {
385
- promise.then(b => {
386
- backend = b;
387
- callback();
388
- }, callback);
389
- }
388
+ }, callback);
390
389
  }
391
- );
390
+ });
392
391
  compiler.hooks.thisCompilation.tap(
393
- "LazyCompilationPlugin",
392
+ PLUGIN_NAME,
394
393
  (compilation, { normalModuleFactory }) => {
395
394
  normalModuleFactory.hooks.module.tap(
396
- "LazyCompilationPlugin",
395
+ PLUGIN_NAME,
397
396
  (module, createData, resolveData) => {
398
397
  if (
399
398
  resolveData.dependencies.every(dep =>
@@ -454,7 +453,7 @@ class LazyCompilationPlugin {
454
453
  );
455
454
  }
456
455
  );
457
- compiler.hooks.shutdown.tapAsync("LazyCompilationPlugin", callback => {
456
+ compiler.hooks.shutdown.tapAsync(PLUGIN_NAME, callback => {
458
457
  backend.dispose(callback);
459
458
  });
460
459
  }
@@ -21,6 +21,8 @@ const {
21
21
  * @property {number=} end end id
22
22
  */
23
23
 
24
+ const PLUGIN_NAME = "ChunkModuleIdRangePlugin";
25
+
24
26
  class ChunkModuleIdRangePlugin {
25
27
  /**
26
28
  * @param {ChunkModuleIdRangePluginOptions} options options object
@@ -36,9 +38,9 @@ class ChunkModuleIdRangePlugin {
36
38
  */
37
39
  apply(compiler) {
38
40
  const options = this.options;
39
- compiler.hooks.compilation.tap("ChunkModuleIdRangePlugin", compilation => {
41
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
40
42
  const moduleGraph = compilation.moduleGraph;
41
- compilation.hooks.moduleIds.tap("ChunkModuleIdRangePlugin", modules => {
43
+ compilation.hooks.moduleIds.tap(PLUGIN_NAME, modules => {
42
44
  const chunkGraph = compilation.chunkGraph;
43
45
  const chunk = find(
44
46
  compilation.chunks,
@@ -46,7 +48,7 @@ class ChunkModuleIdRangePlugin {
46
48
  );
47
49
  if (!chunk) {
48
50
  throw new Error(
49
- `ChunkModuleIdRangePlugin: Chunk with name '${options.name}"' was not found`
51
+ `${PLUGIN_NAME}: Chunk with name '${options.name}"' was not found`
50
52
  );
51
53
  }
52
54
 
@@ -63,9 +65,7 @@ class ChunkModuleIdRangePlugin {
63
65
  cmpFn = compareModulesByPostOrderIndexOrIdentifier(moduleGraph);
64
66
  break;
65
67
  default:
66
- throw new Error(
67
- "ChunkModuleIdRangePlugin: unexpected value of order"
68
- );
68
+ throw new Error(`${PLUGIN_NAME}: unexpected value of order`);
69
69
  }
70
70
  chunkModules = chunkGraph.getOrderedChunkModules(chunk, cmpFn);
71
71
  } else {
@@ -27,6 +27,8 @@ const {
27
27
  * @property {boolean=} failOnConflict throw an error when id conflicts occur (instead of rehashing)
28
28
  */
29
29
 
30
+ const PLUGIN_NAME = "DeterministicModuleIdsPlugin";
31
+
30
32
  class DeterministicModuleIdsPlugin {
31
33
  /**
32
34
  * @param {DeterministicModuleIdsPluginOptions=} options options
@@ -41,56 +43,53 @@ class DeterministicModuleIdsPlugin {
41
43
  * @returns {void}
42
44
  */
43
45
  apply(compiler) {
44
- compiler.hooks.compilation.tap(
45
- "DeterministicModuleIdsPlugin",
46
- compilation => {
47
- compilation.hooks.moduleIds.tap("DeterministicModuleIdsPlugin", () => {
48
- const chunkGraph = compilation.chunkGraph;
49
- const context = this.options.context
50
- ? this.options.context
51
- : compiler.context;
52
- const maxLength = this.options.maxLength || 3;
53
- const failOnConflict = this.options.failOnConflict || false;
54
- const fixedLength = this.options.fixedLength || false;
55
- const salt = this.options.salt || 0;
56
- let conflicts = 0;
46
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
47
+ compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
48
+ const chunkGraph = compilation.chunkGraph;
49
+ const context = this.options.context
50
+ ? this.options.context
51
+ : compiler.context;
52
+ const maxLength = this.options.maxLength || 3;
53
+ const failOnConflict = this.options.failOnConflict || false;
54
+ const fixedLength = this.options.fixedLength || false;
55
+ const salt = this.options.salt || 0;
56
+ let conflicts = 0;
57
57
 
58
- const [usedIds, modules] = getUsedModuleIdsAndModules(
59
- compilation,
60
- this.options.test
61
- );
62
- assignDeterministicIds(
63
- modules,
64
- module => getFullModuleName(module, context, compiler.root),
65
- failOnConflict
66
- ? () => 0
67
- : compareModulesByPreOrderIndexOrIdentifier(
68
- compilation.moduleGraph
69
- ),
70
- (module, id) => {
71
- const size = usedIds.size;
72
- usedIds.add(`${id}`);
73
- if (size === usedIds.size) {
74
- conflicts++;
75
- return false;
76
- }
77
- chunkGraph.setModuleId(module, id);
78
- return true;
79
- },
80
- [10 ** maxLength],
81
- fixedLength ? 0 : 10,
82
- usedIds.size,
83
- salt
58
+ const [usedIds, modules] = getUsedModuleIdsAndModules(
59
+ compilation,
60
+ this.options.test
61
+ );
62
+ assignDeterministicIds(
63
+ modules,
64
+ module => getFullModuleName(module, context, compiler.root),
65
+ failOnConflict
66
+ ? () => 0
67
+ : compareModulesByPreOrderIndexOrIdentifier(
68
+ compilation.moduleGraph
69
+ ),
70
+ (module, id) => {
71
+ const size = usedIds.size;
72
+ usedIds.add(`${id}`);
73
+ if (size === usedIds.size) {
74
+ conflicts++;
75
+ return false;
76
+ }
77
+ chunkGraph.setModuleId(module, id);
78
+ return true;
79
+ },
80
+ [10 ** maxLength],
81
+ fixedLength ? 0 : 10,
82
+ usedIds.size,
83
+ salt
84
+ );
85
+ if (failOnConflict && conflicts)
86
+ throw new Error(
87
+ `Assigning deterministic module ids has lead to ${conflicts} conflict${
88
+ conflicts > 1 ? "s" : ""
89
+ }.\nIncrease the 'maxLength' to increase the id space and make conflicts less likely (recommended when there are many conflicts or application is expected to grow), or add an 'salt' number to try another hash starting value in the same id space (recommended when there is only a single conflict).`
84
90
  );
85
- if (failOnConflict && conflicts)
86
- throw new Error(
87
- `Assigning deterministic module ids has lead to ${conflicts} conflict${
88
- conflicts > 1 ? "s" : ""
89
- }.\nIncrease the 'maxLength' to increase the id space and make conflicts less likely (recommended when there are many conflicts or application is expected to grow), or add an 'salt' number to try another hash starting value in the same id space (recommended when there is only a single conflict).`
90
- );
91
- });
92
- }
93
- );
91
+ });
92
+ });
94
93
  }
95
94
  }
96
95
 
@@ -28,6 +28,8 @@ const validate = createSchemaValidation(
28
28
  }
29
29
  );
30
30
 
31
+ const PLUGIN_NAME = "HashedModuleIdsPlugin";
32
+
31
33
  class HashedModuleIdsPlugin {
32
34
  /**
33
35
  * @param {HashedModuleIdsPluginOptions=} options options object
@@ -52,8 +54,8 @@ class HashedModuleIdsPlugin {
52
54
  */
53
55
  apply(compiler) {
54
56
  const options = this.options;
55
- compiler.hooks.compilation.tap("HashedModuleIdsPlugin", compilation => {
56
- compilation.hooks.moduleIds.tap("HashedModuleIdsPlugin", () => {
57
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
58
+ compilation.hooks.moduleIds.tap(PLUGIN_NAME, () => {
57
59
  const chunkGraph = compilation.chunkGraph;
58
60
  const context = this.options.context
59
61
  ? this.options.context
@@ -25,6 +25,8 @@ const {
25
25
  * @property {string=} delimiter delimiter
26
26
  */
27
27
 
28
+ const PLUGIN_NAME = "NamedChunkIdsPlugin";
29
+
28
30
  class NamedChunkIdsPlugin {
29
31
  /**
30
32
  * @param {NamedChunkIdsPluginOptions=} options options
@@ -40,11 +42,11 @@ class NamedChunkIdsPlugin {
40
42
  * @returns {void}
41
43
  */
42
44
  apply(compiler) {
43
- compiler.hooks.compilation.tap("NamedChunkIdsPlugin", compilation => {
45
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
44
46
  const hashFunction =
45
47
  /** @type {NonNullable<Output["hashFunction"]>} */
46
48
  (compilation.outputOptions.hashFunction);
47
- compilation.hooks.chunkIds.tap("NamedChunkIdsPlugin", chunks => {
49
+ compilation.hooks.chunkIds.tap(PLUGIN_NAME, chunks => {
48
50
  const chunkGraph = compilation.chunkGraph;
49
51
  const context = this.context ? this.context : compiler.context;
50
52
  const delimiter = this.delimiter;