webpack 5.77.0 → 5.78.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 (66) hide show
  1. package/bin/webpack.js +0 -0
  2. package/lib/APIPlugin.js +25 -18
  3. package/lib/CompatibilityPlugin.js +53 -52
  4. package/lib/ConstPlugin.js +22 -15
  5. package/lib/ContextModule.js +3 -2
  6. package/lib/DefinePlugin.js +44 -36
  7. package/lib/DelegatedModule.js +2 -1
  8. package/lib/DllModule.js +2 -1
  9. package/lib/ErrorHelpers.js +61 -22
  10. package/lib/ExportsInfoApiPlugin.js +16 -9
  11. package/lib/ExternalModule.js +2 -1
  12. package/lib/FlagAllModulesAsUsedPlugin.js +22 -27
  13. package/lib/FlagDependencyExportsPlugin.js +336 -348
  14. package/lib/FlagDependencyUsagePlugin.js +6 -8
  15. package/lib/FlagEntryExportAsUsedPlugin.js +22 -23
  16. package/lib/HotModuleReplacementPlugin.js +50 -45
  17. package/lib/JavascriptMetaInfoPlugin.js +16 -9
  18. package/lib/ModuleTypeConstants.js +50 -0
  19. package/lib/NodeStuffPlugin.js +35 -31
  20. package/lib/NormalModule.js +2 -1
  21. package/lib/NormalModuleFactory.js +7 -1
  22. package/lib/ProvidePlugin.js +17 -10
  23. package/lib/RawModule.js +2 -1
  24. package/lib/RequireJsStuffPlugin.js +15 -15
  25. package/lib/UseStrictPlugin.js +15 -8
  26. package/lib/WebpackIsIncludedPlugin.js +16 -9
  27. package/lib/config/defaults.js +16 -8
  28. package/lib/config/normalization.js +4 -0
  29. package/lib/container/ContainerEntryModule.js +2 -1
  30. package/lib/css/CssParser.js +22 -2
  31. package/lib/debug/ProfilingPlugin.js +20 -12
  32. package/lib/dependencies/AMDPlugin.js +26 -20
  33. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -4
  34. package/lib/dependencies/CommonJsPlugin.js +29 -25
  35. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -1
  36. package/lib/dependencies/HarmonyModulesPlugin.js +11 -5
  37. package/lib/dependencies/ImportMetaContextPlugin.js +11 -5
  38. package/lib/dependencies/ImportMetaPlugin.js +26 -20
  39. package/lib/dependencies/ImportPlugin.js +14 -7
  40. package/lib/dependencies/RequireContextPlugin.js +12 -6
  41. package/lib/dependencies/RequireEnsurePlugin.js +13 -7
  42. package/lib/dependencies/RequireIncludePlugin.js +11 -5
  43. package/lib/dependencies/SystemPlugin.js +21 -15
  44. package/lib/dependencies/URLPlugin.js +15 -9
  45. package/lib/dependencies/WorkerPlugin.js +14 -8
  46. package/lib/javascript/JavascriptModulesPlugin.js +157 -164
  47. package/lib/json/JsonModulesPlugin.js +13 -5
  48. package/lib/library/AmdLibraryPlugin.js +22 -6
  49. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +2 -1
  50. package/lib/node/ReadFileCompileWasmPlugin.js +2 -1
  51. package/lib/optimize/ConcatenatedModule.js +2 -1
  52. package/lib/optimize/InnerGraphPlugin.js +47 -46
  53. package/lib/optimize/SideEffectsFlagPlugin.js +43 -43
  54. package/lib/sharing/ConsumeSharedPlugin.js +4 -0
  55. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +9 -6
  56. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +42 -43
  57. package/lib/web/FetchCompileAsyncWasmPlugin.js +2 -1
  58. package/lib/web/FetchCompileWasmPlugin.js +40 -40
  59. package/package.json +1 -1
  60. package/schemas/WebpackOptions.check.js +1 -1
  61. package/schemas/WebpackOptions.json +18 -0
  62. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  63. package/schemas/plugins/container/ContainerPlugin.json +8 -0
  64. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  65. package/schemas/plugins/container/ModuleFederationPlugin.json +8 -0
  66. package/types.d.ts +10 -0
@@ -24,16 +24,22 @@ const RuntimeRequirementsDependency = require("./RuntimeRequirementsDependency")
24
24
  const CommonJsExportsParserPlugin = require("./CommonJsExportsParserPlugin");
25
25
  const CommonJsImportsParserPlugin = require("./CommonJsImportsParserPlugin");
26
26
 
27
+ const {
28
+ JAVASCRIPT_MODULE_TYPE_AUTO,
29
+ JAVASCRIPT_MODULE_TYPE_DYNAMIC
30
+ } = require("../ModuleTypeConstants");
27
31
  const {
28
32
  evaluateToIdentifier,
29
33
  toConstantDependency
30
34
  } = require("../javascript/JavascriptParserHelpers");
31
35
  const CommonJsExportRequireDependency = require("./CommonJsExportRequireDependency");
32
36
 
37
+ const PLUGIN_NAME = "CommonJsPlugin";
38
+
33
39
  class CommonJsPlugin {
34
40
  apply(compiler) {
35
41
  compiler.hooks.compilation.tap(
36
- "CommonJsPlugin",
42
+ PLUGIN_NAME,
37
43
  (compilation, { contextModuleFactory, normalModuleFactory }) => {
38
44
  compilation.dependencyFactories.set(
39
45
  CommonJsRequireDependency,
@@ -126,21 +132,21 @@ class CommonJsPlugin {
126
132
 
127
133
  compilation.hooks.runtimeRequirementInModule
128
134
  .for(RuntimeGlobals.harmonyModuleDecorator)
129
- .tap("CommonJsPlugin", (module, set) => {
135
+ .tap(PLUGIN_NAME, (module, set) => {
130
136
  set.add(RuntimeGlobals.module);
131
137
  set.add(RuntimeGlobals.requireScope);
132
138
  });
133
139
 
134
140
  compilation.hooks.runtimeRequirementInModule
135
141
  .for(RuntimeGlobals.nodeModuleDecorator)
136
- .tap("CommonJsPlugin", (module, set) => {
142
+ .tap(PLUGIN_NAME, (module, set) => {
137
143
  set.add(RuntimeGlobals.module);
138
144
  set.add(RuntimeGlobals.requireScope);
139
145
  });
140
146
 
141
147
  compilation.hooks.runtimeRequirementInTree
142
148
  .for(RuntimeGlobals.harmonyModuleDecorator)
143
- .tap("CommonJsPlugin", (chunk, set) => {
149
+ .tap(PLUGIN_NAME, (chunk, set) => {
144
150
  compilation.addRuntimeModule(
145
151
  chunk,
146
152
  new HarmonyModuleDecoratorRuntimeModule()
@@ -149,7 +155,7 @@ class CommonJsPlugin {
149
155
 
150
156
  compilation.hooks.runtimeRequirementInTree
151
157
  .for(RuntimeGlobals.nodeModuleDecorator)
152
- .tap("CommonJsPlugin", (chunk, set) => {
158
+ .tap(PLUGIN_NAME, (chunk, set) => {
153
159
  compilation.addRuntimeModule(
154
160
  chunk,
155
161
  new NodeModuleDecoratorRuntimeModule()
@@ -162,14 +168,14 @@ class CommonJsPlugin {
162
168
  parser.hooks.typeof
163
169
  .for("module")
164
170
  .tap(
165
- "CommonJsPlugin",
171
+ PLUGIN_NAME,
166
172
  toConstantDependency(parser, JSON.stringify("object"))
167
173
  );
168
174
 
169
175
  parser.hooks.expression
170
176
  .for("require.main")
171
177
  .tap(
172
- "CommonJsPlugin",
178
+ PLUGIN_NAME,
173
179
  toConstantDependency(
174
180
  parser,
175
181
  `${RuntimeGlobals.moduleCache}[${RuntimeGlobals.entryModuleId}]`,
@@ -178,7 +184,7 @@ class CommonJsPlugin {
178
184
  );
179
185
  parser.hooks.expression
180
186
  .for("module.loaded")
181
- .tap("CommonJsPlugin", expr => {
187
+ .tap(PLUGIN_NAME, expr => {
182
188
  parser.state.module.buildInfo.moduleConcatenationBailout =
183
189
  "module.loaded";
184
190
  const dep = new RuntimeRequirementsDependency([
@@ -189,21 +195,19 @@ class CommonJsPlugin {
189
195
  return true;
190
196
  });
191
197
 
192
- parser.hooks.expression
193
- .for("module.id")
194
- .tap("CommonJsPlugin", expr => {
195
- parser.state.module.buildInfo.moduleConcatenationBailout =
196
- "module.id";
197
- const dep = new RuntimeRequirementsDependency([
198
- RuntimeGlobals.moduleId
199
- ]);
200
- dep.loc = expr.loc;
201
- parser.state.module.addPresentationalDependency(dep);
202
- return true;
203
- });
198
+ parser.hooks.expression.for("module.id").tap(PLUGIN_NAME, expr => {
199
+ parser.state.module.buildInfo.moduleConcatenationBailout =
200
+ "module.id";
201
+ const dep = new RuntimeRequirementsDependency([
202
+ RuntimeGlobals.moduleId
203
+ ]);
204
+ dep.loc = expr.loc;
205
+ parser.state.module.addPresentationalDependency(dep);
206
+ return true;
207
+ });
204
208
 
205
209
  parser.hooks.evaluateIdentifier.for("module.hot").tap(
206
- "CommonJsPlugin",
210
+ PLUGIN_NAME,
207
211
  evaluateToIdentifier("module.hot", "module", () => ["hot"], null)
208
212
  );
209
213
 
@@ -214,11 +218,11 @@ class CommonJsPlugin {
214
218
  };
215
219
 
216
220
  normalModuleFactory.hooks.parser
217
- .for("javascript/auto")
218
- .tap("CommonJsPlugin", handler);
221
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
222
+ .tap(PLUGIN_NAME, handler);
219
223
  normalModuleFactory.hooks.parser
220
- .for("javascript/dynamic")
221
- .tap("CommonJsPlugin", handler);
224
+ .for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
225
+ .tap(PLUGIN_NAME, handler);
222
226
  }
223
227
  );
224
228
  }
@@ -5,6 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const { JAVASCRIPT_MODULE_TYPE_ESM } = require("../ModuleTypeConstants");
8
9
  const DynamicExports = require("./DynamicExports");
9
10
  const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency");
10
11
  const HarmonyExports = require("./HarmonyExports");
@@ -17,7 +18,8 @@ module.exports = class HarmonyDetectionParserPlugin {
17
18
 
18
19
  apply(parser) {
19
20
  parser.hooks.program.tap("HarmonyDetectionParserPlugin", ast => {
20
- const isStrictHarmony = parser.state.module.type === "javascript/esm";
21
+ const isStrictHarmony =
22
+ parser.state.module.type === JAVASCRIPT_MODULE_TYPE_ESM;
21
23
  const isHarmony =
22
24
  isStrictHarmony ||
23
25
  ast.body.some(
@@ -16,6 +16,10 @@ const HarmonyExportSpecifierDependency = require("./HarmonyExportSpecifierDepend
16
16
  const HarmonyImportSideEffectDependency = require("./HarmonyImportSideEffectDependency");
17
17
  const HarmonyImportSpecifierDependency = require("./HarmonyImportSpecifierDependency");
18
18
 
19
+ const {
20
+ JAVASCRIPT_MODULE_TYPE_AUTO,
21
+ JAVASCRIPT_MODULE_TYPE_ESM
22
+ } = require("../ModuleTypeConstants");
19
23
  const HarmonyDetectionParserPlugin = require("./HarmonyDetectionParserPlugin");
20
24
  const HarmonyExportDependencyParserPlugin = require("./HarmonyExportDependencyParserPlugin");
21
25
  const HarmonyImportDependencyParserPlugin = require("./HarmonyImportDependencyParserPlugin");
@@ -23,6 +27,8 @@ const HarmonyTopLevelThisParserPlugin = require("./HarmonyTopLevelThisParserPlug
23
27
 
24
28
  /** @typedef {import("../Compiler")} Compiler */
25
29
 
30
+ const PLUGIN_NAME = "HarmonyModulesPlugin";
31
+
26
32
  class HarmonyModulesPlugin {
27
33
  constructor(options) {
28
34
  this.options = options;
@@ -35,7 +41,7 @@ class HarmonyModulesPlugin {
35
41
  */
36
42
  apply(compiler) {
37
43
  compiler.hooks.compilation.tap(
38
- "HarmonyModulesPlugin",
44
+ PLUGIN_NAME,
39
45
  (compilation, { normalModuleFactory }) => {
40
46
  compilation.dependencyTemplates.set(
41
47
  HarmonyCompatibilityDependency,
@@ -119,11 +125,11 @@ class HarmonyModulesPlugin {
119
125
  };
120
126
 
121
127
  normalModuleFactory.hooks.parser
122
- .for("javascript/auto")
123
- .tap("HarmonyModulesPlugin", handler);
128
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
129
+ .tap(PLUGIN_NAME, handler);
124
130
  normalModuleFactory.hooks.parser
125
- .for("javascript/esm")
126
- .tap("HarmonyModulesPlugin", handler);
131
+ .for(JAVASCRIPT_MODULE_TYPE_ESM)
132
+ .tap(PLUGIN_NAME, handler);
127
133
  }
128
134
  );
129
135
  }
@@ -5,6 +5,10 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const {
9
+ JAVASCRIPT_MODULE_TYPE_AUTO,
10
+ JAVASCRIPT_MODULE_TYPE_ESM
11
+ } = require("../ModuleTypeConstants");
8
12
  const ContextElementDependency = require("./ContextElementDependency");
9
13
  const ImportMetaContextDependency = require("./ImportMetaContextDependency");
10
14
  const ImportMetaContextDependencyParserPlugin = require("./ImportMetaContextDependencyParserPlugin");
@@ -12,6 +16,8 @@ const ImportMetaContextDependencyParserPlugin = require("./ImportMetaContextDepe
12
16
  /** @typedef {import("../../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
13
17
  /** @typedef {import("../Compiler")} Compiler */
14
18
 
19
+ const PLUGIN_NAME = "ImportMetaContextPlugin";
20
+
15
21
  class ImportMetaContextPlugin {
16
22
  /**
17
23
  * Apply the plugin
@@ -20,7 +26,7 @@ class ImportMetaContextPlugin {
20
26
  */
21
27
  apply(compiler) {
22
28
  compiler.hooks.compilation.tap(
23
- "RequireContextPlugin",
29
+ PLUGIN_NAME,
24
30
  (compilation, { contextModuleFactory, normalModuleFactory }) => {
25
31
  compilation.dependencyFactories.set(
26
32
  ImportMetaContextDependency,
@@ -46,11 +52,11 @@ class ImportMetaContextPlugin {
46
52
  };
47
53
 
48
54
  normalModuleFactory.hooks.parser
49
- .for("javascript/auto")
50
- .tap("ImportMetaContextPlugin", handler);
55
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
56
+ .tap(PLUGIN_NAME, handler);
51
57
  normalModuleFactory.hooks.parser
52
- .for("javascript/esm")
53
- .tap("ImportMetaContextPlugin", handler);
58
+ .for(JAVASCRIPT_MODULE_TYPE_ESM)
59
+ .tap(PLUGIN_NAME, handler);
54
60
  }
55
61
  );
56
62
  }
@@ -7,6 +7,10 @@
7
7
 
8
8
  const { pathToFileURL } = require("url");
9
9
  const ModuleDependencyWarning = require("../ModuleDependencyWarning");
10
+ const {
11
+ JAVASCRIPT_MODULE_TYPE_AUTO,
12
+ JAVASCRIPT_MODULE_TYPE_ESM
13
+ } = require("../ModuleTypeConstants");
10
14
  const Template = require("../Template");
11
15
  const BasicEvaluatedExpression = require("../javascript/BasicEvaluatedExpression");
12
16
  const {
@@ -29,13 +33,15 @@ const getCriticalDependencyWarning = memoize(() =>
29
33
  require("./CriticalDependencyWarning")
30
34
  );
31
35
 
36
+ const PLUGIN_NAME = "ImportMetaPlugin";
37
+
32
38
  class ImportMetaPlugin {
33
39
  /**
34
40
  * @param {Compiler} compiler compiler
35
41
  */
36
42
  apply(compiler) {
37
43
  compiler.hooks.compilation.tap(
38
- "ImportMetaPlugin",
44
+ PLUGIN_NAME,
39
45
  (compilation, { normalModuleFactory }) => {
40
46
  /**
41
47
  * @param {NormalModule} module module
@@ -56,7 +62,7 @@ class ImportMetaPlugin {
56
62
 
57
63
  parser.hooks.expression
58
64
  .for("import.meta")
59
- .tap("ImportMetaPlugin", metaProperty => {
65
+ .tap(PLUGIN_NAME, metaProperty => {
60
66
  const dep = new ConstDependency(
61
67
  importMetaName,
62
68
  metaProperty.range
@@ -72,12 +78,12 @@ class ImportMetaPlugin {
72
78
  parser.hooks.typeof
73
79
  .for("import.meta")
74
80
  .tap(
75
- "ImportMetaPlugin",
81
+ PLUGIN_NAME,
76
82
  toConstantDependency(parser, JSON.stringify("object"))
77
83
  );
78
84
  parser.hooks.expression
79
85
  .for("import.meta")
80
- .tap("ImportMetaPlugin", metaProperty => {
86
+ .tap(PLUGIN_NAME, metaProperty => {
81
87
  const CriticalDependencyWarning = getCriticalDependencyWarning();
82
88
  parser.state.module.addWarning(
83
89
  new ModuleDependencyWarning(
@@ -98,9 +104,9 @@ class ImportMetaPlugin {
98
104
  });
99
105
  parser.hooks.evaluateTypeof
100
106
  .for("import.meta")
101
- .tap("ImportMetaPlugin", evaluateToString("object"));
107
+ .tap(PLUGIN_NAME, evaluateToString("object"));
102
108
  parser.hooks.evaluateIdentifier.for("import.meta").tap(
103
- "ImportMetaPlugin",
109
+ PLUGIN_NAME,
104
110
  evaluateToIdentifier("import.meta", "import.meta", () => [], true)
105
111
  );
106
112
 
@@ -108,12 +114,12 @@ class ImportMetaPlugin {
108
114
  parser.hooks.typeof
109
115
  .for("import.meta.url")
110
116
  .tap(
111
- "ImportMetaPlugin",
117
+ PLUGIN_NAME,
112
118
  toConstantDependency(parser, JSON.stringify("string"))
113
119
  );
114
120
  parser.hooks.expression
115
121
  .for("import.meta.url")
116
- .tap("ImportMetaPlugin", expr => {
122
+ .tap(PLUGIN_NAME, expr => {
117
123
  const dep = new ConstDependency(
118
124
  JSON.stringify(getUrl(parser.state.module)),
119
125
  expr.range
@@ -124,10 +130,10 @@ class ImportMetaPlugin {
124
130
  });
125
131
  parser.hooks.evaluateTypeof
126
132
  .for("import.meta.url")
127
- .tap("ImportMetaPlugin", evaluateToString("string"));
133
+ .tap(PLUGIN_NAME, evaluateToString("string"));
128
134
  parser.hooks.evaluateIdentifier
129
135
  .for("import.meta.url")
130
- .tap("ImportMetaPlugin", expr => {
136
+ .tap(PLUGIN_NAME, expr => {
131
137
  return new BasicEvaluatedExpression()
132
138
  .setString(getUrl(parser.state.module))
133
139
  .setRange(expr.range);
@@ -141,26 +147,26 @@ class ImportMetaPlugin {
141
147
  parser.hooks.typeof
142
148
  .for("import.meta.webpack")
143
149
  .tap(
144
- "ImportMetaPlugin",
150
+ PLUGIN_NAME,
145
151
  toConstantDependency(parser, JSON.stringify("number"))
146
152
  );
147
153
  parser.hooks.expression
148
154
  .for("import.meta.webpack")
149
155
  .tap(
150
- "ImportMetaPlugin",
156
+ PLUGIN_NAME,
151
157
  toConstantDependency(parser, JSON.stringify(webpackVersion))
152
158
  );
153
159
  parser.hooks.evaluateTypeof
154
160
  .for("import.meta.webpack")
155
- .tap("ImportMetaPlugin", evaluateToString("number"));
161
+ .tap(PLUGIN_NAME, evaluateToString("number"));
156
162
  parser.hooks.evaluateIdentifier
157
163
  .for("import.meta.webpack")
158
- .tap("ImportMetaPlugin", evaluateToNumber(webpackVersion));
164
+ .tap(PLUGIN_NAME, evaluateToNumber(webpackVersion));
159
165
 
160
166
  /// Unknown properties ///
161
167
  parser.hooks.unhandledExpressionMemberChain
162
168
  .for("import.meta")
163
- .tap("ImportMetaPlugin", (expr, members) => {
169
+ .tap(PLUGIN_NAME, (expr, members) => {
164
170
  const dep = new ConstDependency(
165
171
  `${Template.toNormalComment(
166
172
  "unsupported import.meta." + members.join(".")
@@ -173,7 +179,7 @@ class ImportMetaPlugin {
173
179
  });
174
180
  parser.hooks.evaluate
175
181
  .for("MemberExpression")
176
- .tap("ImportMetaPlugin", expression => {
182
+ .tap(PLUGIN_NAME, expression => {
177
183
  const expr = /** @type {MemberExpression} */ (expression);
178
184
  if (
179
185
  expr.object.type === "MetaProperty" &&
@@ -190,11 +196,11 @@ class ImportMetaPlugin {
190
196
  };
191
197
 
192
198
  normalModuleFactory.hooks.parser
193
- .for("javascript/auto")
194
- .tap("ImportMetaPlugin", parserHandler);
199
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
200
+ .tap(PLUGIN_NAME, parserHandler);
195
201
  normalModuleFactory.hooks.parser
196
- .for("javascript/esm")
197
- .tap("ImportMetaPlugin", parserHandler);
202
+ .for(JAVASCRIPT_MODULE_TYPE_ESM)
203
+ .tap(PLUGIN_NAME, parserHandler);
198
204
  }
199
205
  );
200
206
  }
@@ -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 ImportContextDependency = require("./ImportContextDependency");
9
14
  const ImportDependency = require("./ImportDependency");
10
15
  const ImportEagerDependency = require("./ImportEagerDependency");
@@ -13,6 +18,8 @@ const ImportWeakDependency = require("./ImportWeakDependency");
13
18
 
14
19
  /** @typedef {import("../Compiler")} Compiler */
15
20
 
21
+ const PLUGIN_NAME = "ImportPlugin";
22
+
16
23
  class ImportPlugin {
17
24
  /**
18
25
  * Apply the plugin
@@ -21,7 +28,7 @@ class ImportPlugin {
21
28
  */
22
29
  apply(compiler) {
23
30
  compiler.hooks.compilation.tap(
24
- "ImportPlugin",
31
+ PLUGIN_NAME,
25
32
  (compilation, { contextModuleFactory, normalModuleFactory }) => {
26
33
  compilation.dependencyFactories.set(
27
34
  ImportDependency,
@@ -67,14 +74,14 @@ class ImportPlugin {
67
74
  };
68
75
 
69
76
  normalModuleFactory.hooks.parser
70
- .for("javascript/auto")
71
- .tap("ImportPlugin", handler);
77
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
78
+ .tap(PLUGIN_NAME, handler);
72
79
  normalModuleFactory.hooks.parser
73
- .for("javascript/dynamic")
74
- .tap("ImportPlugin", handler);
80
+ .for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
81
+ .tap(PLUGIN_NAME, handler);
75
82
  normalModuleFactory.hooks.parser
76
- .for("javascript/esm")
77
- .tap("ImportPlugin", handler);
83
+ .for(JAVASCRIPT_MODULE_TYPE_ESM)
84
+ .tap(PLUGIN_NAME, handler);
78
85
  }
79
86
  );
80
87
  }
@@ -5,6 +5,10 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const {
9
+ JAVASCRIPT_MODULE_TYPE_AUTO,
10
+ JAVASCRIPT_MODULE_TYPE_DYNAMIC
11
+ } = require("../ModuleTypeConstants");
8
12
  const { cachedSetProperty } = require("../util/cleverMerge");
9
13
  const ContextElementDependency = require("./ContextElementDependency");
10
14
  const RequireContextDependency = require("./RequireContextDependency");
@@ -16,6 +20,8 @@ const RequireContextDependencyParserPlugin = require("./RequireContextDependency
16
20
  /** @type {ResolveOptions} */
17
21
  const EMPTY_RESOLVE_OPTIONS = {};
18
22
 
23
+ const PLUGIN_NAME = "RequireContextPlugin";
24
+
19
25
  class RequireContextPlugin {
20
26
  /**
21
27
  * Apply the plugin
@@ -24,7 +30,7 @@ class RequireContextPlugin {
24
30
  */
25
31
  apply(compiler) {
26
32
  compiler.hooks.compilation.tap(
27
- "RequireContextPlugin",
33
+ PLUGIN_NAME,
28
34
  (compilation, { contextModuleFactory, normalModuleFactory }) => {
29
35
  compilation.dependencyFactories.set(
30
36
  RequireContextDependency,
@@ -51,14 +57,14 @@ class RequireContextPlugin {
51
57
  };
52
58
 
53
59
  normalModuleFactory.hooks.parser
54
- .for("javascript/auto")
55
- .tap("RequireContextPlugin", handler);
60
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
61
+ .tap(PLUGIN_NAME, handler);
56
62
  normalModuleFactory.hooks.parser
57
- .for("javascript/dynamic")
58
- .tap("RequireContextPlugin", handler);
63
+ .for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
64
+ .tap(PLUGIN_NAME, handler);
59
65
 
60
66
  contextModuleFactory.hooks.alternativeRequests.tap(
61
- "RequireContextPlugin",
67
+ PLUGIN_NAME,
62
68
  (items, options) => {
63
69
  if (items.length === 0) return items;
64
70
 
@@ -10,15 +10,21 @@ const RequireEnsureItemDependency = require("./RequireEnsureItemDependency");
10
10
 
11
11
  const RequireEnsureDependenciesBlockParserPlugin = require("./RequireEnsureDependenciesBlockParserPlugin");
12
12
 
13
+ const {
14
+ JAVASCRIPT_MODULE_TYPE_AUTO,
15
+ JAVASCRIPT_MODULE_TYPE_DYNAMIC
16
+ } = require("../ModuleTypeConstants");
13
17
  const {
14
18
  evaluateToString,
15
19
  toConstantDependency
16
20
  } = require("../javascript/JavascriptParserHelpers");
17
21
 
22
+ const PLUGIN_NAME = "RequireEnsurePlugin";
23
+
18
24
  class RequireEnsurePlugin {
19
25
  apply(compiler) {
20
26
  compiler.hooks.compilation.tap(
21
- "RequireEnsurePlugin",
27
+ PLUGIN_NAME,
22
28
  (compilation, { normalModuleFactory }) => {
23
29
  compilation.dependencyFactories.set(
24
30
  RequireEnsureItemDependency,
@@ -44,21 +50,21 @@ class RequireEnsurePlugin {
44
50
  new RequireEnsureDependenciesBlockParserPlugin().apply(parser);
45
51
  parser.hooks.evaluateTypeof
46
52
  .for("require.ensure")
47
- .tap("RequireEnsurePlugin", evaluateToString("function"));
53
+ .tap(PLUGIN_NAME, evaluateToString("function"));
48
54
  parser.hooks.typeof
49
55
  .for("require.ensure")
50
56
  .tap(
51
- "RequireEnsurePlugin",
57
+ PLUGIN_NAME,
52
58
  toConstantDependency(parser, JSON.stringify("function"))
53
59
  );
54
60
  };
55
61
 
56
62
  normalModuleFactory.hooks.parser
57
- .for("javascript/auto")
58
- .tap("RequireEnsurePlugin", handler);
63
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
64
+ .tap(PLUGIN_NAME, handler);
59
65
  normalModuleFactory.hooks.parser
60
- .for("javascript/dynamic")
61
- .tap("RequireEnsurePlugin", handler);
66
+ .for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
67
+ .tap(PLUGIN_NAME, handler);
62
68
  }
63
69
  );
64
70
  }
@@ -5,13 +5,19 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const {
9
+ JAVASCRIPT_MODULE_TYPE_AUTO,
10
+ JAVASCRIPT_MODULE_TYPE_DYNAMIC
11
+ } = require("../ModuleTypeConstants");
8
12
  const RequireIncludeDependency = require("./RequireIncludeDependency");
9
13
  const RequireIncludeDependencyParserPlugin = require("./RequireIncludeDependencyParserPlugin");
10
14
 
15
+ const PLUGIN_NAME = "RequireIncludePlugin";
16
+
11
17
  class RequireIncludePlugin {
12
18
  apply(compiler) {
13
19
  compiler.hooks.compilation.tap(
14
- "RequireIncludePlugin",
20
+ PLUGIN_NAME,
15
21
  (compilation, { normalModuleFactory }) => {
16
22
  compilation.dependencyFactories.set(
17
23
  RequireIncludeDependency,
@@ -30,11 +36,11 @@ class RequireIncludePlugin {
30
36
  };
31
37
 
32
38
  normalModuleFactory.hooks.parser
33
- .for("javascript/auto")
34
- .tap("RequireIncludePlugin", handler);
39
+ .for(JAVASCRIPT_MODULE_TYPE_AUTO)
40
+ .tap(PLUGIN_NAME, handler);
35
41
  normalModuleFactory.hooks.parser
36
- .for("javascript/dynamic")
37
- .tap("RequireIncludePlugin", handler);
42
+ .for(JAVASCRIPT_MODULE_TYPE_DYNAMIC)
43
+ .tap(PLUGIN_NAME, handler);
38
44
  }
39
45
  );
40
46
  }