webpack 5.99.5 → 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 (169) hide show
  1. package/README.md +1 -1
  2. package/lib/APIPlugin.js +2 -2
  3. package/lib/AutomaticPrefetchPlugin.js +21 -22
  4. package/lib/BannerPlugin.js +31 -35
  5. package/lib/Cache.js +1 -1
  6. package/lib/Chunk.js +12 -9
  7. package/lib/CleanPlugin.js +5 -3
  8. package/lib/Compilation.js +45 -35
  9. package/lib/Compiler.js +6 -4
  10. package/lib/ContextExclusionPlugin.js +4 -2
  11. package/lib/ContextModule.js +2 -1
  12. package/lib/ContextReplacementPlugin.js +5 -3
  13. package/lib/DelegatedPlugin.js +4 -2
  14. package/lib/DllEntryPlugin.js +4 -2
  15. package/lib/DllPlugin.js +5 -3
  16. package/lib/DllReferencePlugin.js +56 -60
  17. package/lib/DynamicEntryPlugin.js +4 -2
  18. package/lib/EntryOptionPlugin.js +3 -1
  19. package/lib/EntryPlugin.js +4 -2
  20. package/lib/EnvironmentPlugin.js +4 -2
  21. package/lib/EvalDevToolModulePlugin.js +9 -7
  22. package/lib/EvalSourceMapDevToolPlugin.js +137 -138
  23. package/lib/ExternalsPlugin.js +3 -1
  24. package/lib/FlagDependencyExportsPlugin.js +2 -1
  25. package/lib/HotModuleReplacementPlugin.js +3 -3
  26. package/lib/IgnorePlugin.js +6 -4
  27. package/lib/IgnoreWarningsPlugin.js +4 -2
  28. package/lib/LibManifestPlugin.js +3 -4
  29. package/lib/LoaderOptionsPlugin.js +4 -2
  30. package/lib/LoaderTargetPlugin.js +4 -2
  31. package/lib/Module.js +29 -14
  32. package/lib/ModuleFilenameHelpers.js +1 -1
  33. package/lib/ModuleGraph.js +15 -10
  34. package/lib/ModuleInfoHeaderPlugin.js +11 -12
  35. package/lib/MultiCompiler.js +5 -3
  36. package/lib/NoEmitOnErrorsPlugin.js +5 -3
  37. package/lib/NormalModule.js +6 -2
  38. package/lib/NormalModuleReplacementPlugin.js +33 -36
  39. package/lib/PlatformPlugin.js +3 -1
  40. package/lib/PrefetchPlugin.js +5 -3
  41. package/lib/ProgressPlugin.js +23 -26
  42. package/lib/RecordIdsPlugin.js +73 -103
  43. package/lib/RuntimePlugin.js +34 -32
  44. package/lib/SourceMapDevToolPlugin.js +8 -6
  45. package/lib/Template.js +1 -1
  46. package/lib/WarnCaseSensitiveModulesPlugin.js +36 -37
  47. package/lib/WarnNoModeSetPlugin.js +3 -1
  48. package/lib/WatchIgnorePlugin.js +3 -1
  49. package/lib/WebpackError.js +11 -3
  50. package/lib/WebpackOptionsApply.js +22 -5
  51. package/lib/async-modules/InferAsyncModulesPlugin.js +25 -26
  52. package/lib/buildChunkGraph.js +7 -2
  53. package/lib/cache/IdleFileCachePlugin.js +12 -13
  54. package/lib/cache/MemoryCachePlugin.js +2 -1
  55. package/lib/cache/MemoryWithGcCachePlugin.js +10 -7
  56. package/lib/cache/PackFileCacheStrategy.js +13 -21
  57. package/lib/cache/ResolverCachePlugin.js +22 -22
  58. package/lib/cli.js +8 -4
  59. package/lib/config/defaults.js +2 -2
  60. package/lib/config/normalization.js +9 -3
  61. package/lib/config/target.js +6 -6
  62. package/lib/container/ContainerReferencePlugin.js +24 -26
  63. package/lib/container/ModuleFederationPlugin.js +2 -1
  64. package/lib/css/CssGenerator.js +1 -1
  65. package/lib/css/CssModulesPlugin.js +6 -4
  66. package/lib/css/CssParser.js +1 -1
  67. package/lib/debug/ProfilingPlugin.js +1 -1
  68. package/lib/dependencies/ContextDependencyHelpers.js +1 -1
  69. package/lib/dependencies/CssIcssImportDependency.js +3 -2
  70. package/lib/dependencies/HarmonyDetectionParserPlugin.js +9 -15
  71. package/lib/dependencies/HarmonyExportExpressionDependency.js +1 -1
  72. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +2 -1
  73. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +1 -1
  74. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +15 -15
  75. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +4 -2
  76. package/lib/dependencies/JsonExportsDependency.js +1 -1
  77. package/lib/dependencies/LoaderPlugin.js +5 -3
  78. package/lib/dependencies/LocalModulesHelpers.js +1 -1
  79. package/lib/dependencies/RequireContextDependencyParserPlugin.js +46 -46
  80. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +94 -100
  81. package/lib/dependencies/RequireResolveDependency.js +1 -1
  82. package/lib/dependencies/WorkerPlugin.js +2 -2
  83. package/lib/esm/ModuleChunkLoadingPlugin.js +76 -57
  84. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +11 -9
  85. package/lib/hmr/HotModuleReplacement.runtime.js +0 -1
  86. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +0 -1
  87. package/lib/hmr/LazyCompilationPlugin.js +17 -18
  88. package/lib/ids/ChunkModuleIdRangePlugin.js +6 -6
  89. package/lib/ids/DeterministicChunkIdsPlugin.js +1 -1
  90. package/lib/ids/DeterministicModuleIdsPlugin.js +48 -49
  91. package/lib/ids/HashedModuleIdsPlugin.js +4 -2
  92. package/lib/ids/NamedChunkIdsPlugin.js +6 -4
  93. package/lib/ids/NamedModuleIdsPlugin.js +6 -4
  94. package/lib/ids/NaturalChunkIdsPlugin.js +4 -2
  95. package/lib/ids/NaturalModuleIdsPlugin.js +4 -2
  96. package/lib/ids/OccurrenceChunkIdsPlugin.js +4 -2
  97. package/lib/ids/OccurrenceModuleIdsPlugin.js +4 -2
  98. package/lib/index.js +1 -1
  99. package/lib/javascript/BasicEvaluatedExpression.js +2 -2
  100. package/lib/javascript/JavascriptParser.js +670 -688
  101. package/lib/library/EnableLibraryPlugin.js +15 -2
  102. package/lib/library/ModuleLibraryPlugin.js +66 -43
  103. package/lib/logging/createConsoleLogger.js +0 -1
  104. package/lib/node/CommonJsChunkLoadingPlugin.js +71 -75
  105. package/lib/node/NodeEnvironmentPlugin.js +3 -1
  106. package/lib/node/NodeTemplatePlugin.js +2 -2
  107. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -2
  108. package/lib/node/ReadFileCompileWasmPlugin.js +3 -3
  109. package/lib/optimize/AggressiveMergingPlugin.js +1 -1
  110. package/lib/optimize/AggressiveSplittingPlugin.js +224 -232
  111. package/lib/optimize/ConcatenatedModule.js +12 -15
  112. package/lib/optimize/FlagIncludedChunksPlugin.js +92 -97
  113. package/lib/optimize/LimitChunkCountPlugin.js +4 -2
  114. package/lib/optimize/MangleExportsPlugin.js +15 -16
  115. package/lib/optimize/MinChunkSizePlugin.js +4 -2
  116. package/lib/optimize/ModuleConcatenationPlugin.js +4 -2
  117. package/lib/optimize/RealContentHashPlugin.js +4 -2
  118. package/lib/optimize/RemoveEmptyChunksPlugin.js +5 -3
  119. package/lib/optimize/RemoveParentModulesPlugin.js +4 -2
  120. package/lib/optimize/RuntimeChunkPlugin.js +17 -18
  121. package/lib/optimize/SplitChunksPlugin.js +9 -6
  122. package/lib/performance/SizeLimitsPlugin.js +3 -1
  123. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +61 -62
  124. package/lib/runtime/GetChunkFilenameRuntimeModule.js +3 -4
  125. package/lib/runtime/StartupChunkDependenciesPlugin.js +39 -42
  126. package/lib/schemes/DataUriPlugin.js +5 -3
  127. package/lib/schemes/FileUriPlugin.js +5 -3
  128. package/lib/schemes/HttpUriPlugin.js +32 -39
  129. package/lib/serialization/AggregateErrorSerializer.js +42 -0
  130. package/lib/serialization/BinaryMiddleware.js +22 -38
  131. package/lib/serialization/ErrorObjectSerializer.js +7 -2
  132. package/lib/serialization/FileMiddleware.js +29 -33
  133. package/lib/serialization/ObjectMiddleware.js +42 -30
  134. package/lib/serialization/Serializer.js +29 -18
  135. package/lib/serialization/SerializerMiddleware.js +105 -72
  136. package/lib/serialization/SingleItemMiddleware.js +4 -5
  137. package/lib/sharing/ProvideSharedPlugin.js +6 -4
  138. package/lib/stats/DefaultStatsFactoryPlugin.js +128 -57
  139. package/lib/stats/DefaultStatsPresetPlugin.js +25 -20
  140. package/lib/stats/DefaultStatsPrinterPlugin.js +486 -334
  141. package/lib/stats/StatsFactory.js +47 -10
  142. package/lib/stats/StatsPrinter.js +52 -31
  143. package/lib/util/ArrayQueue.js +1 -1
  144. package/lib/util/AsyncQueue.js +1 -1
  145. package/lib/util/TupleQueue.js +9 -7
  146. package/lib/util/TupleSet.js +37 -18
  147. package/lib/util/WeakTupleMap.js +50 -37
  148. package/lib/util/cleverMerge.js +2 -2
  149. package/lib/util/comparators.js +1 -1
  150. package/lib/util/concatenate.js +4 -2
  151. package/lib/util/createHash.js +1 -1
  152. package/lib/util/fs.js +1 -1
  153. package/lib/util/makeSerializable.js +1 -1
  154. package/lib/util/runtime.js +1 -0
  155. package/lib/util/serialization.js +50 -42
  156. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +1 -1
  157. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -1
  158. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +2 -2
  159. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +55 -57
  160. package/lib/wasm-sync/WebAssemblyGenerator.js +1 -1
  161. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +1 -1
  162. package/lib/web/FetchCompileWasmPlugin.js +2 -2
  163. package/lib/web/JsonpChunkLoadingPlugin.js +73 -74
  164. package/lib/webpack.js +1 -1
  165. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +77 -78
  166. package/package.json +4 -3
  167. package/schemas/WebpackOptions.check.js +1 -1
  168. package/schemas/WebpackOptions.json +24 -2
  169. package/types.d.ts +273 -128
@@ -14,6 +14,8 @@ const { join } = require("./util/fs");
14
14
 
15
15
  /** @typedef {Record<string, string>} NewContentCreateContextMap */
16
16
 
17
+ const PLUGIN_NAME = "ContextReplacementPlugin";
18
+
17
19
  class ContextReplacementPlugin {
18
20
  /**
19
21
  * @param {RegExp} resourceRegExp A regular expression that determines which files will be selected
@@ -95,8 +97,8 @@ class ContextReplacementPlugin {
95
97
  const newContentRegExp = this.newContentRegExp;
96
98
  const newContentCreateContextMap = this.newContentCreateContextMap;
97
99
 
98
- compiler.hooks.contextModuleFactory.tap("ContextReplacementPlugin", cmf => {
99
- cmf.hooks.beforeResolve.tap("ContextReplacementPlugin", result => {
100
+ compiler.hooks.contextModuleFactory.tap(PLUGIN_NAME, cmf => {
101
+ cmf.hooks.beforeResolve.tap(PLUGIN_NAME, result => {
100
102
  if (!result) return;
101
103
  if (resourceRegExp.test(result.request)) {
102
104
  if (newContentResource !== undefined) {
@@ -118,7 +120,7 @@ class ContextReplacementPlugin {
118
120
  }
119
121
  return result;
120
122
  });
121
- cmf.hooks.afterResolve.tap("ContextReplacementPlugin", result => {
123
+ cmf.hooks.afterResolve.tap(PLUGIN_NAME, result => {
122
124
  if (!result) return;
123
125
  if (resourceRegExp.test(result.resource)) {
124
126
  if (newContentResource !== undefined) {
@@ -11,6 +11,8 @@ const DelegatedSourceDependency = require("./dependencies/DelegatedSourceDepende
11
11
  /** @typedef {import("./Compiler")} Compiler */
12
12
  /** @typedef {import("./DelegatedModuleFactoryPlugin").Options} Options */
13
13
 
14
+ const PLUGIN_NAME = "DelegatedPlugin";
15
+
14
16
  class DelegatedPlugin {
15
17
  /**
16
18
  * @param {Options} options options
@@ -26,7 +28,7 @@ class DelegatedPlugin {
26
28
  */
27
29
  apply(compiler) {
28
30
  compiler.hooks.compilation.tap(
29
- "DelegatedPlugin",
31
+ PLUGIN_NAME,
30
32
  (compilation, { normalModuleFactory }) => {
31
33
  compilation.dependencyFactories.set(
32
34
  DelegatedSourceDependency,
@@ -35,7 +37,7 @@ class DelegatedPlugin {
35
37
  }
36
38
  );
37
39
 
38
- compiler.hooks.compile.tap("DelegatedPlugin", ({ normalModuleFactory }) => {
40
+ compiler.hooks.compile.tap(PLUGIN_NAME, ({ normalModuleFactory }) => {
39
41
  new DelegatedModuleFactoryPlugin({
40
42
  associatedObjectForCache: compiler.root,
41
43
  ...this.options
@@ -13,6 +13,8 @@ const EntryDependency = require("./dependencies/EntryDependency");
13
13
  /** @typedef {string[]} Entries */
14
14
  /** @typedef {{ name: string, filename: TODO }} Options */
15
15
 
16
+ const PLUGIN_NAME = "DllEntryPlugin";
17
+
16
18
  class DllEntryPlugin {
17
19
  /**
18
20
  * @param {string} context context
@@ -32,7 +34,7 @@ class DllEntryPlugin {
32
34
  */
33
35
  apply(compiler) {
34
36
  compiler.hooks.compilation.tap(
35
- "DllEntryPlugin",
37
+ PLUGIN_NAME,
36
38
  (compilation, { normalModuleFactory }) => {
37
39
  const dllModuleFactory = new DllModuleFactory();
38
40
  compilation.dependencyFactories.set(
@@ -45,7 +47,7 @@ class DllEntryPlugin {
45
47
  );
46
48
  }
47
49
  );
48
- compiler.hooks.make.tapAsync("DllEntryPlugin", (compilation, callback) => {
50
+ compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
49
51
  compilation.addEntry(
50
52
  this.context,
51
53
  new DllEntryDependency(
package/lib/DllPlugin.js CHANGED
@@ -24,6 +24,8 @@ const validate = createSchemaValidation(
24
24
  }
25
25
  );
26
26
 
27
+ const PLUGIN_NAME = "DllPlugin";
28
+
27
29
  class DllPlugin {
28
30
  /**
29
31
  * @param {DllPluginOptions} options options object
@@ -42,7 +44,7 @@ class DllPlugin {
42
44
  * @returns {void}
43
45
  */
44
46
  apply(compiler) {
45
- compiler.hooks.entryOption.tap("DllPlugin", (context, entry) => {
47
+ compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
46
48
  if (typeof entry !== "function") {
47
49
  for (const name of Object.keys(entry)) {
48
50
  /** @type {Options} */
@@ -55,14 +57,14 @@ class DllPlugin {
55
57
  }
56
58
  } else {
57
59
  throw new Error(
58
- "DllPlugin doesn't support dynamic entry (function) yet"
60
+ `${PLUGIN_NAME} doesn't support dynamic entry (function) yet`
59
61
  );
60
62
  }
61
63
  return true;
62
64
  });
63
65
  new LibManifestPlugin(this.options).apply(compiler);
64
66
  if (!this.options.entryOnly) {
65
- new FlagAllModulesAsUsedPlugin("DllPlugin").apply(compiler);
67
+ new FlagAllModulesAsUsedPlugin(PLUGIN_NAME).apply(compiler);
66
68
  }
67
69
  }
68
70
  }
@@ -32,6 +32,8 @@ const validate = createSchemaValidation(
32
32
 
33
33
  /** @typedef {{ path: string, data: DllReferencePluginOptionsManifest | undefined, error: Error | undefined }} CompilationDataItem */
34
34
 
35
+ const PLUGIN_NAME = "DllReferencePlugin";
36
+
35
37
  class DllReferencePlugin {
36
38
  /**
37
39
  * @param {DllReferencePluginOptions} options options object
@@ -50,7 +52,7 @@ class DllReferencePlugin {
50
52
  */
51
53
  apply(compiler) {
52
54
  compiler.hooks.compilation.tap(
53
- "DllReferencePlugin",
55
+ PLUGIN_NAME,
54
56
  (compilation, { normalModuleFactory }) => {
55
57
  compilation.dependencyFactories.set(
56
58
  DelegatedSourceDependency,
@@ -59,51 +61,48 @@ class DllReferencePlugin {
59
61
  }
60
62
  );
61
63
 
62
- compiler.hooks.beforeCompile.tapAsync(
63
- "DllReferencePlugin",
64
- (params, callback) => {
65
- if ("manifest" in this.options) {
66
- const manifest = this.options.manifest;
67
- if (typeof manifest === "string") {
68
- /** @type {InputFileSystem} */
69
- (compiler.inputFileSystem).readFile(manifest, (err, result) => {
70
- if (err) return callback(err);
71
- /** @type {CompilationDataItem} */
72
- const data = {
73
- path: manifest,
74
- data: undefined,
75
- error: undefined
76
- };
77
- // Catch errors parsing the manifest so that blank
78
- // or malformed manifest files don't kill the process.
79
- try {
80
- data.data = parseJson(
81
- /** @type {Buffer} */ (result).toString("utf-8")
82
- );
83
- } catch (parseErr) {
84
- // Store the error in the params so that it can
85
- // be added as a compilation error later on.
86
- const manifestPath = makePathsRelative(
87
- /** @type {string} */ (compiler.options.context),
88
- manifest,
89
- compiler.root
90
- );
91
- data.error = new DllManifestError(
92
- manifestPath,
93
- /** @type {Error} */ (parseErr).message
94
- );
95
- }
96
- this._compilationData.set(params, data);
97
- return callback();
98
- });
99
- return;
100
- }
64
+ compiler.hooks.beforeCompile.tapAsync(PLUGIN_NAME, (params, callback) => {
65
+ if ("manifest" in this.options) {
66
+ const manifest = this.options.manifest;
67
+ if (typeof manifest === "string") {
68
+ /** @type {InputFileSystem} */
69
+ (compiler.inputFileSystem).readFile(manifest, (err, result) => {
70
+ if (err) return callback(err);
71
+ /** @type {CompilationDataItem} */
72
+ const data = {
73
+ path: manifest,
74
+ data: undefined,
75
+ error: undefined
76
+ };
77
+ // Catch errors parsing the manifest so that blank
78
+ // or malformed manifest files don't kill the process.
79
+ try {
80
+ data.data = parseJson(
81
+ /** @type {Buffer} */ (result).toString("utf-8")
82
+ );
83
+ } catch (parseErr) {
84
+ // Store the error in the params so that it can
85
+ // be added as a compilation error later on.
86
+ const manifestPath = makePathsRelative(
87
+ /** @type {string} */ (compiler.options.context),
88
+ manifest,
89
+ compiler.root
90
+ );
91
+ data.error = new DllManifestError(
92
+ manifestPath,
93
+ /** @type {Error} */ (parseErr).message
94
+ );
95
+ }
96
+ this._compilationData.set(params, data);
97
+ return callback();
98
+ });
99
+ return;
101
100
  }
102
- return callback();
103
101
  }
104
- );
102
+ return callback();
103
+ });
105
104
 
106
- compiler.hooks.compile.tap("DllReferencePlugin", params => {
105
+ compiler.hooks.compile.tap(PLUGIN_NAME, params => {
107
106
  let name = this.options.name;
108
107
  let sourceType = this.options.sourceType;
109
108
  let resolvedContent =
@@ -154,27 +153,24 @@ class DllReferencePlugin {
154
153
  }).apply(normalModuleFactory);
155
154
  });
156
155
 
157
- compiler.hooks.compilation.tap(
158
- "DllReferencePlugin",
159
- (compilation, params) => {
160
- if ("manifest" in this.options) {
161
- const manifest = this.options.manifest;
162
- if (typeof manifest === "string") {
163
- const data = /** @type {CompilationDataItem} */ (
164
- this._compilationData.get(params)
156
+ compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation, params) => {
157
+ if ("manifest" in this.options) {
158
+ const manifest = this.options.manifest;
159
+ if (typeof manifest === "string") {
160
+ const data = /** @type {CompilationDataItem} */ (
161
+ this._compilationData.get(params)
162
+ );
163
+ // If there was an error parsing the manifest file, add the
164
+ // error as a compilation error to make the compilation fail.
165
+ if (data.error) {
166
+ compilation.errors.push(
167
+ /** @type {DllManifestError} */ (data.error)
165
168
  );
166
- // If there was an error parsing the manifest file, add the
167
- // error as a compilation error to make the compilation fail.
168
- if (data.error) {
169
- compilation.errors.push(
170
- /** @type {DllManifestError} */ (data.error)
171
- );
172
- }
173
- compilation.fileDependencies.add(manifest);
174
169
  }
170
+ compilation.fileDependencies.add(manifest);
175
171
  }
176
172
  }
177
- );
173
+ });
178
174
  }
179
175
  }
180
176
 
@@ -15,6 +15,8 @@ const EntryDependency = require("./dependencies/EntryDependency");
15
15
  /** @typedef {import("../declarations/WebpackOptions").EntryStaticNormalized} EntryStatic */
16
16
  /** @typedef {import("./Compiler")} Compiler */
17
17
 
18
+ const PLUGIN_NAME = "DynamicEntryPlugin";
19
+
18
20
  class DynamicEntryPlugin {
19
21
  /**
20
22
  * @param {string} context the context path
@@ -32,7 +34,7 @@ class DynamicEntryPlugin {
32
34
  */
33
35
  apply(compiler) {
34
36
  compiler.hooks.compilation.tap(
35
- "DynamicEntryPlugin",
37
+ PLUGIN_NAME,
36
38
  (compilation, { normalModuleFactory }) => {
37
39
  compilation.dependencyFactories.set(
38
40
  EntryDependency,
@@ -41,7 +43,7 @@ class DynamicEntryPlugin {
41
43
  }
42
44
  );
43
45
 
44
- compiler.hooks.make.tapPromise("DynamicEntryPlugin", compilation =>
46
+ compiler.hooks.make.tapPromise(PLUGIN_NAME, compilation =>
45
47
  Promise.resolve(this.entry())
46
48
  .then(entry => {
47
49
  const promises = [];
@@ -10,13 +10,15 @@
10
10
  /** @typedef {import("./Compiler")} Compiler */
11
11
  /** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
12
12
 
13
+ const PLUGIN_NAME = "EntryOptionPlugin";
14
+
13
15
  class EntryOptionPlugin {
14
16
  /**
15
17
  * @param {Compiler} compiler the compiler instance one is tapping into
16
18
  * @returns {void}
17
19
  */
18
20
  apply(compiler) {
19
- compiler.hooks.entryOption.tap("EntryOptionPlugin", (context, entry) => {
21
+ compiler.hooks.entryOption.tap(PLUGIN_NAME, (context, entry) => {
20
22
  EntryOptionPlugin.applyEntryOption(compiler, context, entry);
21
23
  return true;
22
24
  });
@@ -10,6 +10,8 @@ const EntryDependency = require("./dependencies/EntryDependency");
10
10
  /** @typedef {import("./Compiler")} Compiler */
11
11
  /** @typedef {import("./Entrypoint").EntryOptions} EntryOptions */
12
12
 
13
+ const PLUGIN_NAME = "EntryPlugin";
14
+
13
15
  class EntryPlugin {
14
16
  /**
15
17
  * An entry plugin which will handle creation of the EntryDependency
@@ -30,7 +32,7 @@ class EntryPlugin {
30
32
  */
31
33
  apply(compiler) {
32
34
  compiler.hooks.compilation.tap(
33
- "EntryPlugin",
35
+ PLUGIN_NAME,
34
36
  (compilation, { normalModuleFactory }) => {
35
37
  compilation.dependencyFactories.set(
36
38
  EntryDependency,
@@ -42,7 +44,7 @@ class EntryPlugin {
42
44
  const { entry, options, context } = this;
43
45
  const dep = EntryPlugin.createDependency(entry, options);
44
46
 
45
- compiler.hooks.make.tapAsync("EntryPlugin", (compilation, callback) => {
47
+ compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
46
48
  compilation.addEntry(context, dep, options, err => {
47
49
  callback(err);
48
50
  });
@@ -11,6 +11,8 @@ const WebpackError = require("./WebpackError");
11
11
  /** @typedef {import("./Compiler")} Compiler */
12
12
  /** @typedef {import("./DefinePlugin").CodeValue} CodeValue */
13
13
 
14
+ const PLUGIN_NAME = "EnvironmentPlugin";
15
+
14
16
  class EnvironmentPlugin {
15
17
  /**
16
18
  * @param {(string | string[] | Record<string, EXPECTED_ANY>)[]} keys keys
@@ -46,9 +48,9 @@ class EnvironmentPlugin {
46
48
  : this.defaultValues[key];
47
49
 
48
50
  if (value === undefined) {
49
- compiler.hooks.thisCompilation.tap("EnvironmentPlugin", compilation => {
51
+ compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
50
52
  const error = new WebpackError(
51
- `EnvironmentPlugin - ${key} environment variable is undefined.\n\n` +
53
+ `${PLUGIN_NAME} - ${key} environment variable is undefined.\n\n` +
52
54
  "You can pass an object with default values to suppress this warning.\n" +
53
55
  "See https://webpack.js.org/plugins/environment-plugin for example."
54
56
  );
@@ -35,6 +35,8 @@ const devtoolWarning = new RawSource(`/*
35
35
  * @property {OutputOptions["devtoolModuleFilenameTemplate"]=} moduleFilenameTemplate module filename template
36
36
  */
37
37
 
38
+ const PLUGIN_NAME = "EvalDevToolModulePlugin";
39
+
38
40
  class EvalDevToolModulePlugin {
39
41
  /**
40
42
  * @param {EvalDevToolModulePluginOptions=} options options
@@ -53,10 +55,10 @@ class EvalDevToolModulePlugin {
53
55
  * @returns {void}
54
56
  */
55
57
  apply(compiler) {
56
- compiler.hooks.compilation.tap("EvalDevToolModulePlugin", compilation => {
58
+ compiler.hooks.compilation.tap(PLUGIN_NAME, compilation => {
57
59
  const hooks = JavascriptModulesPlugin.getCompilationHooks(compilation);
58
60
  hooks.renderModuleContent.tap(
59
- "EvalDevToolModulePlugin",
61
+ PLUGIN_NAME,
60
62
  (source, module, { chunk, runtimeTemplate, chunkGraph }) => {
61
63
  const cacheEntry = cache.get(source);
62
64
  if (cacheEntry !== undefined) return cacheEntry;
@@ -103,20 +105,20 @@ class EvalDevToolModulePlugin {
103
105
  }
104
106
  );
105
107
  hooks.inlineInRuntimeBailout.tap(
106
- "EvalDevToolModulePlugin",
108
+ PLUGIN_NAME,
107
109
  () => "the eval devtool is used."
108
110
  );
109
111
  hooks.render.tap(
110
- "EvalDevToolModulePlugin",
112
+ PLUGIN_NAME,
111
113
  source => new ConcatSource(devtoolWarning, source)
112
114
  );
113
- hooks.chunkHash.tap("EvalDevToolModulePlugin", (chunk, hash) => {
114
- hash.update("EvalDevToolModulePlugin");
115
+ hooks.chunkHash.tap(PLUGIN_NAME, (chunk, hash) => {
116
+ hash.update(PLUGIN_NAME);
115
117
  hash.update("2");
116
118
  });
117
119
  if (compilation.outputOptions.trustedTypes) {
118
120
  compilation.hooks.additionalModuleRuntimeRequirements.tap(
119
- "EvalDevToolModulePlugin",
121
+ PLUGIN_NAME,
120
122
  (module, set, context) => {
121
123
  set.add(RuntimeGlobals.createScript);
122
124
  }