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
@@ -9,6 +9,7 @@ const { RawSource } = require("webpack-sources");
9
9
  const { UsageState } = require("../ExportsInfo");
10
10
  const Generator = require("../Generator");
11
11
  const InitFragment = require("../InitFragment");
12
+ const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypesConstants");
12
13
  const RuntimeGlobals = require("../RuntimeGlobals");
13
14
  const Template = require("../Template");
14
15
  const ModuleDependency = require("../dependencies/ModuleDependency");
@@ -20,18 +21,17 @@ const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDe
20
21
  /** @typedef {import("../DependencyTemplates")} DependencyTemplates */
21
22
  /** @typedef {import("../Generator").GenerateContext} GenerateContext */
22
23
  /** @typedef {import("../Module")} Module */
24
+ /** @typedef {import("../Module").SourceTypes} SourceTypes */
23
25
  /** @typedef {import("../NormalModule")} NormalModule */
24
26
  /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
25
27
 
26
- const TYPES = new Set(["webassembly"]);
27
-
28
28
  class WebAssemblyJavascriptGenerator extends Generator {
29
29
  /**
30
30
  * @param {NormalModule} module fresh module
31
- * @returns {Set<string>} available types (do not mutate)
31
+ * @returns {SourceTypes} available types (do not mutate)
32
32
  */
33
33
  getTypes(module) {
34
- return TYPES;
34
+ return WEBASSEMBLY_TYPES;
35
35
  }
36
36
 
37
37
  /**
@@ -46,7 +46,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
46
46
  /**
47
47
  * @param {NormalModule} module module for which the code should be generated
48
48
  * @param {GenerateContext} generateContext context for generate
49
- * @returns {Source} generated code
49
+ * @returns {Source | null} generated code
50
50
  */
51
51
  generate(module, generateContext) {
52
52
  const {
@@ -44,9 +44,8 @@ class FetchCompileAsyncWasmPlugin {
44
44
 
45
45
  compilation.hooks.runtimeRequirementInTree
46
46
  .for(RuntimeGlobals.instantiateWasm)
47
- .tap("FetchCompileAsyncWasmPlugin", (chunk, set) => {
47
+ .tap("FetchCompileAsyncWasmPlugin", (chunk, set, { chunkGraph }) => {
48
48
  if (!isEnabledForChunk(chunk)) return;
49
- const chunkGraph = compilation.chunkGraph;
50
49
  if (
51
50
  !chunkGraph.hasModuleInGraph(
52
51
  chunk,
@@ -58,9 +58,8 @@ class FetchCompileWasmPlugin {
58
58
 
59
59
  compilation.hooks.runtimeRequirementInTree
60
60
  .for(RuntimeGlobals.ensureChunkHandlers)
61
- .tap(PLUGIN_NAME, (chunk, set) => {
61
+ .tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
62
62
  if (!isEnabledForChunk(chunk)) return;
63
- const chunkGraph = compilation.chunkGraph;
64
63
  if (
65
64
  !chunkGraph.hasModuleInGraph(
66
65
  chunk,
@@ -103,12 +103,6 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
103
103
  const withHmrManifest = this._runtimeRequirements.has(
104
104
  RuntimeGlobals.hmrDownloadManifest
105
105
  );
106
- const withPrefetch = this._runtimeRequirements.has(
107
- RuntimeGlobals.prefetchChunkHandlers
108
- );
109
- const withPreload = this._runtimeRequirements.has(
110
- RuntimeGlobals.preloadChunkHandlers
111
- );
112
106
  const withFetchPriority = this._runtimeRequirements.has(
113
107
  RuntimeGlobals.hasFetchPriority
114
108
  );
@@ -117,6 +111,12 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
117
111
  )}]`;
118
112
  const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
119
113
  const chunk = /** @type {Chunk} */ (this.chunk);
114
+ const withPrefetch =
115
+ this._runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers) &&
116
+ chunk.hasChildByOrder(chunkGraph, "prefetch", true, chunkHasJs);
117
+ const withPreload =
118
+ this._runtimeRequirements.has(RuntimeGlobals.preloadChunkHandlers) &&
119
+ chunk.hasChildByOrder(chunkGraph, "preload", true, chunkHasJs);
120
120
  const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
121
121
  const hasJsMatcher = compileBooleanMatcher(conditionMap);
122
122
  const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
package/package.json CHANGED
@@ -1,17 +1,16 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.94.0",
3
+ "version": "5.96.0",
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",
7
7
  "dependencies": {
8
- "@types/estree": "^1.0.5",
8
+ "@types/estree": "^1.0.6",
9
9
  "@webassemblyjs/ast": "^1.12.1",
10
10
  "@webassemblyjs/wasm-edit": "^1.12.1",
11
11
  "@webassemblyjs/wasm-parser": "^1.12.1",
12
- "acorn": "^8.7.1",
13
- "acorn-import-attributes": "^1.9.5",
14
- "browserslist": "^4.21.10",
12
+ "acorn": "^8.14.0",
13
+ "browserslist": "^4.24.0",
15
14
  "chrome-trace-event": "^1.0.2",
16
15
  "enhanced-resolve": "^5.17.1",
17
16
  "es-module-lexer": "^1.2.1",
@@ -35,16 +34,16 @@
35
34
  }
36
35
  },
37
36
  "devDependencies": {
38
- "@babel/core": "^7.24.7",
39
- "@babel/preset-react": "^7.24.7",
40
- "@eslint/js": "^9.5.0",
41
- "@stylistic/eslint-plugin": "^2.4.0",
37
+ "@babel/core": "^7.25.8",
38
+ "@babel/preset-react": "^7.25.7",
39
+ "@eslint/js": "^9.12.0",
40
+ "@stylistic/eslint-plugin": "^2.9.0",
42
41
  "@types/eslint-scope": "^3.7.7",
43
42
  "@types/glob-to-regexp": "^0.4.4",
44
43
  "@types/jest": "^29.5.11",
45
44
  "@types/mime-types": "^2.1.4",
46
45
  "@types/node": "^22.0.0",
47
- "assemblyscript": "^0.27.22",
46
+ "assemblyscript": "^0.27.30",
48
47
  "babel-loader": "^9.1.3",
49
48
  "benchmark": "^2.1.4",
50
49
  "bundle-loader": "^0.5.6",
@@ -53,16 +52,16 @@
53
52
  "core-js": "^3.6.5",
54
53
  "cspell": "^8.8.4",
55
54
  "css-loader": "^7.1.2",
56
- "date-fns": "^3.2.0",
55
+ "date-fns": "^4.0.0",
57
56
  "es5-ext": "^0.10.53",
58
57
  "es6-promise-polyfill": "^1.2.0",
59
- "eslint": "^9.5.0",
58
+ "eslint": "^9.12.0",
60
59
  "eslint-config-prettier": "^9.1.0",
61
60
  "eslint-plugin-jest": "^28.6.0",
62
61
  "eslint-plugin-jsdoc": "^48.10.1",
63
- "eslint-plugin-n": "^17.8.1",
62
+ "eslint-plugin-n": "^17.11.1",
64
63
  "eslint-plugin-prettier": "^5.1.3",
65
- "eslint-plugin-unicorn": "^55.0.0",
64
+ "eslint-plugin-unicorn": "^56.0.0",
66
65
  "file-loader": "^6.0.0",
67
66
  "fork-ts-checker-webpack-plugin": "^9.0.2",
68
67
  "globals": "^15.4.0",
@@ -83,10 +82,10 @@
83
82
  "lint-staged": "^15.2.5",
84
83
  "lodash": "^4.17.19",
85
84
  "lodash-es": "^4.17.15",
86
- "memfs": "^4.9.2",
85
+ "memfs": "^4.14.0",
87
86
  "mini-css-extract-plugin": "^2.9.0",
88
87
  "mini-svg-data-uri": "^1.2.3",
89
- "nyc": "^17.0.0",
88
+ "nyc": "^17.1.0",
90
89
  "open-cli": "^8.0.0",
91
90
  "prettier": "^3.2.1",
92
91
  "prettier-2": "npm:prettier@^2",
@@ -98,14 +97,14 @@
98
97
  "react-dom": "^18.3.1",
99
98
  "rimraf": "^3.0.2",
100
99
  "script-loader": "^0.7.2",
101
- "simple-git": "^3.25.0",
100
+ "simple-git": "^3.27.0",
102
101
  "strip-ansi": "^6.0.0",
103
102
  "style-loader": "^4.0.0",
104
- "terser": "^5.31.1",
103
+ "terser": "^5.34.1",
105
104
  "toml": "^3.0.0",
106
- "tooling": "webpack/tooling#v1.23.3",
105
+ "tooling": "webpack/tooling#v1.23.5",
107
106
  "ts-loader": "^9.5.1",
108
- "typescript": "^5.4.2",
107
+ "typescript": "^5.6.2",
109
108
  "url-loader": "^4.1.0",
110
109
  "wast-loader": "^1.12.1",
111
110
  "webassembly-feature": "1.3.0",