webpack 5.105.3 → 5.106.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 (131) hide show
  1. package/README.md +3 -6
  2. package/lib/BannerPlugin.js +13 -13
  3. package/lib/Chunk.js +25 -0
  4. package/lib/ChunkGraph.js +8 -4
  5. package/lib/CleanPlugin.js +23 -20
  6. package/lib/CompatibilityPlugin.js +1 -1
  7. package/lib/Compilation.js +36 -13
  8. package/lib/Compiler.js +59 -1
  9. package/lib/CssModule.js +17 -2
  10. package/lib/Dependency.js +1 -1
  11. package/lib/DllPlugin.js +17 -17
  12. package/lib/DllReferencePlugin.js +20 -18
  13. package/lib/DotenvPlugin.js +29 -27
  14. package/lib/ExternalModule.js +39 -6
  15. package/lib/FileSystemInfo.js +3 -1
  16. package/lib/IgnorePlugin.js +12 -11
  17. package/lib/LoaderOptionsPlugin.js +17 -15
  18. package/lib/ManifestPlugin.js +27 -25
  19. package/lib/Module.js +84 -4
  20. package/lib/ModuleGraph.js +3 -0
  21. package/lib/ModuleParseError.js +1 -1
  22. package/lib/ModuleTypeConstants.js +1 -1
  23. package/lib/MultiStats.js +5 -5
  24. package/lib/NormalModule.js +7 -3
  25. package/lib/NormalModuleFactory.js +20 -1
  26. package/lib/ProgressPlugin.js +39 -29
  27. package/lib/RuntimeGlobals.js +6 -0
  28. package/lib/RuntimeModule.js +18 -1
  29. package/lib/RuntimeTemplate.js +1 -1
  30. package/lib/SourceMapDevToolPlugin.js +13 -11
  31. package/lib/Stats.js +3 -2
  32. package/lib/TemplatedPathPlugin.js +4 -3
  33. package/lib/WatchIgnorePlugin.js +15 -13
  34. package/lib/WebpackOptionsApply.js +4 -4
  35. package/lib/asset/AssetModulesPlugin.js +50 -29
  36. package/lib/cli.js +3 -1
  37. package/lib/config/defaults.js +27 -13
  38. package/lib/config/normalization.js +3 -2
  39. package/lib/container/ContainerPlugin.js +46 -42
  40. package/lib/container/ContainerReferencePlugin.js +42 -26
  41. package/lib/container/FallbackModule.js +1 -1
  42. package/lib/container/ModuleFederationPlugin.js +17 -13
  43. package/lib/container/RemoteModule.js +18 -1
  44. package/lib/css/CssGenerator.js +315 -191
  45. package/lib/css/CssInjectStyleRuntimeModule.js +179 -0
  46. package/lib/css/CssLoadingRuntimeModule.js +1 -4
  47. package/lib/css/CssModulesPlugin.js +197 -98
  48. package/lib/css/CssParser.js +231 -134
  49. package/lib/css/walkCssTokens.js +115 -12
  50. package/lib/debug/ProfilingPlugin.js +16 -13
  51. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +20 -15
  52. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +4 -3
  53. package/lib/dependencies/CommonJsExportRequireDependency.js +4 -2
  54. package/lib/dependencies/CommonJsExportsDependency.js +1 -1
  55. package/lib/dependencies/CommonJsExportsParserPlugin.js +1 -1
  56. package/lib/dependencies/CommonJsFullRequireDependency.js +1 -1
  57. package/lib/dependencies/CommonJsImportsParserPlugin.js +63 -2
  58. package/lib/dependencies/CommonJsRequireContextDependency.js +21 -0
  59. package/lib/dependencies/CommonJsRequireDependency.js +42 -1
  60. package/lib/dependencies/CommonJsSelfReferenceDependency.js +1 -1
  61. package/lib/dependencies/ContextElementDependency.js +1 -1
  62. package/lib/dependencies/CreateRequireParserPlugin.js +11 -0
  63. package/lib/dependencies/CssIcssExportDependency.js +210 -87
  64. package/lib/dependencies/CssIcssImportDependency.js +13 -70
  65. package/lib/dependencies/CssIcssSymbolDependency.js +19 -30
  66. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +13 -2
  67. package/lib/dependencies/HarmonyExportExpressionDependency.js +28 -2
  68. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +13 -3
  69. package/lib/dependencies/HarmonyExportInitFragment.js +1 -1
  70. package/lib/dependencies/HarmonyImportDependency.js +21 -8
  71. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +124 -205
  72. package/lib/dependencies/HarmonyImportSideEffectDependency.js +12 -6
  73. package/lib/dependencies/HarmonyImportSpecifierDependency.js +13 -2
  74. package/lib/dependencies/ImportContextDependency.js +1 -1
  75. package/lib/dependencies/ImportDependency.js +16 -2
  76. package/lib/dependencies/ImportMetaPlugin.js +39 -29
  77. package/lib/dependencies/ImportParserPlugin.js +4 -5
  78. package/lib/dependencies/ImportPhase.js +65 -22
  79. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +1 -1
  80. package/lib/esm/ModuleChunkFormatPlugin.js +1 -4
  81. package/lib/ids/HashedModuleIdsPlugin.js +21 -23
  82. package/lib/ids/OccurrenceChunkIdsPlugin.js +15 -11
  83. package/lib/ids/OccurrenceModuleIdsPlugin.js +15 -11
  84. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -4
  85. package/lib/javascript/CommonJsChunkFormatPlugin.js +1 -4
  86. package/lib/javascript/EnableChunkLoadingPlugin.js +1 -2
  87. package/lib/javascript/JavascriptModulesPlugin.js +38 -12
  88. package/lib/javascript/JavascriptParser.js +5 -3
  89. package/lib/json/JsonModulesPlugin.js +28 -21
  90. package/lib/library/AssignLibraryPlugin.js +1 -1
  91. package/lib/library/ExportPropertyLibraryPlugin.js +1 -1
  92. package/lib/library/ModuleLibraryPlugin.js +35 -13
  93. package/lib/library/SystemLibraryPlugin.js +1 -1
  94. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +22 -0
  95. package/lib/optimize/AggressiveSplittingPlugin.js +18 -31
  96. package/lib/optimize/ConcatenatedModule.js +6 -2
  97. package/lib/optimize/InnerGraphPlugin.js +11 -5
  98. package/lib/optimize/LimitChunkCountPlugin.js +22 -18
  99. package/lib/optimize/MergeDuplicateChunksPlugin.js +15 -12
  100. package/lib/optimize/MinChunkSizePlugin.js +20 -16
  101. package/lib/optimize/ModuleConcatenationPlugin.js +4 -1
  102. package/lib/optimize/RemoveEmptyChunksPlugin.js +0 -1
  103. package/lib/rules/RuleSetCompiler.js +1 -0
  104. package/lib/schemes/HttpUriPlugin.js +20 -11
  105. package/lib/schemes/VirtualUrlPlugin.js +77 -30
  106. package/lib/serialization/FileMiddleware.js +7 -7
  107. package/lib/sharing/ConsumeSharedModule.js +18 -1
  108. package/lib/sharing/ConsumeSharedPlugin.js +32 -25
  109. package/lib/sharing/ProvideSharedPlugin.js +29 -25
  110. package/lib/util/AppendOnlyStackedSet.js +22 -1
  111. package/lib/util/{propertyName.js → property.js} +26 -1
  112. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +148 -0
  113. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +54 -0
  114. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +105 -0
  115. package/lib/wasm-async/AsyncWebAssemblyParser.js +30 -6
  116. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +26 -2
  117. package/lib/web/FetchCompileAsyncWasmPlugin.js +23 -0
  118. package/lib/web/JsonpTemplatePlugin.js +1 -0
  119. package/lib/webpack.js +34 -4
  120. package/package.json +20 -18
  121. package/schemas/WebpackOptions.check.js +1 -1
  122. package/schemas/WebpackOptions.json +82 -22
  123. package/schemas/plugins/css/CssModuleGeneratorOptions.check.js +1 -1
  124. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  125. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  126. package/schemas/plugins/optimize/LimitChunkCountPlugin.json +1 -1
  127. package/schemas/plugins/schemes/VirtualUrlPlugin.check.js +1 -1
  128. package/schemas/plugins/schemes/VirtualUrlPlugin.json +8 -0
  129. package/types.d.ts +606 -150
  130. package/lib/util/create-schema-validation.js +0 -41
  131. package/lib/util/propertyAccess.js +0 -30
@@ -11,7 +11,6 @@ const Compilation = require("./Compilation");
11
11
  const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
12
12
  const ProgressPlugin = require("./ProgressPlugin");
13
13
  const SourceMapDevToolModuleOptionsPlugin = require("./SourceMapDevToolModuleOptionsPlugin");
14
- const createSchemaValidation = require("./util/create-schema-validation");
15
14
  const createHash = require("./util/createHash");
16
15
  const { dirname, relative } = require("./util/fs");
17
16
  const generateDebugId = require("./util/generateDebugId");
@@ -34,14 +33,6 @@ const { makePathsAbsolute } = require("./util/identifier");
34
33
  /** @typedef {import("./TemplatedPathPlugin").TemplatePath} TemplatePath */
35
34
  /** @typedef {import("./util/fs").OutputFileSystem} OutputFileSystem */
36
35
 
37
- const validate = createSchemaValidation(
38
- require("../schemas/plugins/SourceMapDevToolPlugin.check"),
39
- () => require("../schemas/plugins/SourceMapDevToolPlugin.json"),
40
- {
41
- name: "SourceMap DevTool Plugin",
42
- baseDataPath: "options"
43
- }
44
- );
45
36
  /**
46
37
  * @typedef {object} SourceMapTask
47
38
  * @property {Source} asset
@@ -141,8 +132,6 @@ class SourceMapDevToolPlugin {
141
132
  * @throws {Error} throws error, if got more than 1 arguments
142
133
  */
143
134
  constructor(options = {}) {
144
- validate(options);
145
-
146
135
  /** @type {undefined | null | false | string} */
147
136
  this.sourceMapFilename = options.filename;
148
137
  /** @type {false | TemplatePath} */
@@ -170,6 +159,19 @@ class SourceMapDevToolPlugin {
170
159
  * @returns {void}
171
160
  */
172
161
  apply(compiler) {
162
+ compiler.hooks.validate.tap(PLUGIN_NAME, () => {
163
+ compiler.validate(
164
+ () => require("../schemas/plugins/SourceMapDevToolPlugin.json"),
165
+ this.options,
166
+ {
167
+ name: "SourceMap DevTool Plugin",
168
+ baseDataPath: "options"
169
+ },
170
+ (options) =>
171
+ require("../schemas/plugins/SourceMapDevToolPlugin.check")(options)
172
+ );
173
+ });
174
+
173
175
  const outputFs =
174
176
  /** @type {OutputFileSystem} */
175
177
  (compiler.outputFileSystem);
package/lib/Stats.js CHANGED
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  /** @typedef {import("../declarations/WebpackOptions").StatsOptions} StatsOptions */
9
+ /** @typedef {import("../declarations/WebpackOptions").StatsValue} StatsValue */
9
10
  /** @typedef {import("./Compilation")} Compilation */
10
11
  /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsCompilation} StatsCompilation */
11
12
 
@@ -50,7 +51,7 @@ class Stats {
50
51
  }
51
52
 
52
53
  /**
53
- * @param {(string | boolean | StatsOptions)=} options stats options
54
+ * @param {StatsValue=} options stats options
54
55
  * @returns {StatsCompilation} json output
55
56
  */
56
57
  toJson(options) {
@@ -66,7 +67,7 @@ class Stats {
66
67
  }
67
68
 
68
69
  /**
69
- * @param {(string | boolean | StatsOptions)=} options stats options
70
+ * @param {StatsValue=} options stats options
70
71
  * @returns {string} string output
71
72
  */
72
73
  toString(options) {
@@ -138,10 +138,10 @@ const deprecated = (fn, message, code) => {
138
138
  /**
139
139
  * @param {TemplatePath} path the raw path
140
140
  * @param {PathData} data context data
141
- * @param {AssetInfo | undefined} assetInfo extra info about the asset (will be written to)
141
+ * @param {AssetInfo=} assetInfo extra info about the asset (will be written to)
142
142
  * @returns {string} the interpolated path
143
143
  */
144
- const replacePathVariables = (path, data, assetInfo) => {
144
+ const interpolate = (path, data, assetInfo) => {
145
145
  const chunkGraph = data.chunkGraph;
146
146
 
147
147
  /** @type {Map<string, Replacer>} */
@@ -392,9 +392,10 @@ class TemplatedPathPlugin {
392
392
  */
393
393
  apply(compiler) {
394
394
  compiler.hooks.compilation.tap(plugin, (compilation) => {
395
- compilation.hooks.assetPath.tap(plugin, replacePathVariables);
395
+ compilation.hooks.assetPath.tap(plugin, interpolate);
396
396
  });
397
397
  }
398
398
  }
399
399
 
400
400
  module.exports = TemplatedPathPlugin;
401
+ module.exports.interpolate = interpolate;
@@ -6,7 +6,6 @@
6
6
  "use strict";
7
7
 
8
8
  const { groupBy } = require("./util/ArrayHelpers");
9
- const createSchemaValidation = require("./util/create-schema-validation");
10
9
 
11
10
  /** @typedef {import("watchpack").TimeInfoEntries} TimeInfoEntries */
12
11
  /** @typedef {import("../declarations/plugins/WatchIgnorePlugin").WatchIgnorePluginOptions} WatchIgnorePluginOptions */
@@ -15,15 +14,6 @@ const createSchemaValidation = require("./util/create-schema-validation");
15
14
  /** @typedef {import("./util/fs").WatchMethod} WatchMethod */
16
15
  /** @typedef {import("./util/fs").Watcher} Watcher */
17
16
 
18
- const validate = createSchemaValidation(
19
- require("../schemas/plugins/WatchIgnorePlugin.check"),
20
- () => require("../schemas/plugins/WatchIgnorePlugin.json"),
21
- {
22
- name: "Watch Ignore Plugin",
23
- baseDataPath: "options"
24
- }
25
- );
26
-
27
17
  const IGNORE_TIME_ENTRY = "ignore";
28
18
 
29
19
  class IgnoringWatchFileSystem {
@@ -132,8 +122,8 @@ class WatchIgnorePlugin {
132
122
  * @param {WatchIgnorePluginOptions} options options
133
123
  */
134
124
  constructor(options) {
135
- validate(options);
136
- this.paths = options.paths;
125
+ /** @type {WatchIgnorePluginOptions} */
126
+ this.options = options;
137
127
  }
138
128
 
139
129
  /**
@@ -142,11 +132,23 @@ class WatchIgnorePlugin {
142
132
  * @returns {void}
143
133
  */
144
134
  apply(compiler) {
135
+ compiler.hooks.validate.tap(PLUGIN_NAME, () => {
136
+ compiler.validate(
137
+ () => require("../schemas/plugins/WatchIgnorePlugin.json"),
138
+ this.options,
139
+ {
140
+ name: "Watch Ignore Plugin",
141
+ baseDataPath: "options"
142
+ },
143
+ (options) =>
144
+ require("../schemas/plugins/WatchIgnorePlugin.check")(options)
145
+ );
146
+ });
145
147
  compiler.hooks.afterEnvironment.tap(PLUGIN_NAME, () => {
146
148
  compiler.watchFileSystem = new IgnoringWatchFileSystem(
147
149
  /** @type {WatchFileSystem} */
148
150
  (compiler.watchFileSystem),
149
- this.paths
151
+ this.options.paths
150
152
  );
151
153
  });
152
154
  }
@@ -442,7 +442,7 @@ class WebpackOptionsApply extends OptionsApply {
442
442
  const NormalModuleReplacementPlugin = require("./NormalModuleReplacementPlugin");
443
443
 
444
444
  // Override emitter that using `EventEmitter` to `EventTarget`
445
- // TODO webpack6 - migrate to `EventTarget` by default
445
+ // TODO webpack 6 - migrate to `EventTarget` by default
446
446
  new NormalModuleReplacementPlugin(/emitter(\.js)?$/, (result) => {
447
447
  if (
448
448
  /webpack[/\\]hot|webpack-dev-server[/\\]client|webpack-hot-middleware[/\\]client/.test(
@@ -487,15 +487,15 @@ class WebpackOptionsApply extends OptionsApply {
487
487
  }
488
488
 
489
489
  if (
490
- options.experiments.deferImport &&
491
490
  !(
492
491
  /** @type {typeof JavascriptParser & { __importPhasesExtended?: true }} */
493
492
  (JavascriptParser).__importPhasesExtended
494
- )
493
+ ) &&
494
+ (options.experiments.deferImport || options.experiments.sourceImport)
495
495
  ) {
496
496
  const importPhases = require("acorn-import-phases");
497
497
 
498
- JavascriptParser.extend(importPhases({ source: false }));
498
+ JavascriptParser.extend(importPhases({ source: true, defer: true }));
499
499
  /** @type {typeof JavascriptParser & { __importPhasesExtended?: true }} */
500
500
  (JavascriptParser).__importPhasesExtended = true;
501
501
  }
@@ -13,7 +13,6 @@ const {
13
13
  ASSET_MODULE_TYPE_SOURCE
14
14
  } = require("../ModuleTypeConstants");
15
15
  const { compareModulesByFullName } = require("../util/comparators");
16
- const createSchemaValidation = require("../util/create-schema-validation");
17
16
  const memoize = require("../util/memoize");
18
17
 
19
18
  /** @typedef {import("webpack-sources").Source} Source */
@@ -46,32 +45,6 @@ const generatorValidationOptions = {
46
45
  name: "Asset Modules Plugin",
47
46
  baseDataPath: "generator"
48
47
  };
49
- const validateGeneratorOptions = {
50
- asset: createSchemaValidation(
51
- require("../../schemas/plugins/asset/AssetGeneratorOptions.check"),
52
- () => getSchema("AssetGeneratorOptions"),
53
- generatorValidationOptions
54
- ),
55
- "asset/resource": createSchemaValidation(
56
- require("../../schemas/plugins/asset/AssetResourceGeneratorOptions.check"),
57
- () => getSchema("AssetResourceGeneratorOptions"),
58
- generatorValidationOptions
59
- ),
60
- "asset/inline": createSchemaValidation(
61
- require("../../schemas/plugins/asset/AssetInlineGeneratorOptions.check"),
62
- () => getSchema("AssetInlineGeneratorOptions"),
63
- generatorValidationOptions
64
- )
65
- };
66
-
67
- const validateParserOptions = createSchemaValidation(
68
- require("../../schemas/plugins/asset/AssetParserOptions.check"),
69
- () => getSchema("AssetParserOptions"),
70
- {
71
- name: "Asset Modules Plugin",
72
- baseDataPath: "parser"
73
- }
74
- );
75
48
 
76
49
  const getAssetGenerator = memoize(() => require("./AssetGenerator"));
77
50
  const getAssetParser = memoize(() => require("./AssetParser"));
@@ -135,7 +108,18 @@ class AssetModulesPlugin {
135
108
  normalModuleFactory.hooks.createParser
136
109
  .for(ASSET_MODULE_TYPE)
137
110
  .tap(PLUGIN_NAME, (parserOptions) => {
138
- validateParserOptions(parserOptions);
111
+ compiler.validate(
112
+ () => getSchema("AssetParserOptions"),
113
+ parserOptions,
114
+ {
115
+ name: "Asset Modules Plugin",
116
+ baseDataPath: "parser"
117
+ },
118
+ (options) =>
119
+ require("../../schemas/plugins/asset/AssetParserOptions.check")(
120
+ options
121
+ )
122
+ );
139
123
 
140
124
  let dataUrlCondition = parserOptions.dataUrlCondition;
141
125
  if (!dataUrlCondition || typeof dataUrlCondition === "object") {
@@ -186,7 +170,44 @@ class AssetModulesPlugin {
186
170
  normalModuleFactory.hooks.createGenerator
187
171
  .for(type)
188
172
  .tap(PLUGIN_NAME, (generatorOptions) => {
189
- validateGeneratorOptions[type](generatorOptions);
173
+ switch (type) {
174
+ case ASSET_MODULE_TYPE: {
175
+ compiler.validate(
176
+ () => getSchema("AssetGeneratorOptions"),
177
+ generatorOptions,
178
+ generatorValidationOptions,
179
+ (options) =>
180
+ require("../../schemas/plugins/asset/AssetGeneratorOptions.check")(
181
+ options
182
+ )
183
+ );
184
+ break;
185
+ }
186
+ case ASSET_MODULE_TYPE_RESOURCE: {
187
+ compiler.validate(
188
+ () => getSchema("AssetResourceGeneratorOptions"),
189
+ generatorOptions,
190
+ generatorValidationOptions,
191
+ (options) =>
192
+ require("../../schemas/plugins/asset/AssetResourceGeneratorOptions.check")(
193
+ options
194
+ )
195
+ );
196
+ break;
197
+ }
198
+ case ASSET_MODULE_TYPE_INLINE: {
199
+ compiler.validate(
200
+ () => getSchema("AssetInlineGeneratorOptions"),
201
+ generatorOptions,
202
+ generatorValidationOptions,
203
+ (options) =>
204
+ require("../../schemas/plugins/asset/AssetInlineGeneratorOptions.check")(
205
+ options
206
+ )
207
+ );
208
+ break;
209
+ }
210
+ }
190
211
 
191
212
  /** @type {undefined | AssetGeneratorDataUrl} */
192
213
  let dataUrl;
package/lib/cli.js CHANGED
@@ -603,6 +603,8 @@ const getExpectedValue = (argConfig) => {
603
603
 
604
604
  /** @typedef {null | string | number | boolean | RegExp | EnumValue | []} ParsedValue */
605
605
 
606
+ const DECIMAL_NUMBER_REGEXP = /^[+-]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?$/i;
607
+
606
608
  /**
607
609
  * @param {ArgumentConfig} argConfig processing instructions
608
610
  * @param {Value} value the value
@@ -622,7 +624,7 @@ const parseValueForArgumentConfig = (argConfig, value) => {
622
624
  break;
623
625
  case "number":
624
626
  if (typeof value === "number") return value;
625
- if (typeof value === "string" && /^[+-]?\d*(\.\d*)e\d+$/i) {
627
+ if (typeof value === "string" && DECIMAL_NUMBER_REGEXP.test(value)) {
626
628
  const n = Number(value);
627
629
  if (!Number.isNaN(n)) return n;
628
630
  }
@@ -58,8 +58,9 @@ const {
58
58
  /** @typedef {import("../../declarations/WebpackOptions").LibraryType} LibraryType */
59
59
  /** @typedef {import("../../declarations/WebpackOptions").Loader} Loader */
60
60
  /** @typedef {import("../../declarations/WebpackOptions").Mode} Mode */
61
+ /** @typedef {import("../../declarations/WebpackOptions").HashFunction} HashFunction */
61
62
  /** @typedef {import("../../declarations/WebpackOptions").HashSalt} HashSalt */
62
- /** @typedef {import("../../declarations/WebpackOptions").HashSalt} HashDigest */
63
+ /** @typedef {import("../../declarations/WebpackOptions").HashDigest} HashDigest */
63
64
  /** @typedef {import("../../declarations/WebpackOptions").HashDigestLength} HashDigestLength */
64
65
  /** @typedef {import("../../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
65
66
  /** @typedef {import("../../declarations/WebpackOptions").Node} WebpackNode */
@@ -363,6 +364,8 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
363
364
  /** @type {NonNullable<ExperimentsNormalized["futureDefaults"]>} */
364
365
  (options.experiments.futureDefaults);
365
366
 
367
+ F(options, "validate", () => !(futureDefaults === true && production));
368
+
366
369
  F(options, "cache", () =>
367
370
  development ? { type: /** @type {"memory"} */ ("memory") } : false
368
371
  );
@@ -405,11 +408,8 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
405
408
  hashSalt: /** @type {NonNullable<Output["hashSalt"]>} */ (
406
409
  options.output.hashSalt
407
410
  ),
408
- hashDigest: /** @type {NonNullable<Output["hashDigest"]>} */ (
409
- options.output.hashDigest
410
- ),
411
- hashDigestLength: /** @type {NonNullable<Output["hashDigestLength"]>} */ (
412
- options.output.hashDigestLength
411
+ hashFunction: /** @type {NonNullable<Output["hashFunction"]>} */ (
412
+ options.output.hashFunction
413
413
  ),
414
414
  syncWebAssembly:
415
415
  /** @type {NonNullable<ExperimentsNormalized["syncWebAssembly"]>} */
@@ -423,6 +423,9 @@ const applyWebpackOptionsDefaults = (options, compilerIndex) => {
423
423
  deferImport:
424
424
  /** @type {NonNullable<ExperimentsNormalized["deferImport"]>} */
425
425
  (options.experiments.deferImport),
426
+ sourceImport:
427
+ /** @type {NonNullable<ExperimentsNormalized["sourceImport"]>} */
428
+ (options.experiments.sourceImport),
426
429
  futureDefaults,
427
430
  isNode: targetProperties && targetProperties.node === true,
428
431
  uniqueName: /** @type {string} */ (options.output.uniqueName),
@@ -549,6 +552,7 @@ const applyExperimentsDefaults = (
549
552
  D(experiments, "buildHttp", undefined);
550
553
  D(experiments, "cacheUnaffected", experiments.futureDefaults);
551
554
  D(experiments, "deferImport", false);
555
+ D(experiments, "sourceImport", false);
552
556
  F(experiments, "css", () => (experiments.futureDefaults ? true : undefined));
553
557
 
554
558
  if (typeof experiments.buildHttp === "object") {
@@ -721,13 +725,14 @@ const applySnapshotDefaults = (snapshot, { production, futureDefaults }) => {
721
725
  * @param {object} options options
722
726
  * @param {boolean} options.futureDefaults is future defaults enabled
723
727
  * @param {boolean} options.deferImport is defer import enabled
728
+ * @param {boolean} options.sourceImport is import source enabled
724
729
  * @param {boolean} options.isNode is node target platform
725
730
  * @param {boolean} options.outputModule is output.module enabled
726
731
  * @returns {void}
727
732
  */
728
733
  const applyJavascriptParserOptionsDefaults = (
729
734
  parserOptions,
730
- { futureDefaults, deferImport, isNode, outputModule }
735
+ { futureDefaults, deferImport, sourceImport, isNode, outputModule }
731
736
  ) => {
732
737
  D(parserOptions, "unknownContextRequest", ".");
733
738
  D(parserOptions, "unknownContextRegExp", false);
@@ -749,6 +754,7 @@ const applyJavascriptParserOptionsDefaults = (
749
754
  D(parserOptions, "createRequire", isNode);
750
755
  D(parserOptions, "dynamicUrl", true);
751
756
  D(parserOptions, "deferImport", deferImport);
757
+ D(parserOptions, "sourceImport", sourceImport);
752
758
  if (futureDefaults) D(parserOptions, "exportsPresence", "error");
753
759
  };
754
760
 
@@ -789,11 +795,11 @@ const applyCssGeneratorOptionsDefaults = (
789
795
  * @param {string} options.uniqueName the unique name
790
796
  * @param {boolean} options.isNode is node target platform
791
797
  * @param {boolean} options.deferImport is defer import enabled
798
+ * @param {boolean} options.sourceImport is import source enabled
792
799
  * @param {TargetProperties | false} options.targetProperties target properties
793
800
  * @param {Mode | undefined} options.mode mode
794
801
  * @param {HashSalt} options.hashSalt hash salt
795
- * @param {HashDigest} options.hashDigest hash digest
796
- * @param {HashDigestLength} options.hashDigestLength hash digest length
802
+ * @param {HashFunction} options.hashFunction hash function
797
803
  * @param {boolean} options.outputModule is output.module enabled
798
804
  * @returns {void}
799
805
  */
@@ -801,8 +807,7 @@ const applyModuleDefaults = (
801
807
  module,
802
808
  {
803
809
  hashSalt,
804
- hashDigest,
805
- hashDigestLength,
810
+ hashFunction,
806
811
  cache,
807
812
  syncWebAssembly,
808
813
  asyncWebAssembly,
@@ -813,6 +818,7 @@ const applyModuleDefaults = (
813
818
  targetProperties,
814
819
  mode,
815
820
  deferImport,
821
+ sourceImport,
816
822
  outputModule
817
823
  }
818
824
  ) => {
@@ -872,6 +878,7 @@ const applyModuleDefaults = (
872
878
  {
873
879
  futureDefaults,
874
880
  deferImport,
881
+ sourceImport,
875
882
  isNode,
876
883
  outputModule
877
884
  }
@@ -990,6 +997,13 @@ const applyModuleDefaults = (
990
997
  localIdentHashSalt
991
998
  );
992
999
 
1000
+ D(
1001
+ /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]> | NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]> | NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
1002
+ (module.generator[type]),
1003
+ "localIdentHashFunction",
1004
+ hashFunction
1005
+ );
1006
+
993
1007
  D(
994
1008
  /** @type {NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_AUTO]> | NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]> | NonNullable<GeneratorOptionsByModuleTypeKnown[CSS_MODULE_TYPE_MODULE]>} */
995
1009
  (module.generator[type]),
@@ -1501,7 +1515,7 @@ const applyOutputDefaults = (
1501
1515
  output.module &&
1502
1516
  environment.dynamicImport
1503
1517
  ) {
1504
- return "universal";
1518
+ return "import";
1505
1519
  }
1506
1520
  }
1507
1521
  return false;
@@ -1527,7 +1541,7 @@ const applyOutputDefaults = (
1527
1541
  output.module &&
1528
1542
  environment.dynamicImportInWorker
1529
1543
  ) {
1530
- return "universal";
1544
+ return "import";
1531
1545
  }
1532
1546
  }
1533
1547
  return false;
@@ -364,7 +364,7 @@ const getNormalizedWebpackOptions = (config) => ({
364
364
  importFunctionName: output.importFunctionName,
365
365
  importMetaName: output.importMetaName,
366
366
  scriptType: output.scriptType,
367
- // TODO webpack6 remove `libraryTarget`/`auxiliaryComment`/`amdContainer`/etc in favor of the `library` option
367
+ // TODO webpack 6 remove `libraryTarget`/`auxiliaryComment`/`amdContainer`/etc in favor of the `library` option
368
368
  library: libraryBase && {
369
369
  type:
370
370
  output.libraryTarget !== undefined
@@ -416,6 +416,7 @@ const getNormalizedWebpackOptions = (config) => ({
416
416
  return result;
417
417
  }),
418
418
  parallelism: config.parallelism,
419
+ validate: config.validate,
419
420
  performance: optionalNestedConfig(config.performance, (performance) => {
420
421
  if (performance === false) return false;
421
422
  return {
@@ -599,7 +600,7 @@ const applyWebpackOptionsInterception = (options) => {
599
600
  };
600
601
  }
601
602
 
602
- // TODO webpack6 - remove compatibility logic and move `devtools` fully into `devtool` with multi-type support
603
+ // TODO webpack 6 - remove compatibility logic and move `devtools` fully into `devtool` with multi-type support
603
604
  let _devtool = options.devtool;
604
605
  /** @type {WebpackOptionsNormalized["devtool"]} */
605
606
  let cached;
@@ -5,7 +5,6 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const createSchemaValidation = require("../util/create-schema-validation");
9
8
  const memoize = require("../util/memoize");
10
9
  const ContainerEntryDependency = require("./ContainerEntryDependency");
11
10
  const ContainerEntryModuleFactory = require("./ContainerEntryModuleFactory");
@@ -20,15 +19,6 @@ const getModuleFederationPlugin = memoize(() =>
20
19
  require("./ModuleFederationPlugin")
21
20
  );
22
21
 
23
- const validate = createSchemaValidation(
24
- require("../../schemas/plugins/container/ContainerPlugin.check"),
25
- () => require("../../schemas/plugins/container/ContainerPlugin.json"),
26
- {
27
- name: "Container Plugin",
28
- baseDataPath: "options"
29
- }
30
- );
31
-
32
22
  const PLUGIN_NAME = "ContainerPlugin";
33
23
 
34
24
  class ContainerPlugin {
@@ -36,31 +26,8 @@ class ContainerPlugin {
36
26
  * @param {ContainerPluginOptions} options options
37
27
  */
38
28
  constructor(options) {
39
- validate(options);
40
-
41
- this._options = {
42
- name: options.name,
43
- shareScope: options.shareScope || "default",
44
- library: options.library || {
45
- type: "var",
46
- name: options.name
47
- },
48
- runtime: options.runtime,
49
- filename: options.filename || undefined,
50
- exposes: /** @type {ExposesList} */ (
51
- parseOptions(
52
- options.exposes,
53
- (item) => ({
54
- import: Array.isArray(item) ? item : [item],
55
- name: undefined
56
- }),
57
- (item) => ({
58
- import: Array.isArray(item.import) ? item.import : [item.import],
59
- name: item.name || undefined
60
- })
61
- )
62
- )
63
- };
29
+ /** @type {ContainerPluginOptions} */
30
+ this.options = options;
64
31
  }
65
32
 
66
33
  /**
@@ -69,25 +36,62 @@ class ContainerPlugin {
69
36
  * @returns {void}
70
37
  */
71
38
  apply(compiler) {
72
- const { name, exposes, shareScope, filename, library, runtime } =
73
- this._options;
39
+ compiler.hooks.validate.tap(PLUGIN_NAME, () => {
40
+ compiler.validate(
41
+ () => require("../../schemas/plugins/container/ContainerPlugin.json"),
42
+ this.options,
43
+ {
44
+ name: "Container Plugin",
45
+ baseDataPath: "options"
46
+ },
47
+ (options) =>
48
+ require("../../schemas/plugins/container/ContainerPlugin.check")(
49
+ options
50
+ )
51
+ );
52
+ });
53
+
54
+ const library = this.options.library || {
55
+ type: "var",
56
+ name: this.options.name
57
+ };
74
58
 
75
59
  if (!compiler.options.output.enabledLibraryTypes.includes(library.type)) {
76
60
  compiler.options.output.enabledLibraryTypes.push(library.type);
77
61
  }
78
62
 
63
+ const exposes = /** @type {ExposesList} */ (
64
+ parseOptions(
65
+ this.options.exposes,
66
+ (item) => ({
67
+ import: Array.isArray(item) ? item : [item],
68
+ name: undefined
69
+ }),
70
+ (item) => ({
71
+ import: Array.isArray(item.import) ? item.import : [item.import],
72
+ name: item.name || undefined
73
+ })
74
+ )
75
+ );
76
+
77
+ const shareScope = this.options.shareScope || "default";
78
+
79
79
  compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
80
80
  const hooks =
81
81
  getModuleFederationPlugin().getCompilationHooks(compilation);
82
- const dep = new ContainerEntryDependency(name, exposes, shareScope);
83
- dep.loc = { name };
82
+ const dep = new ContainerEntryDependency(
83
+ this.options.name,
84
+ exposes,
85
+ shareScope
86
+ );
87
+ dep.loc = { name: this.options.name };
84
88
  compilation.addEntry(
85
89
  compilation.options.context,
86
90
  dep,
87
91
  {
88
- name,
89
- filename,
90
- runtime,
92
+ name: this.options.name,
93
+ filename: this.options.filename,
94
+ runtime: this.options.runtime,
91
95
  library
92
96
  },
93
97
  (error) => {