webpack 5.77.0 → 5.79.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.

Potentially problematic release.


This version of webpack might be problematic. Click here for more details.

Files changed (82) hide show
  1. package/bin/webpack.js +0 -0
  2. package/lib/APIPlugin.js +25 -18
  3. package/lib/CompatibilityPlugin.js +80 -62
  4. package/lib/Compiler.js +7 -4
  5. package/lib/ConstPlugin.js +22 -15
  6. package/lib/ContextModule.js +3 -2
  7. package/lib/DefinePlugin.js +62 -42
  8. package/lib/DelegatedModule.js +2 -1
  9. package/lib/DllModule.js +2 -1
  10. package/lib/ErrorHelpers.js +61 -22
  11. package/lib/ExportsInfoApiPlugin.js +16 -9
  12. package/lib/ExternalModule.js +2 -1
  13. package/lib/FlagAllModulesAsUsedPlugin.js +22 -27
  14. package/lib/FlagDependencyExportsPlugin.js +336 -348
  15. package/lib/FlagDependencyUsagePlugin.js +6 -8
  16. package/lib/FlagEntryExportAsUsedPlugin.js +22 -23
  17. package/lib/HotModuleReplacementPlugin.js +50 -45
  18. package/lib/JavascriptMetaInfoPlugin.js +16 -9
  19. package/lib/LibManifestPlugin.js +2 -1
  20. package/lib/ModuleTypeConstants.js +50 -0
  21. package/lib/NodeStuffPlugin.js +35 -31
  22. package/lib/NormalModule.js +2 -1
  23. package/lib/NormalModuleFactory.js +7 -1
  24. package/lib/NormalModuleReplacementPlugin.js +1 -1
  25. package/lib/ProvidePlugin.js +17 -10
  26. package/lib/RawModule.js +2 -1
  27. package/lib/RequireJsStuffPlugin.js +15 -15
  28. package/lib/UseStrictPlugin.js +15 -8
  29. package/lib/WebpackIsIncludedPlugin.js +16 -9
  30. package/lib/config/defaults.js +16 -8
  31. package/lib/config/normalization.js +4 -0
  32. package/lib/container/ContainerEntryModule.js +2 -1
  33. package/lib/css/CssLoadingRuntimeModule.js +1 -1
  34. package/lib/css/CssParser.js +28 -8
  35. package/lib/css/walkCssTokens.js +6 -1
  36. package/lib/debug/ProfilingPlugin.js +20 -12
  37. package/lib/dependencies/AMDPlugin.js +26 -20
  38. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -4
  39. package/lib/dependencies/CommonJsPlugin.js +29 -25
  40. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -1
  41. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +4 -0
  42. package/lib/dependencies/HarmonyImportSpecifierDependency.js +28 -3
  43. package/lib/dependencies/HarmonyModulesPlugin.js +11 -5
  44. package/lib/dependencies/ImportMetaContextPlugin.js +11 -5
  45. package/lib/dependencies/ImportMetaPlugin.js +26 -20
  46. package/lib/dependencies/ImportPlugin.js +14 -7
  47. package/lib/dependencies/RequireContextPlugin.js +12 -6
  48. package/lib/dependencies/RequireEnsurePlugin.js +13 -7
  49. package/lib/dependencies/RequireIncludePlugin.js +11 -5
  50. package/lib/dependencies/SystemPlugin.js +21 -15
  51. package/lib/dependencies/URLPlugin.js +15 -9
  52. package/lib/dependencies/WorkerPlugin.js +14 -8
  53. package/lib/index.js +5 -0
  54. package/lib/javascript/JavascriptModulesPlugin.js +157 -164
  55. package/lib/javascript/JavascriptParser.js +88 -0
  56. package/lib/json/JsonModulesPlugin.js +13 -5
  57. package/lib/library/AmdLibraryPlugin.js +22 -6
  58. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
  59. package/lib/node/ReadFileCompileWasmPlugin.js +2 -1
  60. package/lib/optimize/ConcatenatedModule.js +2 -1
  61. package/lib/optimize/InnerGraphPlugin.js +47 -46
  62. package/lib/optimize/SideEffectsFlagPlugin.js +43 -43
  63. package/lib/sharing/ConsumeSharedPlugin.js +4 -0
  64. package/lib/stats/DefaultStatsPrinterPlugin.js +14 -0
  65. package/lib/util/hash/md4.js +2 -2
  66. package/lib/util/hash/xxhash64.js +1 -1
  67. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +9 -6
  68. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +42 -43
  69. package/lib/web/FetchCompileAsyncWasmPlugin.js +2 -1
  70. package/lib/web/FetchCompileWasmPlugin.js +40 -40
  71. package/lib/webpack.js +1 -1
  72. package/package.json +41 -36
  73. package/schemas/WebpackOptions.check.js +1 -1
  74. package/schemas/WebpackOptions.json +18 -0
  75. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  76. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  77. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  78. package/schemas/plugins/container/ContainerPlugin.json +8 -0
  79. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  80. package/schemas/plugins/container/ModuleFederationPlugin.json +8 -0
  81. package/schemas/plugins/sharing/SharePlugin.check.js +1 -1
  82. package/types.d.ts +152 -122
package/bin/webpack.js CHANGED
File without changes
package/lib/APIPlugin.js CHANGED
@@ -5,6 +5,11 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const {
9
+ JAVASCRIPT_MODULE_TYPE_AUTO,
10
+ JAVASCRIPT_MODULE_TYPE_DYNAMIC,
11
+ JAVASCRIPT_MODULE_TYPE_ESM
12
+ } = require("./ModuleTypeConstants");
8
13
  const RuntimeGlobals = require("./RuntimeGlobals");
9
14
  const WebpackError = require("./WebpackError");
10
15
  const ConstDependency = require("./dependencies/ConstDependency");
@@ -113,6 +118,8 @@ const REPLACEMENTS = {
113
118
  };
114
119
  /* eslint-enable camelcase */
115
120
 
121
+ const PLUGIN_NAME = "APIPlugin";
122
+
116
123
  class APIPlugin {
117
124
  /**
118
125
  * Apply the plugin
@@ -121,7 +128,7 @@ class APIPlugin {
121
128
  */
122
129
  apply(compiler) {
123
130
  compiler.hooks.compilation.tap(
124
- "APIPlugin",
131
+ PLUGIN_NAME,
125
132
  (compilation, { normalModuleFactory }) => {
126
133
  compilation.dependencyTemplates.set(
127
134
  ConstDependency,
@@ -130,7 +137,7 @@ class APIPlugin {
130
137
 
131
138
  compilation.hooks.runtimeRequirementInTree
132
139
  .for(RuntimeGlobals.chunkName)
133
- .tap("APIPlugin", chunk => {
140
+ .tap(PLUGIN_NAME, chunk => {
134
141
  compilation.addRuntimeModule(
135
142
  chunk,
136
143
  new ChunkNameRuntimeModule(chunk.name)
@@ -140,7 +147,7 @@ class APIPlugin {
140
147
 
141
148
  compilation.hooks.runtimeRequirementInTree
142
149
  .for(RuntimeGlobals.getFullHash)
143
- .tap("APIPlugin", (chunk, set) => {
150
+ .tap(PLUGIN_NAME, (chunk, set) => {
144
151
  compilation.addRuntimeModule(chunk, new GetFullHashRuntimeModule());
145
152
  return true;
146
153
  });
@@ -154,11 +161,11 @@ class APIPlugin {
154
161
  parser.hooks.expression
155
162
  .for(key)
156
163
  .tap(
157
- "APIPlugin",
164
+ PLUGIN_NAME,
158
165
  toConstantDependency(parser, info.expr, info.req)
159
166
  );
160
167
  if (info.assign === false) {
161
- parser.hooks.assign.for(key).tap("APIPlugin", expr => {
168
+ parser.hooks.assign.for(key).tap(PLUGIN_NAME, expr => {
162
169
  const err = new WebpackError(`${key} must not be assigned`);
163
170
  err.loc = expr.loc;
164
171
  throw err;
@@ -167,13 +174,13 @@ class APIPlugin {
167
174
  if (info.type) {
168
175
  parser.hooks.evaluateTypeof
169
176
  .for(key)
170
- .tap("APIPlugin", evaluateToString(info.type));
177
+ .tap(PLUGIN_NAME, evaluateToString(info.type));
171
178
  }
172
179
  });
173
180
 
174
181
  parser.hooks.expression
175
182
  .for("__webpack_layer__")
176
- .tap("APIPlugin", expr => {
183
+ .tap(PLUGIN_NAME, expr => {
177
184
  const dep = new ConstDependency(
178
185
  JSON.stringify(parser.state.module.layer),
179
186
  expr.range
@@ -184,7 +191,7 @@ class APIPlugin {
184
191
  });
185
192
  parser.hooks.evaluateIdentifier
186
193
  .for("__webpack_layer__")
187
- .tap("APIPlugin", expr =>
194
+ .tap(PLUGIN_NAME, expr =>
188
195
  (parser.state.module.layer === null
189
196
  ? new BasicEvaluatedExpression().setNull()
190
197
  : new BasicEvaluatedExpression().setString(
@@ -194,7 +201,7 @@ class APIPlugin {
194
201
  );
195
202
  parser.hooks.evaluateTypeof
196
203
  .for("__webpack_layer__")
197
- .tap("APIPlugin", expr =>
204
+ .tap(PLUGIN_NAME, expr =>
198
205
  new BasicEvaluatedExpression()
199
206
  .setString(
200
207
  parser.state.module.layer === null ? "object" : "string"
@@ -204,7 +211,7 @@ class APIPlugin {
204
211
 
205
212
  parser.hooks.expression
206
213
  .for("__webpack_module__.id")
207
- .tap("APIPlugin", expr => {
214
+ .tap(PLUGIN_NAME, expr => {
208
215
  parser.state.module.buildInfo.moduleConcatenationBailout =
209
216
  "__webpack_module__.id";
210
217
  const dep = new ConstDependency(
@@ -219,7 +226,7 @@ class APIPlugin {
219
226
 
220
227
  parser.hooks.expression
221
228
  .for("__webpack_module__")
222
- .tap("APIPlugin", expr => {
229
+ .tap(PLUGIN_NAME, expr => {
223
230
  parser.state.module.buildInfo.moduleConcatenationBailout =
224
231
  "__webpack_module__";
225
232
  const dep = new ConstDependency(
@@ -233,18 +240,18 @@ class APIPlugin {
233
240
  });
234
241
  parser.hooks.evaluateTypeof
235
242
  .for("__webpack_module__")
236
- .tap("APIPlugin", evaluateToString("object"));
243
+ .tap(PLUGIN_NAME, evaluateToString("object"));
237
244
  };
238
245
 
239
246
  normalModuleFactory.hooks.parser
240
- .for("javascript/auto")
241
- .tap("APIPlugin", handler);
247
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
248
+ .tap(PLUGIN_NAME, handler);
242
249
  normalModuleFactory.hooks.parser
243
- .for("javascript/dynamic")
244
- .tap("APIPlugin", handler);
250
+ .for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
251
+ .tap(PLUGIN_NAME, handler);
245
252
  normalModuleFactory.hooks.parser
246
- .for("javascript/esm")
247
- .tap("APIPlugin", handler);
253
+ .for(JAVASCRIPT_MODULE_TYPE_ESM)
254
+ .tap(PLUGIN_NAME, handler);
248
255
  }
249
256
  );
250
257
  }
@@ -5,12 +5,18 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const {
9
+ JAVASCRIPT_MODULE_TYPE_AUTO,
10
+ JAVASCRIPT_MODULE_TYPE_DYNAMIC,
11
+ JAVASCRIPT_MODULE_TYPE_ESM
12
+ } = require("./ModuleTypeConstants");
8
13
  const ConstDependency = require("./dependencies/ConstDependency");
9
14
 
10
15
  /** @typedef {import("./Compiler")} Compiler */
11
16
  /** @typedef {import("./javascript/JavascriptParser")} JavascriptParser */
12
17
 
13
- const nestedWebpackRequireTag = Symbol("nested __webpack_require__");
18
+ const nestedWebpackIdentifierTag = Symbol("nested webpack identifier");
19
+ const PLUGIN_NAME = "CompatibilityPlugin";
14
20
 
15
21
  class CompatibilityPlugin {
16
22
  /**
@@ -20,7 +26,7 @@ class CompatibilityPlugin {
20
26
  */
21
27
  apply(compiler) {
22
28
  compiler.hooks.compilation.tap(
23
- "CompatibilityPlugin",
29
+ PLUGIN_NAME,
24
30
  (compilation, { normalModuleFactory }) => {
25
31
  compilation.dependencyTemplates.set(
26
32
  ConstDependency,
@@ -28,41 +34,39 @@ class CompatibilityPlugin {
28
34
  );
29
35
 
30
36
  normalModuleFactory.hooks.parser
31
- .for("javascript/auto")
32
- .tap("CompatibilityPlugin", (parser, parserOptions) => {
37
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
38
+ .tap(PLUGIN_NAME, (parser, parserOptions) => {
33
39
  if (
34
40
  parserOptions.browserify !== undefined &&
35
41
  !parserOptions.browserify
36
42
  )
37
43
  return;
38
44
 
39
- parser.hooks.call
40
- .for("require")
41
- .tap("CompatibilityPlugin", expr => {
42
- // support for browserify style require delegator: "require(o, !0)"
43
- if (expr.arguments.length !== 2) return;
44
- const second = parser.evaluateExpression(expr.arguments[1]);
45
- if (!second.isBoolean()) return;
46
- if (second.asBool() !== true) return;
47
- const dep = new ConstDependency("require", expr.callee.range);
48
- dep.loc = expr.loc;
49
- if (parser.state.current.dependencies.length > 0) {
50
- const last =
51
- parser.state.current.dependencies[
52
- parser.state.current.dependencies.length - 1
53
- ];
54
- if (
55
- last.critical &&
56
- last.options &&
57
- last.options.request === "." &&
58
- last.userRequest === "." &&
59
- last.options.recursive
60
- )
61
- parser.state.current.dependencies.pop();
62
- }
63
- parser.state.module.addPresentationalDependency(dep);
64
- return true;
65
- });
45
+ parser.hooks.call.for("require").tap(PLUGIN_NAME, expr => {
46
+ // support for browserify style require delegator: "require(o, !0)"
47
+ if (expr.arguments.length !== 2) return;
48
+ const second = parser.evaluateExpression(expr.arguments[1]);
49
+ if (!second.isBoolean()) return;
50
+ if (second.asBool() !== true) return;
51
+ const dep = new ConstDependency("require", expr.callee.range);
52
+ dep.loc = expr.loc;
53
+ if (parser.state.current.dependencies.length > 0) {
54
+ const last =
55
+ parser.state.current.dependencies[
56
+ parser.state.current.dependencies.length - 1
57
+ ];
58
+ if (
59
+ last.critical &&
60
+ last.options &&
61
+ last.options.request === "." &&
62
+ last.userRequest === "." &&
63
+ last.options.recursive
64
+ )
65
+ parser.state.current.dependencies.pop();
66
+ }
67
+ parser.state.module.addPresentationalDependency(dep);
68
+ return true;
69
+ });
66
70
  });
67
71
 
68
72
  /**
@@ -71,29 +75,33 @@ class CompatibilityPlugin {
71
75
  */
72
76
  const handler = parser => {
73
77
  // Handle nested requires
74
- parser.hooks.preStatement.tap("CompatibilityPlugin", statement => {
78
+ parser.hooks.preStatement.tap(PLUGIN_NAME, statement => {
75
79
  if (
76
80
  statement.type === "FunctionDeclaration" &&
77
81
  statement.id &&
78
82
  statement.id.name === "__webpack_require__"
79
83
  ) {
80
84
  const newName = `__nested_webpack_require_${statement.range[0]}__`;
81
- parser.tagVariable(statement.id.name, nestedWebpackRequireTag, {
82
- name: newName,
83
- declaration: {
84
- updated: false,
85
- loc: statement.id.loc,
86
- range: statement.id.range
85
+ parser.tagVariable(
86
+ statement.id.name,
87
+ nestedWebpackIdentifierTag,
88
+ {
89
+ name: newName,
90
+ declaration: {
91
+ updated: false,
92
+ loc: statement.id.loc,
93
+ range: statement.id.range
94
+ }
87
95
  }
88
- });
96
+ );
89
97
  return true;
90
98
  }
91
99
  });
92
100
  parser.hooks.pattern
93
101
  .for("__webpack_require__")
94
- .tap("CompatibilityPlugin", pattern => {
102
+ .tap(PLUGIN_NAME, pattern => {
95
103
  const newName = `__nested_webpack_require_${pattern.range[0]}__`;
96
- parser.tagVariable(pattern.name, nestedWebpackRequireTag, {
104
+ parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
97
105
  name: newName,
98
106
  declaration: {
99
107
  updated: false,
@@ -103,9 +111,22 @@ class CompatibilityPlugin {
103
111
  });
104
112
  return true;
105
113
  });
114
+ parser.hooks.pattern
115
+ .for("__webpack_exports__")
116
+ .tap(PLUGIN_NAME, pattern => {
117
+ parser.tagVariable(pattern.name, nestedWebpackIdentifierTag, {
118
+ name: "__nested_webpack_exports__",
119
+ declaration: {
120
+ updated: false,
121
+ loc: pattern.loc,
122
+ range: pattern.range
123
+ }
124
+ });
125
+ return true;
126
+ });
106
127
  parser.hooks.expression
107
- .for(nestedWebpackRequireTag)
108
- .tap("CompatibilityPlugin", expr => {
128
+ .for(nestedWebpackIdentifierTag)
129
+ .tap(PLUGIN_NAME, expr => {
109
130
  const { name, declaration } = parser.currentTagData;
110
131
  if (!declaration.updated) {
111
132
  const dep = new ConstDependency(name, declaration.range);
@@ -120,31 +141,28 @@ class CompatibilityPlugin {
120
141
  });
121
142
 
122
143
  // Handle hashbang
123
- parser.hooks.program.tap(
124
- "CompatibilityPlugin",
125
- (program, comments) => {
126
- if (comments.length === 0) return;
127
- const c = comments[0];
128
- if (c.type === "Line" && c.range[0] === 0) {
129
- if (parser.state.source.slice(0, 2).toString() !== "#!") return;
130
- // this is a hashbang comment
131
- const dep = new ConstDependency("//", 0);
132
- dep.loc = c.loc;
133
- parser.state.module.addPresentationalDependency(dep);
134
- }
144
+ parser.hooks.program.tap(PLUGIN_NAME, (program, comments) => {
145
+ if (comments.length === 0) return;
146
+ const c = comments[0];
147
+ if (c.type === "Line" && c.range[0] === 0) {
148
+ if (parser.state.source.slice(0, 2).toString() !== "#!") return;
149
+ // this is a hashbang comment
150
+ const dep = new ConstDependency("//", 0);
151
+ dep.loc = c.loc;
152
+ parser.state.module.addPresentationalDependency(dep);
135
153
  }
136
- );
154
+ });
137
155
  };
138
156
 
139
157
  normalModuleFactory.hooks.parser
140
- .for("javascript/auto")
141
- .tap("CompatibilityPlugin", handler);
158
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
159
+ .tap(PLUGIN_NAME, handler);
142
160
  normalModuleFactory.hooks.parser
143
- .for("javascript/dynamic")
144
- .tap("CompatibilityPlugin", handler);
161
+ .for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
162
+ .tap(PLUGIN_NAME, handler);
145
163
  normalModuleFactory.hooks.parser
146
- .for("javascript/esm")
147
- .tap("CompatibilityPlugin", handler);
164
+ .for(JAVASCRIPT_MODULE_TYPE_ESM)
165
+ .tap(PLUGIN_NAME, handler);
148
166
  }
149
167
  );
150
168
  }
package/lib/Compiler.js CHANGED
@@ -970,10 +970,13 @@ ${other}`);
970
970
  readRecords(callback) {
971
971
  if (this.hooks.readRecords.isUsed()) {
972
972
  if (this.recordsInputPath) {
973
- asyncLib.parallel([
974
- cb => this.hooks.readRecords.callAsync(cb),
975
- this._readRecords.bind(this)
976
- ]);
973
+ asyncLib.parallel(
974
+ [
975
+ cb => this.hooks.readRecords.callAsync(cb),
976
+ this._readRecords.bind(this)
977
+ ],
978
+ err => callback(err)
979
+ );
977
980
  } else {
978
981
  this.records = {};
979
982
  this.hooks.readRecords.callAsync(callback);
@@ -5,6 +5,11 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const {
9
+ JAVASCRIPT_MODULE_TYPE_AUTO,
10
+ JAVASCRIPT_MODULE_TYPE_DYNAMIC,
11
+ JAVASCRIPT_MODULE_TYPE_ESM
12
+ } = require("./ModuleTypeConstants");
8
13
  const CachedConstDependency = require("./dependencies/CachedConstDependency");
9
14
  const ConstDependency = require("./dependencies/ConstDependency");
10
15
  const { evaluateToString } = require("./javascript/JavascriptParserHelpers");
@@ -108,6 +113,8 @@ const getHoistedDeclarations = (branch, includeFunctionDeclarations) => {
108
113
  return Array.from(declarations);
109
114
  };
110
115
 
116
+ const PLUGIN_NAME = "ConstPlugin";
117
+
111
118
  class ConstPlugin {
112
119
  /**
113
120
  * Apply the plugin
@@ -117,7 +124,7 @@ class ConstPlugin {
117
124
  apply(compiler) {
118
125
  const cachedParseResource = parseResource.bindCache(compiler.root);
119
126
  compiler.hooks.compilation.tap(
120
- "ConstPlugin",
127
+ PLUGIN_NAME,
121
128
  (compilation, { normalModuleFactory }) => {
122
129
  compilation.dependencyTemplates.set(
123
130
  ConstDependency,
@@ -130,7 +137,7 @@ class ConstPlugin {
130
137
  );
131
138
 
132
139
  const handler = parser => {
133
- parser.hooks.statementIf.tap("ConstPlugin", statement => {
140
+ parser.hooks.statementIf.tap(PLUGIN_NAME, statement => {
134
141
  if (parser.scope.isAsmJs) return;
135
142
  const param = parser.evaluateExpression(statement.test);
136
143
  const bool = param.asBool();
@@ -202,7 +209,7 @@ class ConstPlugin {
202
209
  }
203
210
  });
204
211
  parser.hooks.expressionConditionalOperator.tap(
205
- "ConstPlugin",
212
+ PLUGIN_NAME,
206
213
  expression => {
207
214
  if (parser.scope.isAsmJs) return;
208
215
  const param = parser.evaluateExpression(expression.test);
@@ -237,7 +244,7 @@ class ConstPlugin {
237
244
  }
238
245
  );
239
246
  parser.hooks.expressionLogicalOperator.tap(
240
- "ConstPlugin",
247
+ PLUGIN_NAME,
241
248
  expression => {
242
249
  if (parser.scope.isAsmJs) return;
243
250
  if (
@@ -374,7 +381,7 @@ class ConstPlugin {
374
381
  }
375
382
  }
376
383
  );
377
- parser.hooks.optionalChaining.tap("ConstPlugin", expr => {
384
+ parser.hooks.optionalChaining.tap(PLUGIN_NAME, expr => {
378
385
  /** @type {ExpressionNode[]} */
379
386
  const optionalExpressionsStack = [];
380
387
  /** @type {ExpressionNode|SuperNode} */
@@ -429,7 +436,7 @@ class ConstPlugin {
429
436
  });
430
437
  parser.hooks.evaluateIdentifier
431
438
  .for("__resourceQuery")
432
- .tap("ConstPlugin", expr => {
439
+ .tap(PLUGIN_NAME, expr => {
433
440
  if (parser.scope.isAsmJs) return;
434
441
  if (!parser.state.module) return;
435
442
  return evaluateToString(
@@ -438,7 +445,7 @@ class ConstPlugin {
438
445
  });
439
446
  parser.hooks.expression
440
447
  .for("__resourceQuery")
441
- .tap("ConstPlugin", expr => {
448
+ .tap(PLUGIN_NAME, expr => {
442
449
  if (parser.scope.isAsmJs) return;
443
450
  if (!parser.state.module) return;
444
451
  const dep = new CachedConstDependency(
@@ -455,7 +462,7 @@ class ConstPlugin {
455
462
 
456
463
  parser.hooks.evaluateIdentifier
457
464
  .for("__resourceFragment")
458
- .tap("ConstPlugin", expr => {
465
+ .tap(PLUGIN_NAME, expr => {
459
466
  if (parser.scope.isAsmJs) return;
460
467
  if (!parser.state.module) return;
461
468
  return evaluateToString(
@@ -464,7 +471,7 @@ class ConstPlugin {
464
471
  });
465
472
  parser.hooks.expression
466
473
  .for("__resourceFragment")
467
- .tap("ConstPlugin", expr => {
474
+ .tap(PLUGIN_NAME, expr => {
468
475
  if (parser.scope.isAsmJs) return;
469
476
  if (!parser.state.module) return;
470
477
  const dep = new CachedConstDependency(
@@ -481,14 +488,14 @@ class ConstPlugin {
481
488
  };
482
489
 
483
490
  normalModuleFactory.hooks.parser
484
- .for("javascript/auto")
485
- .tap("ConstPlugin", handler);
491
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
492
+ .tap(PLUGIN_NAME, handler);
486
493
  normalModuleFactory.hooks.parser
487
- .for("javascript/dynamic")
488
- .tap("ConstPlugin", handler);
494
+ .for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
495
+ .tap(PLUGIN_NAME, handler);
489
496
  normalModuleFactory.hooks.parser
490
- .for("javascript/esm")
491
- .tap("ConstPlugin", handler);
497
+ .for(JAVASCRIPT_MODULE_TYPE_ESM)
498
+ .tap(PLUGIN_NAME, handler);
492
499
  }
493
500
  );
494
501
  }
@@ -9,6 +9,7 @@ const { OriginalSource, RawSource } = require("webpack-sources");
9
9
  const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
10
10
  const { makeWebpackError } = require("./HookWebpackError");
11
11
  const Module = require("./Module");
12
+ const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
12
13
  const RuntimeGlobals = require("./RuntimeGlobals");
13
14
  const Template = require("./Template");
14
15
  const WebpackError = require("./WebpackError");
@@ -105,7 +106,7 @@ class ContextModule extends Module {
105
106
  const resourceFragment =
106
107
  (options && options.resourceFragment) || parsed.fragment;
107
108
 
108
- super("javascript/dynamic", resource);
109
+ super(JAVASCRIPT_MODULE_TYPE_DYNAMIC, resource);
109
110
  /** @type {ContextModuleOptions} */
110
111
  this.options = {
111
112
  ...options,
@@ -114,7 +115,7 @@ class ContextModule extends Module {
114
115
  resourceFragment
115
116
  };
116
117
  } else {
117
- super("javascript/dynamic");
118
+ super(JAVASCRIPT_MODULE_TYPE_DYNAMIC);
118
119
  /** @type {ContextModuleOptions} */
119
120
  this.options = {
120
121
  ...options,