webpack 5.84.1 → 5.85.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.

Potentially problematic release.


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

Files changed (121) hide show
  1. package/lib/AsyncDependenciesBlock.js +2 -2
  2. package/lib/AutomaticPrefetchPlugin.js +1 -0
  3. package/lib/BannerPlugin.js +4 -0
  4. package/lib/CacheFacade.js +4 -0
  5. package/lib/ChunkGroup.js +5 -1
  6. package/lib/CleanPlugin.js +30 -7
  7. package/lib/CompatibilityPlugin.js +1 -1
  8. package/lib/Compilation.js +1 -1
  9. package/lib/Compiler.js +1 -1
  10. package/lib/ContextModuleFactory.js +1 -1
  11. package/lib/DllModuleFactory.js +1 -1
  12. package/lib/HookWebpackError.js +1 -1
  13. package/lib/IgnoreErrorModuleFactory.js +1 -1
  14. package/lib/Module.js +21 -9
  15. package/lib/ModuleFactory.js +1 -1
  16. package/lib/ModuleTypeConstants.js +2 -1
  17. package/lib/NormalModuleFactory.js +1 -1
  18. package/lib/NormalModuleReplacementPlugin.js +4 -2
  19. package/lib/NullFactory.js +1 -1
  20. package/lib/RecordIdsPlugin.js +4 -4
  21. package/lib/RuntimeModule.js +5 -5
  22. package/lib/RuntimePlugin.js +4 -0
  23. package/lib/RuntimeTemplate.js +2 -2
  24. package/lib/SelfModuleFactory.js +1 -1
  25. package/lib/Template.js +1 -1
  26. package/lib/UseStrictPlugin.js +4 -0
  27. package/lib/WarnDeprecatedOptionPlugin.js +7 -0
  28. package/lib/WatchIgnorePlugin.js +4 -0
  29. package/lib/WebpackOptionsApply.js +2 -1
  30. package/lib/asset/AssetGenerator.js +7 -2
  31. package/lib/asset/AssetModulesPlugin.js +7 -1
  32. package/lib/asset/AssetParser.js +4 -1
  33. package/lib/asset/RawDataUrlModule.js +5 -3
  34. package/lib/async-modules/InferAsyncModulesPlugin.js +1 -1
  35. package/lib/cache/PackFileCacheStrategy.js +7 -1
  36. package/lib/config/defaults.js +38 -10
  37. package/lib/config/normalization.js +2 -1
  38. package/lib/container/ContainerEntryModule.js +4 -0
  39. package/lib/container/ContainerEntryModuleFactory.js +1 -1
  40. package/lib/container/FallbackDependency.js +7 -0
  41. package/lib/container/FallbackItemDependency.js +3 -0
  42. package/lib/container/FallbackModule.js +4 -0
  43. package/lib/container/FallbackModuleFactory.js +1 -1
  44. package/lib/container/RemoteModule.js +4 -0
  45. package/lib/container/RemoteRuntimeModule.js +1 -0
  46. package/lib/container/RemoteToExternalDependency.js +3 -0
  47. package/lib/dependencies/CommonJsPlugin.js +14 -12
  48. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +1 -1
  49. package/lib/dependencies/HarmonyExports.js +3 -1
  50. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +16 -5
  51. package/lib/dependencies/HarmonyImportSpecifierDependency.js +75 -6
  52. package/lib/dependencies/WorkerPlugin.js +25 -1
  53. package/lib/esm/ModuleChunkFormatPlugin.js +13 -5
  54. package/lib/esm/ModuleChunkLoadingPlugin.js +9 -0
  55. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +10 -8
  56. package/lib/hmr/LazyCompilationPlugin.js +1 -1
  57. package/lib/ids/ChunkModuleIdRangePlugin.js +11 -0
  58. package/lib/ids/DeterministicChunkIdsPlugin.js +11 -2
  59. package/lib/ids/DeterministicModuleIdsPlugin.js +11 -7
  60. package/lib/ids/HashedModuleIdsPlugin.js +8 -1
  61. package/lib/ids/IdHelpers.js +6 -0
  62. package/lib/ids/NamedChunkIdsPlugin.js +13 -1
  63. package/lib/ids/NamedModuleIdsPlugin.js +14 -3
  64. package/lib/ids/OccurrenceChunkIdsPlugin.js +6 -2
  65. package/lib/ids/SyncModuleIdsPlugin.js +2 -2
  66. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +1 -1
  67. package/lib/javascript/BasicEvaluatedExpression.js +12 -1
  68. package/lib/javascript/ChunkHelpers.js +2 -2
  69. package/lib/javascript/EnableChunkLoadingPlugin.js +4 -0
  70. package/lib/javascript/JavascriptModulesPlugin.js +24 -19
  71. package/lib/javascript/JavascriptParser.js +42 -18
  72. package/lib/javascript/StartupHelpers.js +1 -1
  73. package/lib/json/JsonGenerator.js +7 -5
  74. package/lib/json/JsonParser.js +1 -1
  75. package/lib/library/AbstractLibraryPlugin.js +4 -0
  76. package/lib/library/AssignLibraryPlugin.js +6 -4
  77. package/lib/library/ExportPropertyLibraryPlugin.js +4 -1
  78. package/lib/library/ModuleLibraryPlugin.js +6 -3
  79. package/lib/library/SystemLibraryPlugin.js +1 -0
  80. package/lib/library/UmdLibraryPlugin.js +4 -0
  81. package/lib/node/CommonJsChunkLoadingPlugin.js +17 -2
  82. package/lib/node/NodeTemplatePlugin.js +10 -2
  83. package/lib/node/NodeWatchFileSystem.js +1 -1
  84. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +4 -1
  85. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -0
  86. package/lib/node/ReadFileCompileWasmPlugin.js +19 -2
  87. package/lib/node/RequireChunkLoadingRuntimeModule.js +4 -1
  88. package/lib/runtime/AsyncModuleRuntimeModule.js +1 -1
  89. package/lib/runtime/AutoPublicPathRuntimeModule.js +5 -1
  90. package/lib/runtime/BaseUriRuntimeModule.js +5 -1
  91. package/lib/runtime/EnsureChunkRuntimeModule.js +3 -0
  92. package/lib/runtime/GetChunkFilenameRuntimeModule.js +35 -16
  93. package/lib/runtime/GetTrustedTypesPolicyRuntimeModule.js +1 -1
  94. package/lib/runtime/LoadScriptRuntimeModule.js +1 -1
  95. package/lib/runtime/PublicPathRuntimeModule.js +5 -0
  96. package/lib/runtime/StartupChunkDependenciesPlugin.js +15 -0
  97. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +3 -0
  98. package/lib/runtime/StartupEntrypointRuntimeModule.js +3 -0
  99. package/lib/sharing/ProvideSharedModuleFactory.js +1 -1
  100. package/lib/util/createHash.js +1 -1
  101. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
  102. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +9 -1
  103. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +13 -3
  104. package/lib/wasm-async/AsyncWebAssemblyModulesPlugin.js +19 -2
  105. package/lib/wasm-async/AsyncWebAssemblyParser.js +3 -0
  106. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +25 -1
  107. package/lib/wasm-sync/WasmFinalizeExportsPlugin.js +14 -5
  108. package/lib/wasm-sync/WebAssemblyGenerator.js +18 -5
  109. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +1 -1
  110. package/lib/wasm-sync/WebAssemblyModulesPlugin.js +12 -1
  111. package/lib/wasm-sync/WebAssemblyParser.js +9 -2
  112. package/lib/wasm-sync/WebAssemblyUtils.js +1 -1
  113. package/lib/web/FetchCompileAsyncWasmPlugin.js +9 -0
  114. package/lib/web/FetchCompileWasmPlugin.js +19 -2
  115. package/lib/web/JsonpChunkLoadingPlugin.js +9 -0
  116. package/lib/webworker/ImportScriptsChunkLoadingPlugin.js +9 -0
  117. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +1 -1
  118. package/package.json +1 -1
  119. package/schemas/WebpackOptions.check.js +1 -1
  120. package/schemas/WebpackOptions.json +12 -0
  121. package/types.d.ts +189 -141
@@ -9,6 +9,7 @@ const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
9
9
  const RuntimeGlobals = require("../RuntimeGlobals");
10
10
  const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRuntimeModule");
11
11
 
12
+ /** @typedef {import("../Chunk")} Chunk */
12
13
  /** @typedef {import("../Compiler")} Compiler */
13
14
 
14
15
  class FetchCompileAsyncWasmPlugin {
@@ -22,6 +23,10 @@ class FetchCompileAsyncWasmPlugin {
22
23
  "FetchCompileAsyncWasmPlugin",
23
24
  compilation => {
24
25
  const globalWasmLoading = compilation.outputOptions.wasmLoading;
26
+ /**
27
+ * @param {Chunk} chunk chunk
28
+ * @returns {boolean} true, if wasm loading is enabled for the chunk
29
+ */
25
30
  const isEnabledForChunk = chunk => {
26
31
  const options = chunk.getEntryOptions();
27
32
  const wasmLoading =
@@ -30,6 +35,10 @@ class FetchCompileAsyncWasmPlugin {
30
35
  : globalWasmLoading;
31
36
  return wasmLoading === "fetch";
32
37
  };
38
+ /**
39
+ * @param {string} path path to the wasm file
40
+ * @returns {string} code to load the wasm file
41
+ */
33
42
  const generateLoadBinaryCode = path =>
34
43
  `fetch(${RuntimeGlobals.publicPath} + ${path})`;
35
44
 
@@ -9,15 +9,24 @@ const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
9
9
  const RuntimeGlobals = require("../RuntimeGlobals");
10
10
  const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRuntimeModule");
11
11
 
12
+ /** @typedef {import("../Chunk")} Chunk */
12
13
  /** @typedef {import("../Compiler")} Compiler */
13
14
 
14
15
  // TODO webpack 6 remove
15
16
 
16
17
  const PLUGIN_NAME = "FetchCompileWasmPlugin";
17
18
 
19
+ /**
20
+ * @typedef {Object} FetchCompileWasmPluginOptions
21
+ * @property {boolean} [mangleImports] mangle imports
22
+ */
23
+
18
24
  class FetchCompileWasmPlugin {
19
- constructor(options) {
20
- this.options = options || {};
25
+ /**
26
+ * @param {FetchCompileWasmPluginOptions} [options] options
27
+ */
28
+ constructor(options = {}) {
29
+ this.options = options;
21
30
  }
22
31
 
23
32
  /**
@@ -28,6 +37,10 @@ class FetchCompileWasmPlugin {
28
37
  apply(compiler) {
29
38
  compiler.hooks.thisCompilation.tap(PLUGIN_NAME, compilation => {
30
39
  const globalWasmLoading = compilation.outputOptions.wasmLoading;
40
+ /**
41
+ * @param {Chunk} chunk chunk
42
+ * @returns {boolean} true, if wasm loading is enabled for the chunk
43
+ */
31
44
  const isEnabledForChunk = chunk => {
32
45
  const options = chunk.getEntryOptions();
33
46
  const wasmLoading =
@@ -36,6 +49,10 @@ class FetchCompileWasmPlugin {
36
49
  : globalWasmLoading;
37
50
  return wasmLoading === "fetch";
38
51
  };
52
+ /**
53
+ * @param {string} path path to the wasm file
54
+ * @returns {string} code to load the wasm file
55
+ */
39
56
  const generateLoadBinaryCode = path =>
40
57
  `fetch(${RuntimeGlobals.publicPath} + ${path})`;
41
58
 
@@ -8,6 +8,7 @@
8
8
  const RuntimeGlobals = require("../RuntimeGlobals");
9
9
  const JsonpChunkLoadingRuntimeModule = require("./JsonpChunkLoadingRuntimeModule");
10
10
 
11
+ /** @typedef {import("../Chunk")} Chunk */
11
12
  /** @typedef {import("../Compiler")} Compiler */
12
13
 
13
14
  class JsonpChunkLoadingPlugin {
@@ -21,6 +22,10 @@ class JsonpChunkLoadingPlugin {
21
22
  "JsonpChunkLoadingPlugin",
22
23
  compilation => {
23
24
  const globalChunkLoading = compilation.outputOptions.chunkLoading;
25
+ /**
26
+ * @param {Chunk} chunk chunk
27
+ * @returns {boolean} true, if wasm loading is enabled for the chunk
28
+ */
24
29
  const isEnabledForChunk = chunk => {
25
30
  const options = chunk.getEntryOptions();
26
31
  const chunkLoading =
@@ -30,6 +35,10 @@ class JsonpChunkLoadingPlugin {
30
35
  return chunkLoading === "jsonp";
31
36
  };
32
37
  const onceForChunkSet = new WeakSet();
38
+ /**
39
+ * @param {Chunk} chunk chunk
40
+ * @param {Set<string>} set runtime requirements
41
+ */
33
42
  const handler = (chunk, set) => {
34
43
  if (onceForChunkSet.has(chunk)) return;
35
44
  onceForChunkSet.add(chunk);
@@ -9,6 +9,7 @@ const RuntimeGlobals = require("../RuntimeGlobals");
9
9
  const StartupChunkDependenciesPlugin = require("../runtime/StartupChunkDependenciesPlugin");
10
10
  const ImportScriptsChunkLoadingRuntimeModule = require("./ImportScriptsChunkLoadingRuntimeModule");
11
11
 
12
+ /** @typedef {import("../Chunk")} Chunk */
12
13
  /** @typedef {import("../Compiler")} Compiler */
13
14
 
14
15
  class ImportScriptsChunkLoadingPlugin {
@@ -26,6 +27,10 @@ class ImportScriptsChunkLoadingPlugin {
26
27
  "ImportScriptsChunkLoadingPlugin",
27
28
  compilation => {
28
29
  const globalChunkLoading = compilation.outputOptions.chunkLoading;
30
+ /**
31
+ * @param {Chunk} chunk chunk
32
+ * @returns {boolean} true, if wasm loading is enabled for the chunk
33
+ */
29
34
  const isEnabledForChunk = chunk => {
30
35
  const options = chunk.getEntryOptions();
31
36
  const chunkLoading =
@@ -35,6 +40,10 @@ class ImportScriptsChunkLoadingPlugin {
35
40
  return chunkLoading === "import-scripts";
36
41
  };
37
42
  const onceForChunkSet = new WeakSet();
43
+ /**
44
+ * @param {Chunk} chunk chunk
45
+ * @param {Set<string>} set runtime requirements
46
+ */
38
47
  const handler = (chunk, set) => {
39
48
  if (onceForChunkSet.has(chunk)) return;
40
49
  onceForChunkSet.add(chunk);
@@ -47,7 +47,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
47
47
  );
48
48
  const rootOutputDir = getUndoPath(
49
49
  outputName,
50
- this.compilation.outputOptions.path,
50
+ /** @type {string} */ (this.compilation.outputOptions.path),
51
51
  false
52
52
  );
53
53
  return `${RuntimeGlobals.baseURI} = self.location + ${JSON.stringify(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.84.1",
3
+ "version": "5.85.1",
4
4
  "author": "Tobias Koppers @sokra",
5
5
  "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.",
6
6
  "license": "MIT",