webpack 5.107.0 → 5.107.1

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 (47) hide show
  1. package/lib/BannerPlugin.js +3 -4
  2. package/lib/Chunk.js +21 -25
  3. package/lib/ChunkGroup.js +57 -15
  4. package/lib/Compilation.js +33 -11
  5. package/lib/EvalSourceMapDevToolPlugin.js +0 -1
  6. package/lib/ExportsInfo.js +30 -34
  7. package/lib/ExternalModule.js +15 -11
  8. package/lib/ExternalModuleFactoryPlugin.js +2 -1
  9. package/lib/Module.js +1 -1
  10. package/lib/ModuleNotFoundError.js +10 -0
  11. package/lib/ModuleSourceTypeConstants.js +24 -22
  12. package/lib/NormalModule.js +106 -46
  13. package/lib/NormalModuleFactory.js +38 -26
  14. package/lib/RuntimePlugin.js +1 -1
  15. package/lib/SourceMapDevToolPlugin.js +250 -49
  16. package/lib/Template.js +1 -1
  17. package/lib/TemplatedPathPlugin.js +22 -4
  18. package/lib/asset/AssetBytesGenerator.js +6 -6
  19. package/lib/asset/AssetGenerator.js +14 -14
  20. package/lib/asset/AssetModulesPlugin.js +3 -7
  21. package/lib/asset/AssetSourceGenerator.js +6 -6
  22. package/lib/css/CssModulesPlugin.js +2 -2
  23. package/lib/dependencies/CommonJsImportsParserPlugin.js +108 -1
  24. package/lib/dependencies/CssUrlDependency.js +3 -2
  25. package/lib/dependencies/HarmonyDetectionParserPlugin.js +21 -1
  26. package/lib/dependencies/HtmlScriptSrcDependency.js +264 -25
  27. package/lib/dependencies/HtmlSourceDependency.js +3 -2
  28. package/lib/html/HtmlModulesPlugin.js +1 -5
  29. package/lib/html/walkHtmlTokens.js +641 -125
  30. package/lib/index.js +2 -0
  31. package/lib/javascript/JavascriptModulesPlugin.js +2 -2
  32. package/lib/optimize/SideEffectsFlagPlugin.js +1 -2
  33. package/lib/optimize/SplitChunksPlugin.js +4 -4
  34. package/lib/runtime/AutoPublicPathRuntimeModule.js +3 -3
  35. package/lib/runtime/GetChunkFilenameRuntimeModule.js +5 -5
  36. package/lib/sharing/ConsumeSharedPlugin.js +2 -8
  37. package/lib/sharing/ProvideSharedPlugin.js +4 -4
  38. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +1 -2
  39. package/package.json +3 -3
  40. package/schemas/WebpackOptions.check.js +1 -1
  41. package/schemas/WebpackOptions.json +11 -9
  42. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  43. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  44. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  45. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  46. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  47. package/types.d.ts +355 -144
package/lib/index.js CHANGED
@@ -41,6 +41,8 @@ const memoize = require("./util/memoize");
41
41
  /** @typedef {import("./Compilation").AssetInfo} AssetInfo */
42
42
  /** @typedef {import("./Compilation").EntryOptions} EntryOptions */
43
43
  /** @typedef {import("./Compilation").PathData} PathData */
44
+ /** @typedef {import("./Compilation").PathDataChunk} PathDataChunk */
45
+ /** @typedef {import("./Compilation").PathDataModule} PathDataModule */
44
46
  /** @typedef {import("./CodeGenerationResults")} CodeGenerationResults */
45
47
  /** @typedef {import("./Entrypoint")} Entrypoint */
46
48
  /** @typedef {import("./ExternalModuleFactoryPlugin").ExternalItemFunctionCallback} ExternalItemFunctionCallback */
@@ -83,7 +83,7 @@ const JavascriptParser = require("./JavascriptParser");
83
83
  /** @typedef {import("../Module").CodeGenerationResultData} CodeGenerationResultData */
84
84
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
85
85
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
86
- /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
86
+ /** @typedef {import("../Chunk").ChunkFilenameTemplate} ChunkFilenameTemplate */
87
87
  /** @typedef {import("../errors/WebpackError")} WebpackError */
88
88
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
89
89
  /** @typedef {import("../util/Hash")} Hash */
@@ -732,7 +732,7 @@ class JavascriptModulesPlugin {
732
732
  * Gets chunk filename template.
733
733
  * @param {Chunk} chunk chunk
734
734
  * @param {OutputOptions} outputOptions output options
735
- * @returns {TemplatePath} used filename template
735
+ * @returns {ChunkFilenameTemplate} used filename template
736
736
  */
737
737
  static getChunkFilenameTemplate(chunk, outputOptions) {
738
738
  if (chunk.filenameTemplate) {
@@ -27,7 +27,6 @@ const { CompilerHintNotationRegExp } = require("../util/magicComment");
27
27
  /** @typedef {import("../Module")} Module */
28
28
  /** @typedef {import("../Module").BuildMeta} BuildMeta */
29
29
  /** @typedef {import("../ModuleGraphConnection")} ModuleGraphConnection */
30
- /** @typedef {import("../NormalModuleFactory").ModuleSettings} ModuleSettings */
31
30
  /** @typedef {import("../javascript/JavascriptParser")} JavascriptParser */
32
31
  /** @typedef {import("../javascript/JavascriptParser").Range} Range */
33
32
 
@@ -134,7 +133,7 @@ class SideEffectsFlagPlugin {
134
133
  return module;
135
134
  });
136
135
  normalModuleFactory.hooks.module.tap(PLUGIN_NAME, (module, data) => {
137
- const settings = /** @type {ModuleSettings} */ (data.settings);
136
+ const settings = data.settings;
138
137
  if (typeof settings.sideEffects === "boolean") {
139
138
  if (module.factoryMeta === undefined) {
140
139
  module.factoryMeta = {};
@@ -32,7 +32,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
32
32
  /** @typedef {import("../Module")} Module */
33
33
  /** @typedef {import("../Module").SourceType} SourceType */
34
34
  /** @typedef {import("../ModuleGraph")} ModuleGraph */
35
- /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
35
+ /** @typedef {import("../Chunk").ChunkFilenameTemplate} ChunkFilenameTemplate */
36
36
  /** @typedef {import("../util/deterministicGrouping").GroupedItems<Module>} DeterministicGroupingGroupedItemsForModule */
37
37
  /** @typedef {import("../util/deterministicGrouping").Options<Module>} DeterministicGroupingOptionsForModule */
38
38
  /** @typedef {import("../util/deterministicGrouping").Sizes} Sizes */
@@ -78,7 +78,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
78
78
  * @property {CountOfChunk=} minChunks
79
79
  * @property {CountOfRequest=} maxAsyncRequests
80
80
  * @property {CountOfRequest=} maxInitialRequests
81
- * @property {TemplatePath=} filename
81
+ * @property {ChunkFilenameTemplate=} filename
82
82
  * @property {string=} idHint
83
83
  * @property {string=} automaticNameDelimiter
84
84
  * @property {boolean=} reuseExistingChunk
@@ -101,7 +101,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
101
101
  * @property {CountOfChunk} minChunks
102
102
  * @property {CountOfRequest} maxAsyncRequests
103
103
  * @property {CountOfRequest} maxInitialRequests
104
- * @property {TemplatePath=} filename
104
+ * @property {ChunkFilenameTemplate=} filename
105
105
  * @property {string} idHint
106
106
  * @property {string} automaticNameDelimiter
107
107
  * @property {boolean} reuseExistingChunk
@@ -163,7 +163,7 @@ const MinMaxSizeWarning = require("./MinMaxSizeWarning");
163
163
  * @property {CountOfRequest} maxAsyncRequests
164
164
  * @property {CountOfRequest} maxInitialRequests
165
165
  * @property {boolean} hidePathInfo
166
- * @property {TemplatePath=} filename
166
+ * @property {ChunkFilenameTemplate=} filename
167
167
  * @property {string} automaticNameDelimiter
168
168
  * @property {GetCacheGroups} getCacheGroups
169
169
  * @property {GetNameFn} getName
@@ -26,14 +26,14 @@ class AutoPublicPathRuntimeModule extends RuntimeModule {
26
26
  const compilation = /** @type {Compilation} */ (this.compilation);
27
27
  const { scriptType, importMetaName, path, environment } =
28
28
  compilation.outputOptions;
29
+ const chunk = /** @type {Chunk} */ (this.chunk);
29
30
  const chunkName = compilation.getPath(
30
31
  JavascriptModulesPlugin.getChunkFilenameTemplate(
31
- /** @type {Chunk} */
32
- (this.chunk),
32
+ chunk,
33
33
  compilation.outputOptions
34
34
  ),
35
35
  {
36
- chunk: this.chunk,
36
+ chunk,
37
37
  contentHashType: "javascript"
38
38
  }
39
39
  );
@@ -14,14 +14,14 @@ const { first } = require("../util/SetHelpers");
14
14
  /** @typedef {import("../ChunkGraph")} ChunkGraph */
15
15
  /** @typedef {import("../Compilation")} Compilation */
16
16
  /** @typedef {import("../Compilation").HashWithLengthFunction} HashWithLengthFunction */
17
- /** @typedef {import("../TemplatedPathPlugin").TemplatePath} TemplatePath */
17
+ /** @typedef {import("../Chunk").ChunkFilenameTemplate} ChunkFilenameTemplate */
18
18
 
19
19
  class GetChunkFilenameRuntimeModule extends RuntimeModule {
20
20
  /**
21
21
  * @param {string} contentType the contentType to use the content hash for
22
22
  * @param {string} name kind of filename
23
23
  * @param {string} global function name to be assigned
24
- * @param {(chunk: Chunk) => TemplatePath | false} getFilenameForChunk functor to get the filename or function
24
+ * @param {(chunk: Chunk) => ChunkFilenameTemplate | false} getFilenameForChunk functor to get the filename or function
25
25
  * @param {boolean} allChunks when false, only async chunks are included
26
26
  */
27
27
  constructor(contentType, name, global, getFilenameForChunk, allChunks) {
@@ -30,7 +30,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
30
30
  this.contentType = contentType;
31
31
  /** @type {string} */
32
32
  this.global = global;
33
- /** @type {(chunk: Chunk) => TemplatePath | false} */
33
+ /** @type {(chunk: Chunk) => ChunkFilenameTemplate | false} */
34
34
  this.getFilenameForChunk = getFilenameForChunk;
35
35
  /** @type {boolean} */
36
36
  this.allChunks = allChunks;
@@ -49,7 +49,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
49
49
  const chunk = /** @type {Chunk} */ (this.chunk);
50
50
  const { runtimeTemplate } = compilation;
51
51
 
52
- /** @type {Map<string | TemplatePath, Set<Chunk>>} */
52
+ /** @type {Map<ChunkFilenameTemplate, Set<Chunk>>} */
53
53
  const chunkFilenames = new Map();
54
54
  let maxChunks = 0;
55
55
  /** @type {string | undefined} */
@@ -126,7 +126,7 @@ class GetChunkFilenameRuntimeModule extends RuntimeModule {
126
126
 
127
127
  /**
128
128
  * @param {Chunk} c the chunk
129
- * @param {string | TemplatePath} chunkFilename the filename template for the chunk
129
+ * @param {ChunkFilenameTemplate} chunkFilename the filename template for the chunk
130
130
  * @returns {void}
131
131
  */
132
132
  const addStaticUrl = (c, chunkFilename) => {
@@ -356,15 +356,9 @@ class ConsumeSharedPlugin {
356
356
  ) {
357
357
  return Promise.resolve();
358
358
  }
359
- const options = resolvedConsumes.get(
360
- /** @type {string} */ (resource)
361
- );
359
+ const options = resolvedConsumes.get(resource);
362
360
  if (options !== undefined) {
363
- return createConsumeSharedModule(
364
- context,
365
- /** @type {string} */ (resource),
366
- options
367
- );
361
+ return createConsumeSharedModule(context, resource, options);
368
362
  }
369
363
  return Promise.resolve();
370
364
  }
@@ -169,7 +169,7 @@ class ProvideSharedPlugin {
169
169
  normalModuleFactory.hooks.module.tap(
170
170
  PLUGIN_NAME,
171
171
  (module, { resource, resourceResolveData }, resolveData) => {
172
- if (resolvedProvideMap.has(/** @type {string} */ (resource))) {
172
+ if (resolvedProvideMap.has(resource)) {
173
173
  return module;
174
174
  }
175
175
  const { request } = resolveData;
@@ -179,7 +179,7 @@ class ProvideSharedPlugin {
179
179
  provideSharedModule(
180
180
  request,
181
181
  config,
182
- /** @type {string} */ (resource),
182
+ resource,
183
183
  resourceResolveData
184
184
  );
185
185
  resolveData.cacheable = false;
@@ -189,12 +189,12 @@ class ProvideSharedPlugin {
189
189
  if (request.startsWith(prefix)) {
190
190
  const remainder = request.slice(prefix.length);
191
191
  provideSharedModule(
192
- /** @type {string} */ (resource),
192
+ resource,
193
193
  {
194
194
  ...config,
195
195
  shareKey: config.shareKey + remainder
196
196
  },
197
- /** @type {string} */ (resource),
197
+ resource,
198
198
  resourceResolveData
199
199
  );
200
200
  resolveData.cacheable = false;
@@ -216,8 +216,7 @@ class AsyncWebAssemblyModulesPlugin {
216
216
  PLUGIN_NAME,
217
217
  (createData, resolveData) =>
218
218
  new AsyncWasmModule({
219
- .../** @type {NormalModuleCreateData & { type: string }} */
220
- (createData),
219
+ ...createData,
221
220
  phase: resolveData.phase
222
221
  })
223
222
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.107.0",
3
+ "version": "5.107.1",
4
4
  "description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
5
5
  "homepage": "https://github.com/webpack/webpack",
6
6
  "bugs": "https://github.com/webpack/webpack/issues",
@@ -34,7 +34,7 @@
34
34
  "prelint": "yarn setup",
35
35
  "lint": "yarn lint:code && yarn lint:special && yarn lint:types && yarn lint:types-test && yarn lint:types-benchmark && yarn lint:types-module-test && yarn lint:types-hot && yarn fmt:check && yarn lint:spellcheck",
36
36
  "lint:code": "node node_modules/eslint/bin/eslint.js --cache .",
37
- "lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
37
+ "lint:special": "node node_modules/tooling/lockfile-lint && node node_modules/tooling/schemas-lint && node node_modules/tooling/inherit-types && node node_modules/tooling/format-schemas && node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node tooling/generate-html-entities.js && node node_modules/tooling/compile-to-definitions && node node_modules/tooling/precompile-schemas && node node_modules/tooling/generate-types --no-template-literals",
38
38
  "lint:types": "tsc",
39
39
  "lint:types-test": "tsc -p tsconfig.types.test.json",
40
40
  "lint:types-benchmark": "tsc -p tsconfig.types.benchmark.json",
@@ -48,7 +48,7 @@
48
48
  "fmt:base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
49
49
  "fix": "yarn fix:code && yarn fix:special && yarn fmt",
50
50
  "fix:code": "yarn lint:code --fix",
51
- "fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
51
+ "fix:special": "node node_modules/tooling/inherit-types --write && node node_modules/tooling/format-schemas --write && node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node tooling/generate-html-entities.js --write && node node_modules/tooling/compile-to-definitions --write && node node_modules/tooling/precompile-schemas --write && node node_modules/tooling/generate-types --no-template-literals --write",
52
52
  "build:examples": "cd examples && node buildAll.js",
53
53
  "benchmark": "node --max-old-space-size=6144 --experimental-vm-modules --trace-deprecation --hash-seed=1 --random-seed=1 --no-opt --predictable --predictable-gc-schedule --interpreted-frames-native-stack --allow-natives-syntax --expose-gc --no-concurrent-sweeping ./test/BenchmarkTestCases.benchmark.mjs",
54
54
  "pretest": "yarn lint",