webpack 5.94.0 → 5.96.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (151) hide show
  1. package/README.md +1 -1
  2. package/lib/AsyncDependenciesBlock.js +1 -1
  3. package/lib/BannerPlugin.js +2 -1
  4. package/lib/Chunk.js +30 -0
  5. package/lib/ChunkGraph.js +11 -6
  6. package/lib/ChunkGroup.js +2 -2
  7. package/lib/CleanPlugin.js +4 -5
  8. package/lib/CodeGenerationResults.js +6 -5
  9. package/lib/Compilation.js +71 -48
  10. package/lib/Compiler.js +7 -5
  11. package/lib/ConcatenationScope.js +7 -20
  12. package/lib/ContextModule.js +7 -8
  13. package/lib/CssModule.js +25 -21
  14. package/lib/DefinePlugin.js +14 -8
  15. package/lib/DelegatedModule.js +3 -3
  16. package/lib/DllModule.js +4 -4
  17. package/lib/DynamicEntryPlugin.js +29 -22
  18. package/lib/EnvironmentPlugin.js +3 -2
  19. package/lib/EvalDevToolModulePlugin.js +5 -2
  20. package/lib/EvalSourceMapDevToolPlugin.js +5 -2
  21. package/lib/ExternalModule.js +118 -99
  22. package/lib/ExternalModuleFactoryPlugin.js +33 -9
  23. package/lib/FileSystemInfo.js +12 -8
  24. package/lib/Generator.js +5 -4
  25. package/lib/HotModuleReplacementPlugin.js +8 -6
  26. package/lib/IgnorePlugin.js +19 -1
  27. package/lib/LoaderOptionsPlugin.js +3 -1
  28. package/lib/Module.js +9 -8
  29. package/lib/ModuleSourceTypesConstants.js +100 -0
  30. package/lib/NormalModule.js +27 -13
  31. package/lib/NormalModuleFactory.js +38 -22
  32. package/lib/OptionsApply.js +12 -1
  33. package/lib/ProgressPlugin.js +50 -10
  34. package/lib/RawModule.js +3 -4
  35. package/lib/RuntimeModule.js +3 -4
  36. package/lib/RuntimePlugin.js +11 -4
  37. package/lib/RuntimeTemplate.js +13 -42
  38. package/lib/SourceMapDevToolPlugin.js +10 -7
  39. package/lib/TemplatedPathPlugin.js +9 -3
  40. package/lib/Watching.js +2 -2
  41. package/lib/WebpackOptionsApply.js +42 -21
  42. package/lib/asset/AssetGenerator.js +347 -194
  43. package/lib/asset/AssetModulesPlugin.js +2 -1
  44. package/lib/asset/AssetSourceGenerator.js +82 -27
  45. package/lib/asset/RawDataUrlModule.js +5 -4
  46. package/lib/buildChunkGraph.js +79 -62
  47. package/lib/cache/PackFileCacheStrategy.js +69 -31
  48. package/lib/cache/ResolverCachePlugin.js +248 -173
  49. package/lib/config/defaults.js +135 -126
  50. package/lib/container/ContainerEntryModule.js +3 -4
  51. package/lib/container/ContainerPlugin.js +8 -0
  52. package/lib/container/FallbackModule.js +2 -2
  53. package/lib/container/HoistContainerReferencesPlugin.js +250 -0
  54. package/lib/container/ModuleFederationPlugin.js +38 -1
  55. package/lib/container/RemoteModule.js +4 -2
  56. package/lib/container/RemoteRuntimeModule.js +4 -2
  57. package/lib/css/CssExportsGenerator.js +16 -12
  58. package/lib/css/CssGenerator.js +22 -16
  59. package/lib/css/CssLoadingRuntimeModule.js +7 -6
  60. package/lib/css/CssModulesPlugin.js +122 -77
  61. package/lib/css/CssParser.js +655 -526
  62. package/lib/css/walkCssTokens.js +1168 -338
  63. package/lib/debug/ProfilingPlugin.js +5 -0
  64. package/lib/dependencies/CommonJsExportsParserPlugin.js +5 -2
  65. package/lib/dependencies/CommonJsImportsParserPlugin.js +3 -6
  66. package/lib/dependencies/ContextDependency.js +6 -1
  67. package/lib/dependencies/ContextElementDependency.js +33 -6
  68. package/lib/dependencies/CssExportDependency.js +3 -3
  69. package/lib/dependencies/CssLocalIdentifierDependency.js +26 -17
  70. package/lib/dependencies/CssUrlDependency.js +33 -3
  71. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +3 -3
  72. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +39 -14
  73. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +15 -82
  74. package/lib/dependencies/HarmonyImportSpecifierDependency.js +5 -2
  75. package/lib/dependencies/ImportParserPlugin.js +9 -7
  76. package/lib/dependencies/LoaderPlugin.js +19 -0
  77. package/lib/dependencies/SystemPlugin.js +2 -1
  78. package/lib/dependencies/URLPlugin.js +7 -1
  79. package/lib/dependencies/WorkerPlugin.js +1 -1
  80. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +4 -2
  81. package/lib/hmr/HotModuleReplacement.runtime.js +1 -0
  82. package/lib/hmr/JavascriptHotModuleReplacement.runtime.js +1 -0
  83. package/lib/hmr/LazyCompilationPlugin.js +16 -4
  84. package/lib/hmr/lazyCompilationBackend.js +1 -7
  85. package/lib/index.js +35 -6
  86. package/lib/javascript/EnableChunkLoadingPlugin.js +2 -2
  87. package/lib/javascript/JavascriptGenerator.js +8 -8
  88. package/lib/javascript/JavascriptModulesPlugin.js +166 -88
  89. package/lib/javascript/JavascriptParser.js +338 -117
  90. package/lib/json/JsonGenerator.js +5 -5
  91. package/lib/library/EnableLibraryPlugin.js +2 -2
  92. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  93. package/lib/library/UmdLibraryPlugin.js +16 -8
  94. package/lib/logging/Logger.js +11 -11
  95. package/lib/logging/createConsoleLogger.js +14 -14
  96. package/lib/logging/truncateArgs.js +1 -1
  97. package/lib/node/NodeWatchFileSystem.js +3 -1
  98. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +20 -18
  99. package/lib/node/ReadFileCompileWasmPlugin.js +1 -2
  100. package/lib/node/nodeConsole.js +11 -8
  101. package/lib/optimize/AggressiveSplittingPlugin.js +21 -7
  102. package/lib/optimize/ConcatenatedModule.js +44 -148
  103. package/lib/optimize/FlagIncludedChunksPlugin.js +6 -0
  104. package/lib/optimize/InnerGraphPlugin.js +57 -16
  105. package/lib/optimize/LimitChunkCountPlugin.js +2 -4
  106. package/lib/optimize/MergeDuplicateChunksPlugin.js +2 -2
  107. package/lib/optimize/ModuleConcatenationPlugin.js +4 -2
  108. package/lib/optimize/RealContentHashPlugin.js +1 -1
  109. package/lib/optimize/SideEffectsFlagPlugin.js +6 -3
  110. package/lib/rules/RuleSetCompiler.js +2 -2
  111. package/lib/runtime/GetChunkFilenameRuntimeModule.js +2 -2
  112. package/lib/schemes/DataUriPlugin.js +1 -1
  113. package/lib/serialization/BinaryMiddleware.js +32 -19
  114. package/lib/serialization/ObjectMiddleware.js +23 -9
  115. package/lib/serialization/SerializerMiddleware.js +3 -2
  116. package/lib/serialization/types.js +2 -2
  117. package/lib/sharing/ConsumeSharedModule.js +2 -3
  118. package/lib/sharing/ConsumeSharedRuntimeModule.js +3 -1
  119. package/lib/sharing/ProvideSharedModule.js +2 -3
  120. package/lib/stats/DefaultStatsFactoryPlugin.js +22 -20
  121. package/lib/stats/StatsFactory.js +12 -12
  122. package/lib/stats/StatsPrinter.js +7 -7
  123. package/lib/util/AsyncQueue.js +17 -1
  124. package/lib/util/IterableHelpers.js +1 -1
  125. package/lib/util/LazySet.js +12 -0
  126. package/lib/util/SetHelpers.js +1 -1
  127. package/lib/util/cleverMerge.js +48 -24
  128. package/lib/util/concatenate.js +227 -0
  129. package/lib/util/create-schema-validation.js +22 -9
  130. package/lib/util/deprecation.js +86 -28
  131. package/lib/util/fs.js +10 -10
  132. package/lib/util/hash/wasm-hash.js +12 -1
  133. package/lib/util/magicComment.js +21 -0
  134. package/lib/util/makeSerializable.js +24 -1
  135. package/lib/util/memoize.js +2 -1
  136. package/lib/util/runtime.js +10 -1
  137. package/lib/util/semver.js +130 -23
  138. package/lib/wasm/EnableWasmLoadingPlugin.js +2 -2
  139. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +3 -3
  140. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +5 -5
  141. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -5
  142. package/lib/wasm-sync/WebAssemblyGenerator.js +8 -9
  143. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -5
  144. package/lib/web/FetchCompileAsyncWasmPlugin.js +1 -2
  145. package/lib/web/FetchCompileWasmPlugin.js +1 -2
  146. package/lib/web/JsonpChunkLoadingRuntimeModule.js +6 -6
  147. package/package.json +19 -20
  148. package/schemas/WebpackOptions.check.js +1 -1
  149. package/schemas/WebpackOptions.json +12 -2
  150. package/types.d.ts +817 -269
  151. package/lib/util/mergeScope.js +0 -76
@@ -8,20 +8,20 @@
8
8
  const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
9
9
  const CommentCompilationWarning = require("../CommentCompilationWarning");
10
10
  const UnsupportedFeatureWarning = require("../UnsupportedFeatureWarning");
11
+ const { getImportAttributes } = require("../javascript/JavascriptParser");
11
12
  const ContextDependencyHelpers = require("./ContextDependencyHelpers");
12
- const { getAttributes } = require("./HarmonyImportDependencyParserPlugin");
13
13
  const ImportContextDependency = require("./ImportContextDependency");
14
14
  const ImportDependency = require("./ImportDependency");
15
15
  const ImportEagerDependency = require("./ImportEagerDependency");
16
16
  const ImportWeakDependency = require("./ImportWeakDependency");
17
17
 
18
- /** @typedef {import("estree").ImportExpression} ImportExpression */
19
18
  /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
20
19
  /** @typedef {import("../ChunkGroup").RawChunkGroupOptions} RawChunkGroupOptions */
21
20
  /** @typedef {import("../ContextModule").ContextMode} ContextMode */
22
21
  /** @typedef {import("../Dependency").DependencyLocation} DependencyLocation */
23
22
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
24
23
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
24
+ /** @typedef {import("../javascript/JavascriptParser").ImportExpression} ImportExpression */
25
25
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
26
26
 
27
27
  class ImportParserPlugin {
@@ -85,7 +85,7 @@ class ImportParserPlugin {
85
85
  parser.state.module.addWarning(
86
86
  new CommentCompilationWarning(
87
87
  `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
88
- comment.loc
88
+ /** @type {DependencyLocation} */ (comment.loc)
89
89
  )
90
90
  );
91
91
  }
@@ -126,7 +126,7 @@ class ImportParserPlugin {
126
126
  )
127
127
  );
128
128
  } else {
129
- mode = importOptions.webpackMode;
129
+ mode = /** @type {ContextMode} */ (importOptions.webpackMode);
130
130
  }
131
131
  }
132
132
  if (importOptions.webpackPrefetch !== undefined) {
@@ -162,7 +162,9 @@ class ImportParserPlugin {
162
162
  typeof importOptions.webpackFetchPriority === "string" &&
163
163
  ["high", "low", "auto"].includes(importOptions.webpackFetchPriority)
164
164
  ) {
165
- groupOptions.fetchPriority = importOptions.webpackFetchPriority;
165
+ groupOptions.fetchPriority =
166
+ /** @type {"low" | "high" | "auto"} */
167
+ (importOptions.webpackFetchPriority);
166
168
  } else {
167
169
  parser.state.module.addWarning(
168
170
  new UnsupportedFeatureWarning(
@@ -258,7 +260,7 @@ class ImportParserPlugin {
258
260
  }
259
261
 
260
262
  if (param.isString()) {
261
- const attributes = getAttributes(expr);
263
+ const attributes = getImportAttributes(expr);
262
264
 
263
265
  if (mode === "eager") {
264
266
  const dep = new ImportEagerDependency(
@@ -321,7 +323,7 @@ class ImportParserPlugin {
321
323
  typePrefix: "import()",
322
324
  category: "esm",
323
325
  referencedExports: exports,
324
- attributes: getAttributes(expr)
326
+ attributes: getImportAttributes(expr)
325
327
  },
326
328
  parser
327
329
  );
@@ -76,6 +76,12 @@ class LoaderPlugin {
76
76
  )
77
77
  );
78
78
  }
79
+ const oldFactorizeQueueContext =
80
+ compilation.factorizeQueue.getContext();
81
+ compilation.factorizeQueue.setContext("load-module");
82
+ const oldAddModuleQueueContext =
83
+ compilation.addModuleQueue.getContext();
84
+ compilation.addModuleQueue.setContext("load-module");
79
85
  compilation.buildQueue.increaseParallelism();
80
86
  compilation.handleModuleCreation(
81
87
  {
@@ -88,6 +94,8 @@ class LoaderPlugin {
88
94
  recursive: false
89
95
  },
90
96
  err => {
97
+ compilation.factorizeQueue.setContext(oldFactorizeQueueContext);
98
+ compilation.addModuleQueue.setContext(oldAddModuleQueueContext);
91
99
  compilation.buildQueue.decreaseParallelism();
92
100
  if (err) {
93
101
  return callback(err);
@@ -173,6 +181,13 @@ class LoaderPlugin {
173
181
  )
174
182
  );
175
183
  }
184
+
185
+ const oldFactorizeQueueContext =
186
+ compilation.factorizeQueue.getContext();
187
+ compilation.factorizeQueue.setContext("import-module");
188
+ const oldAddModuleQueueContext =
189
+ compilation.addModuleQueue.getContext();
190
+ compilation.addModuleQueue.setContext("import-module");
176
191
  compilation.buildQueue.increaseParallelism();
177
192
  compilation.handleModuleCreation(
178
193
  {
@@ -189,6 +204,8 @@ class LoaderPlugin {
189
204
  checkCycle: true
190
205
  },
191
206
  err => {
207
+ compilation.factorizeQueue.setContext(oldFactorizeQueueContext);
208
+ compilation.addModuleQueue.setContext(oldAddModuleQueueContext);
192
209
  compilation.buildQueue.decreaseParallelism();
193
210
  if (err) {
194
211
  return callback(err);
@@ -197,6 +214,7 @@ class LoaderPlugin {
197
214
  if (!referencedModule) {
198
215
  return callback(new Error("Cannot load the module"));
199
216
  }
217
+ compilation.buildQueue.increaseParallelism();
200
218
  compilation.executeModule(
201
219
  referencedModule,
202
220
  {
@@ -206,6 +224,7 @@ class LoaderPlugin {
206
224
  }
207
225
  },
208
226
  (err, result) => {
227
+ compilation.buildQueue.decreaseParallelism();
209
228
  if (err) return callback(err);
210
229
  const {
211
230
  fileDependencies,
@@ -125,7 +125,8 @@ class SystemPlugin {
125
125
  /** @type {import("estree").Literal} */
126
126
  (expr.arguments[0]),
127
127
  loc: expr.loc,
128
- range: expr.range
128
+ range: expr.range,
129
+ options: null
129
130
  });
130
131
  });
131
132
  };
@@ -19,6 +19,7 @@ const InnerGraph = require("../optimize/InnerGraph");
19
19
  const ConstDependency = require("./ConstDependency");
20
20
  const URLDependency = require("./URLDependency");
21
21
 
22
+ /** @typedef {import("estree").MemberExpression} MemberExpression */
22
23
  /** @typedef {import("estree").NewExpression} NewExpressionNode */
23
24
  /** @typedef {import("../../declarations/WebpackOptions").JavascriptParserOptions} JavascriptParserOptions */
24
25
  /** @typedef {import("../Compiler")} Compiler */
@@ -50,6 +51,11 @@ class URLPlugin {
50
51
  */
51
52
  const getUrl = module => pathToFileURL(module.resource);
52
53
 
54
+ /**
55
+ * @param {Parser} parser parser parser
56
+ * @param {MemberExpression} arg arg
57
+ * @returns {boolean} true when it is `meta.url`, otherwise false
58
+ */
53
59
  const isMetaUrl = (parser, arg) => {
54
60
  const chain = parser.extractMemberExpressionChain(arg);
55
61
 
@@ -117,7 +123,7 @@ class URLPlugin {
117
123
  parser.state.module.addWarning(
118
124
  new CommentCompilationWarning(
119
125
  `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
120
- comment.loc
126
+ /** @type {DependencyLocation} */ (comment.loc)
121
127
  )
122
128
  );
123
129
  }
@@ -251,7 +251,7 @@ class WorkerPlugin {
251
251
  parser.state.module.addWarning(
252
252
  new CommentCompilationWarning(
253
253
  `Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
254
- comment.loc
254
+ /** @type {DependencyLocation} */ (comment.loc)
255
255
  )
256
256
  );
257
257
  }
@@ -113,10 +113,12 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
113
113
  ModuleChunkLoadingRuntimeModule.getCompilationHooks(compilation);
114
114
  const withPrefetch =
115
115
  environment.document &&
116
- this._runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers);
116
+ this._runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers) &&
117
+ chunk.hasChildByOrder(chunkGraph, "prefetch", true, chunkHasJs);
117
118
  const withPreload =
118
119
  environment.document &&
119
- this._runtimeRequirements.has(RuntimeGlobals.preloadChunkHandlers);
120
+ this._runtimeRequirements.has(RuntimeGlobals.preloadChunkHandlers) &&
121
+ chunk.hasChildByOrder(chunkGraph, "preload", true, chunkHasJs);
120
122
  const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
121
123
  const hasJsMatcher = compileBooleanMatcher(conditionMap);
122
124
  const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /*
2
3
  MIT License http://www.opensource.org/licenses/mit-license.php
3
4
  Author Tobias Koppers @sokra
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  /*
2
3
  MIT License http://www.opensource.org/licenses/mit-license.php
3
4
  Author Tobias Koppers @sokra
@@ -10,6 +10,7 @@ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
10
10
  const Dependency = require("../Dependency");
11
11
  const Module = require("../Module");
12
12
  const ModuleFactory = require("../ModuleFactory");
13
+ const { JS_TYPES } = require("../ModuleSourceTypesConstants");
13
14
  const {
14
15
  WEBPACK_MODULE_TYPE_LAZY_COMPILATION_PROXY
15
16
  } = require("../ModuleTypeConstants");
@@ -73,8 +74,6 @@ const checkTest = (test, module) => {
73
74
  return false;
74
75
  };
75
76
 
76
- const TYPES = new Set(["javascript"]);
77
-
78
77
  class LazyCompilationDependency extends Dependency {
79
78
  /**
80
79
  * @param {LazyCompilationProxyModule} proxyModule proxy module
@@ -207,7 +206,7 @@ class LazyCompilationProxyModule extends Module {
207
206
  * @returns {SourceTypes} types available (do not mutate)
208
207
  */
209
208
  getSourceTypes() {
210
- return TYPES;
209
+ return JS_TYPES;
211
210
  }
212
211
 
213
212
  /**
@@ -329,10 +328,23 @@ class LazyCompilationDependencyFactory extends ModuleFactory {
329
328
  }
330
329
  }
331
330
 
331
+ /**
332
+ * @callback BackendHandler
333
+ * @param {Compiler} compiler compiler
334
+ * @param {function(Error | null, BackendApi=): void} callback callback
335
+ * @returns {void}
336
+ */
337
+
338
+ /**
339
+ * @callback PromiseBackendHandler
340
+ * @param {Compiler} compiler compiler
341
+ * @returns {Promise<BackendApi>} backend
342
+ */
343
+
332
344
  class LazyCompilationPlugin {
333
345
  /**
334
346
  * @param {object} options options
335
- * @param {(function(Compiler, function(Error=, BackendApi?): void): void) | function(Compiler): Promise<BackendApi>} options.backend the backend
347
+ * @param {BackendHandler | PromiseBackendHandler} options.backend the backend
336
348
  * @param {boolean} options.entries true, when entries are lazy compiled
337
349
  * @param {boolean} options.imports true, when import() modules are lazy compiled
338
350
  * @param {RegExp | string | (function(Module): boolean) | undefined} options.test additional filter for lazy compiled entrypoint modules
@@ -16,13 +16,7 @@
16
16
  /** @typedef {import("../Compiler")} Compiler */
17
17
  /** @typedef {import("../Module")} Module */
18
18
  /** @typedef {import("./LazyCompilationPlugin").BackendApi} BackendApi */
19
-
20
- /**
21
- * @callback BackendHandler
22
- * @param {Compiler} compiler compiler
23
- * @param {function(Error | null, BackendApi=): void} callback callback
24
- * @returns {void}
25
- */
19
+ /** @typedef {import("./LazyCompilationPlugin").BackendHandler} BackendHandler */
26
20
 
27
21
  /**
28
22
  * @param {Omit<LazyCompilationDefaultBackendOptions, "client"> & { client: NonNullable<LazyCompilationDefaultBackendOptions["client"]>}} options additional options for the backend
package/lib/index.js CHANGED
@@ -70,7 +70,13 @@ const memoize = require("./util/memoize");
70
70
  */
71
71
  const lazyFunction = factory => {
72
72
  const fac = memoize(factory);
73
- const f = /** @type {any} */ ((...args) => fac()(...args));
73
+ const f = /** @type {any} */ (
74
+ /**
75
+ * @param {...any} args args
76
+ * @returns {T} result
77
+ */
78
+ (...args) => fac()(...args)
79
+ );
74
80
  return /** @type {T} */ (f);
75
81
  };
76
82
 
@@ -113,13 +119,21 @@ module.exports = mergeExports(fn, {
113
119
  get webpack() {
114
120
  return require("./webpack");
115
121
  },
122
+ /**
123
+ * @returns {function(Configuration): void} validate fn
124
+ */
116
125
  get validate() {
117
126
  const webpackOptionsSchemaCheck = require("../schemas/WebpackOptions.check.js");
118
- const getRealValidate = memoize(() => {
119
- const validateSchema = require("./validateSchema");
120
- const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
121
- return options => validateSchema(webpackOptionsSchema, options);
122
- });
127
+ const getRealValidate = memoize(
128
+ /**
129
+ * @returns {function(Configuration): void} validate fn
130
+ */
131
+ () => {
132
+ const validateSchema = require("./validateSchema");
133
+ const webpackOptionsSchema = require("../schemas/WebpackOptions.json");
134
+ return options => validateSchema(webpackOptionsSchema, options);
135
+ }
136
+ );
123
137
  return options => {
124
138
  if (!webpackOptionsSchemaCheck(options)) getRealValidate()(options);
125
139
  };
@@ -475,6 +489,15 @@ module.exports = mergeExports(fn, {
475
489
  },
476
490
  get JsonpTemplatePlugin() {
477
491
  return require("./web/JsonpTemplatePlugin");
492
+ },
493
+ get CssLoadingRuntimeModule() {
494
+ return require("./css/CssLoadingRuntimeModule");
495
+ }
496
+ },
497
+
498
+ esm: {
499
+ get ModuleChunkLoadingRuntimeModule() {
500
+ return require("./esm/ModuleChunkLoadingRuntimeModule");
478
501
  }
479
502
  },
480
503
 
@@ -517,6 +540,12 @@ module.exports = mergeExports(fn, {
517
540
  }
518
541
  },
519
542
 
543
+ css: {
544
+ get CssModulesPlugin() {
545
+ return require("./css/CssModulesPlugin");
546
+ }
547
+ },
548
+
520
549
  library: {
521
550
  get AbstractLibraryPlugin() {
522
551
  return require("./library/AbstractLibraryPlugin");
@@ -51,8 +51,8 @@ class EnableChunkLoadingPlugin {
51
51
  throw new Error(
52
52
  `Chunk loading type "${type}" is not enabled. ` +
53
53
  "EnableChunkLoadingPlugin need to be used to enable this type of chunk loading. " +
54
- `This usually happens through the "output.enabledChunkLoadingTypes" option. ` +
55
- `If you are using a function as entry which sets "chunkLoading", you need to add all potential chunk loading types to "output.enabledChunkLoadingTypes". ` +
54
+ 'This usually happens through the "output.enabledChunkLoadingTypes" option. ' +
55
+ 'If you are using a function as entry which sets "chunkLoading", you need to add all potential chunk loading types to "output.enabledChunkLoadingTypes". ' +
56
56
  `These types are enabled: ${Array.from(
57
57
  getEnabledTypes(compiler)
58
58
  ).join(", ")}`
@@ -9,6 +9,7 @@ const util = require("util");
9
9
  const { RawSource, ReplaceSource } = require("webpack-sources");
10
10
  const Generator = require("../Generator");
11
11
  const InitFragment = require("../InitFragment");
12
+ const { JS_TYPES } = require("../ModuleSourceTypesConstants");
12
13
  const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibilityDependency");
13
14
 
14
15
  /** @typedef {import("webpack-sources").Source} Source */
@@ -20,6 +21,7 @@ const HarmonyCompatibilityDependency = require("../dependencies/HarmonyCompatibi
20
21
  /** @typedef {import("../Generator").GenerateContext} GenerateContext */
21
22
  /** @typedef {import("../Module")} Module */
22
23
  /** @typedef {import("../Module").ConcatenationBailoutReasonContext} ConcatenationBailoutReasonContext */
24
+ /** @typedef {import("../Module").SourceTypes} SourceTypes */
23
25
  /** @typedef {import("../NormalModule")} NormalModule */
24
26
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
25
27
 
@@ -40,15 +42,13 @@ const deprecatedGetInitFragments = util.deprecate(
40
42
  "DEP_WEBPACK_JAVASCRIPT_GENERATOR_GET_INIT_FRAGMENTS"
41
43
  );
42
44
 
43
- const TYPES = new Set(["javascript"]);
44
-
45
45
  class JavascriptGenerator extends Generator {
46
46
  /**
47
47
  * @param {NormalModule} module fresh module
48
- * @returns {Set<string>} available types (do not mutate)
48
+ * @returns {SourceTypes} available types (do not mutate)
49
49
  */
50
50
  getTypes(module) {
51
- return TYPES;
51
+ return JS_TYPES;
52
52
  }
53
53
 
54
54
  /**
@@ -93,7 +93,7 @@ class JavascriptGenerator extends Generator {
93
93
  /**
94
94
  * @param {NormalModule} module module for which the code should be generated
95
95
  * @param {GenerateContext} generateContext context for generate
96
- * @returns {Source} generated code
96
+ * @returns {Source | null} generated code
97
97
  */
98
98
  generate(module, generateContext) {
99
99
  const originalSource = module.originalSource();
@@ -190,9 +190,9 @@ class JavascriptGenerator extends Generator {
190
190
  * @returns {void}
191
191
  */
192
192
  sourceDependency(module, dependency, initFragments, source, generateContext) {
193
- const constructor = /** @type {new (...args: any[]) => Dependency} */ (
194
- dependency.constructor
195
- );
193
+ const constructor =
194
+ /** @type {new (...args: EXPECTED_ANY[]) => Dependency} */
195
+ (dependency.constructor);
196
196
  const template = generateContext.dependencyTemplates.get(constructor);
197
197
  if (!template) {
198
198
  throw new Error(