webpack 5.108.3 → 5.109.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 (191) hide show
  1. package/lib/APIPlugin.js +48 -29
  2. package/lib/CacheFacade.js +8 -0
  3. package/lib/ChunkGroup.js +1 -0
  4. package/lib/CompatibilityPlugin.js +31 -29
  5. package/lib/Compilation.js +50 -8
  6. package/lib/ConstPlugin.js +11 -11
  7. package/lib/ContextModule.js +239 -6
  8. package/lib/ContextModuleFactory.js +139 -14
  9. package/lib/DefinePlugin.js +396 -101
  10. package/lib/Entrypoint.js +1 -1
  11. package/lib/ExportsInfoApiPlugin.js +2 -2
  12. package/lib/ExternalModule.js +107 -5
  13. package/lib/ExternalModuleFactoryPlugin.js +20 -1
  14. package/lib/FileSystemInfo.js +130 -74
  15. package/lib/FlagDependencyExportsPlugin.js +55 -8
  16. package/lib/HotModuleReplacementPlugin.js +18 -15
  17. package/lib/LazyBarrel.js +30 -3
  18. package/lib/Module.js +3 -0
  19. package/lib/ModuleFilenameHelpers.js +2 -2
  20. package/lib/ModuleTypeConstants.js +8 -1
  21. package/lib/MultiCompiler.js +13 -2
  22. package/lib/MultiWatching.js +1 -0
  23. package/lib/NodeStuffPlugin.js +51 -33
  24. package/lib/NormalModule.js +169 -405
  25. package/lib/NormalModuleFactory.js +76 -2
  26. package/lib/ProgressPlugin.js +211 -119
  27. package/lib/ProvidePlugin.js +2 -2
  28. package/lib/RuntimeGlobals.js +47 -0
  29. package/lib/RuntimePlugin.js +33 -0
  30. package/lib/RuntimeTemplate.js +304 -16
  31. package/lib/UseStrictPlugin.js +1 -1
  32. package/lib/WebpackIsIncludedPlugin.js +1 -1
  33. package/lib/WebpackOptionsApply.js +24 -19
  34. package/lib/asset/AssetGenerator.js +110 -28
  35. package/lib/asset/AssetModulesPlugin.js +92 -2
  36. package/lib/asset/WebManifestGenerator.js +164 -0
  37. package/lib/asset/WebManifestParser.js +130 -0
  38. package/lib/async-modules/AwaitDependenciesInitFragment.js +14 -4
  39. package/lib/async-modules/isGeneratorLowered.js +26 -0
  40. package/lib/cache/PackFileCacheStrategy.js +9 -3
  41. package/lib/config/browserslistTargetHandler.js +40 -0
  42. package/lib/config/defaults.js +222 -32
  43. package/lib/config/normalization.js +26 -0
  44. package/lib/config/target.js +9 -1
  45. package/lib/css/CssGenerator.js +73 -73
  46. package/lib/css/CssLoadingRuntimeModule.js +5 -1
  47. package/lib/css/CssModulesPlugin.js +92 -53
  48. package/lib/css/CssParser.js +843 -302
  49. package/lib/css/syntax.js +1219 -483
  50. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -6
  51. package/lib/dependencies/AMDPlugin.js +2 -2
  52. package/lib/dependencies/AMDRequireDependenciesBlockParserPlugin.js +13 -13
  53. package/lib/dependencies/CommonJsDependencyHelpers.js +39 -0
  54. package/lib/dependencies/CommonJsExportsDependency.js +47 -2
  55. package/lib/dependencies/CommonJsExportsParserPlugin.js +10 -10
  56. package/lib/dependencies/CommonJsImportsParserPlugin.js +18 -18
  57. package/lib/dependencies/CommonJsPlugin.js +2 -2
  58. package/lib/dependencies/CommonJsRequireDependency.js +26 -1
  59. package/lib/dependencies/CommonJsSelfReferenceDependency.js +32 -1
  60. package/lib/dependencies/ContextDependencyHelpers.js +3 -3
  61. package/lib/dependencies/CreateRequireParserPlugin.js +6 -6
  62. package/lib/dependencies/CssIcssExportDependency.js +190 -87
  63. package/lib/dependencies/CssUrlDependency.js +35 -4
  64. package/lib/dependencies/ExternalModuleInitFragmentDependency.js +2 -2
  65. package/lib/dependencies/HarmonyCompatibilityDependency.js +32 -14
  66. package/lib/dependencies/HarmonyDetectionParserPlugin.js +43 -13
  67. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +7 -19
  68. package/lib/dependencies/HarmonyImportDependency.js +12 -1
  69. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +34 -107
  70. package/lib/dependencies/HarmonyImportGuard.js +192 -20
  71. package/lib/dependencies/HarmonyModulesPlugin.js +6 -0
  72. package/lib/dependencies/HarmonyTopLevelThisParserPlugin.js +1 -1
  73. package/lib/dependencies/HtmlEntryDependency.js +797 -172
  74. package/lib/dependencies/HtmlSourceDependency.js +26 -0
  75. package/lib/dependencies/ImportDependency.js +43 -1
  76. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +31 -18
  77. package/lib/dependencies/ImportMetaContextPlugin.js +38 -7
  78. package/lib/dependencies/ImportMetaGlobDependency.js +81 -0
  79. package/lib/dependencies/ImportMetaGlobDependencyParserPlugin.js +78 -0
  80. package/lib/dependencies/ImportMetaGlobHelpers.js +660 -0
  81. package/lib/dependencies/ImportMetaPlugin.js +532 -180
  82. package/lib/dependencies/ImportMetaResolveDependency.js +90 -0
  83. package/lib/dependencies/ImportParserPlugin.js +87 -26
  84. package/lib/dependencies/ImportPhase.js +10 -8
  85. package/lib/dependencies/LoaderPlugin.js +5 -1
  86. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  87. package/lib/dependencies/RequireEnsureDependenciesBlockParserPlugin.js +3 -6
  88. package/lib/dependencies/RequireIncludeDependencyParserPlugin.js +4 -11
  89. package/lib/dependencies/SystemPlugin.js +2 -4
  90. package/lib/dependencies/TopLevelAwaitDependency.js +93 -0
  91. package/lib/dependencies/URLDependency.js +141 -21
  92. package/lib/dependencies/{WorkerPlugin.js → WorkerAndWorkletPlugin.js} +324 -112
  93. package/lib/dependencies/WorkerDependency.js +86 -18
  94. package/lib/dependencies/WorkletDependency.js +278 -0
  95. package/lib/dll/DelegatedModuleFactoryPlugin.js +19 -0
  96. package/lib/errors/EnvironmentNotSupportAsyncWarning.js +1 -1
  97. package/lib/errors/LoaderLoadingError.js +20 -0
  98. package/lib/errors/ModuleParseError.js +39 -22
  99. package/lib/errors/NodeStuffInWebError.js +1 -1
  100. package/lib/esm/ModuleChunkFormatPlugin.js +47 -14
  101. package/lib/esm/ModuleChunkLoadingPlugin.js +8 -1
  102. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +29 -1
  103. package/lib/hmr/lazyCompilationBackend.js +32 -8
  104. package/lib/html/HtmlGenerator.js +940 -91
  105. package/lib/html/HtmlModule.js +3 -2
  106. package/lib/html/HtmlModulesPlugin.js +625 -170
  107. package/lib/html/HtmlParser.js +812 -340
  108. package/lib/html/favicon.svg +1 -0
  109. package/lib/html/syntax.js +2116 -834
  110. package/lib/ids/IdHelpers.js +1 -1
  111. package/lib/index.js +6 -0
  112. package/lib/javascript/ArrayPushCallbackChunkFormatPlugin.js +4 -5
  113. package/lib/javascript/BasicEvaluatedExpression.js +366 -48
  114. package/lib/javascript/JavascriptGenerator.js +197 -49
  115. package/lib/javascript/JavascriptModulesPlugin.js +178 -24
  116. package/lib/javascript/JavascriptParser.js +711 -355
  117. package/lib/javascript/JavascriptParserHelpers.js +3 -6
  118. package/lib/javascript/syntax.js +4380 -0
  119. package/lib/library/ModuleLibraryPlugin.js +38 -1
  120. package/lib/loaders/LoaderRunner.js +714 -0
  121. package/lib/loaders/loadLoader.js +100 -0
  122. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +19 -0
  123. package/lib/node/ReadFileCompileWasmPlugin.js +14 -0
  124. package/lib/optimize/ConcatenatedModule.js +120 -16
  125. package/lib/optimize/FlagIncludedChunksPlugin.js +13 -3
  126. package/lib/optimize/InnerGraphPlugin.js +50 -30
  127. package/lib/optimize/ModuleConcatenationPlugin.js +69 -3
  128. package/lib/optimize/SideEffectsFlagPlugin.js +86 -43
  129. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +15 -0
  130. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +24 -13
  131. package/lib/prefetch/ResourceHintPlugin.js +663 -0
  132. package/lib/prefetch/ResourceHintRuntimeModule.js +149 -0
  133. package/lib/prefetch/StartupAssetHintRuntimeModule.js +210 -0
  134. package/lib/prefetch/parseResourceHintOptions.js +103 -0
  135. package/lib/rules/RuleSetCompiler.js +114 -0
  136. package/lib/runtime/AsyncModuleGeneratorRuntimeModule.js +56 -0
  137. package/lib/runtime/AsyncModuleRuntimeModule.js +24 -8
  138. package/lib/runtime/AutoPublicPathRuntimeModule.js +7 -1
  139. package/lib/runtime/CommonJsWrapRuntimeModule.js +37 -0
  140. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +59 -0
  141. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +204 -8
  142. package/lib/runtime/SetAnonymousDefaultNameRuntimeModule.js +4 -1
  143. package/lib/schemes/HttpUriPlugin.js +40 -1
  144. package/lib/schemes/VirtualUrlPlugin.js +1 -2
  145. package/lib/serialization/FileMiddleware.js +29 -3
  146. package/lib/stats/DefaultStatsFactoryPlugin.js +32 -3
  147. package/lib/stats/DefaultStatsPresetPlugin.js +2 -0
  148. package/lib/stats/DefaultStatsPrinterPlugin.js +12 -2
  149. package/lib/stats/StatsFactory.js +15 -8
  150. package/lib/url/URLParserPlugin.js +98 -19
  151. package/lib/util/AsyncQueue.js +122 -72
  152. package/lib/util/LocConverter.js +9 -8
  153. package/lib/util/SetHelpers.js +1 -1
  154. package/lib/util/SourceProcessor.js +41 -28
  155. package/lib/util/StackedMap.js +122 -48
  156. package/lib/util/binarySearchBounds.js +2 -2
  157. package/lib/util/concatenate.js +40 -14
  158. package/lib/util/createHooksRegistry.js +13 -5
  159. package/lib/util/dataURL.js +2 -2
  160. package/lib/util/deterministicGrouping.js +7 -5
  161. package/lib/util/formatSize.js +6 -2
  162. package/lib/util/globUtils.js +710 -0
  163. package/lib/util/identifier.js +23 -6
  164. package/lib/util/implicitTypeLoaderFallback.js +62 -0
  165. package/lib/util/internalSerializables.js +88 -71
  166. package/lib/util/magicComment.js +121 -25
  167. package/lib/util/numberHash.js +2 -2
  168. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +24 -18
  169. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +33 -22
  170. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +79 -16
  171. package/lib/web/FetchCompileAsyncWasmPlugin.js +19 -0
  172. package/lib/web/FetchCompileWasmPlugin.js +14 -0
  173. package/lib/web/JsonpChunkLoadingRuntimeModule.js +2 -0
  174. package/lib/webpack.js +65 -0
  175. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +3 -0
  176. package/module.d.ts +21 -0
  177. package/package.json +14 -13
  178. package/schemas/WebpackOptions.check.js +1 -1
  179. package/schemas/WebpackOptions.json +759 -36
  180. package/schemas/plugins/HtmlParserOptions.check.js +1 -1
  181. package/schemas/plugins/ProgressPlugin.check.js +1 -1
  182. package/schemas/plugins/ProgressPlugin.json +17 -1
  183. package/schemas/plugins/container/ContainerReferencePlugin.check.js +1 -1
  184. package/schemas/plugins/container/ContainerReferencePlugin.json +1 -0
  185. package/schemas/plugins/container/ExternalsType.check.js +1 -1
  186. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  187. package/schemas/plugins/container/ModuleFederationPlugin.json +1 -0
  188. package/schemas/plugins/css/CssAutoOrModuleParserOptions.check.js +1 -1
  189. package/schemas/plugins/css/CssModuleParserOptions.check.js +1 -1
  190. package/schemas/plugins/css/CssParserOptions.check.js +1 -1
  191. package/types.d.ts +1300 -325
@@ -54,13 +54,15 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
54
54
  const compilation = /** @type {Compilation} */ (this.compilation);
55
55
  const chunk = /** @type {Chunk} */ (this.chunk);
56
56
  const { outputOptions, runtimeTemplate } = compilation;
57
+ // Opt-in fallback to non-streaming when the server serves wasm with a wrong MIME type.
58
+ const streamingFallback = outputOptions.wasmStreamingFallback;
57
59
  const fn = RuntimeGlobals.instantiateWasm;
58
60
  const wasmModuleSrcPath = compilation.getPath(
59
61
  JSON.stringify(outputOptions.webassemblyModuleFilename),
60
62
  {
61
63
  hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
62
64
  hashWithLength: (length) =>
63
- `" + ${RuntimeGlobals.getFullHash}}().slice(0, ${length}) + "`,
65
+ `" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
64
66
  module: {
65
67
  id: '" + wasmModuleId + "',
66
68
  hash: '" + wasmModuleHash + "',
@@ -107,28 +109,37 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
107
109
  ? this.generateBeforeInstantiateStreaming()
108
110
  : ""
109
111
  ),
110
- Template.indent([
111
- "return WebAssembly.instantiateStreaming(res, importsObj)",
112
- Template.indent([
113
- ".then(",
114
- Template.indent([
115
- `${runtimeTemplate.returningFunction(
116
- "Object.assign(exports, res.instance.exports)",
117
- "res"
118
- )},`,
119
- runtimeTemplate.basicFunction("e", [
120
- 'if(res.headers.get("Content-Type") !== "application/wasm") {',
112
+ Template.indent(
113
+ streamingFallback
114
+ ? [
115
+ "return WebAssembly.instantiateStreaming(res, importsObj)",
121
116
  Template.indent([
122
- 'console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n", e);',
123
- "return fallback();"
124
- ]),
125
- "}",
126
- "throw e;"
127
- ])
128
- ]),
129
- ");"
130
- ])
131
- ]),
117
+ ".then(",
118
+ Template.indent([
119
+ `${runtimeTemplate.returningFunction(
120
+ "Object.assign(exports, res.instance.exports)",
121
+ "res"
122
+ )},`,
123
+ runtimeTemplate.basicFunction("e", [
124
+ 'if(res.headers.get("Content-Type") !== "application/wasm") {',
125
+ Template.indent([
126
+ 'console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n", e);',
127
+ "return fallback();"
128
+ ]),
129
+ "}",
130
+ "throw e;"
131
+ ])
132
+ ]),
133
+ ");"
134
+ ])
135
+ ]
136
+ : [
137
+ `return WebAssembly.instantiateStreaming(res, importsObj).then(${runtimeTemplate.returningFunction(
138
+ "Object.assign(exports, res.instance.exports)",
139
+ "res"
140
+ )});`
141
+ ]
142
+ ),
132
143
  "}",
133
144
  "return fallback();"
134
145
  ]),
@@ -284,12 +284,16 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
284
284
  mangleImports
285
285
  ? `{ ${JSON.stringify(WebAssemblyUtils.MANGLED_MODULE)}: ${content} }`
286
286
  : content;
287
+ // Opt-in fallback to non-streaming when the server serves wasm with a wrong MIME type.
288
+ const streamingFallback = outputOptions.wasmStreamingFallback;
289
+ const streamingMimeFallbackWarning =
290
+ 'console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n", e);';
287
291
  const wasmModuleSrcPath = compilation.getPath(
288
292
  JSON.stringify(outputOptions.webassemblyModuleFilename),
289
293
  {
290
294
  hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
291
295
  hashWithLength: (length) =>
292
- `" + ${RuntimeGlobals.getFullHash}}().slice(0, ${length}) + "`,
296
+ `" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
293
297
  module: {
294
298
  id: '" + wasmModuleId + "',
295
299
  hash: `" + ${JSON.stringify(
@@ -360,24 +364,83 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
360
364
  `var req = ${this.generateLoadBinaryCode(wasmModuleSrcPath)};`,
361
365
  "var promise;",
362
366
  this.supportsStreaming
363
- ? Template.asString([
364
- "if(importObject && typeof importObject.then === 'function' && typeof WebAssembly.compileStreaming === 'function') {",
365
- Template.indent([
366
- "promise = Promise.all([WebAssembly.compileStreaming(req), importObject]).then(function(items) {",
367
+ ? streamingFallback
368
+ ? Template.asString([
369
+ "if(importObject && typeof importObject.then === 'function' && typeof WebAssembly.compileStreaming === 'function') {",
367
370
  Template.indent([
368
- `return WebAssembly.instantiate(items[0], ${createImportObject(
369
- "items[1]"
370
- )});`
371
+ "promise = req.then(function(res) {",
372
+ Template.indent([
373
+ "return Promise.all([WebAssembly.compileStreaming(res), importObject]).then(function(items) {",
374
+ Template.indent([
375
+ `return WebAssembly.instantiate(items[0], ${createImportObject(
376
+ "items[1]"
377
+ )});`
378
+ ]),
379
+ "}, function(e) {",
380
+ Template.indent([
381
+ 'if(res.headers.get("Content-Type") !== "application/wasm") {',
382
+ Template.indent([
383
+ streamingMimeFallbackWarning,
384
+ "return Promise.all([res.arrayBuffer().then(function(bytes) { return WebAssembly.compile(bytes); }), importObject]).then(function(items) {",
385
+ Template.indent([
386
+ `return WebAssembly.instantiate(items[0], ${createImportObject(
387
+ "items[1]"
388
+ )});`
389
+ ]),
390
+ "});"
391
+ ]),
392
+ "}",
393
+ "throw e;"
394
+ ]),
395
+ "});"
396
+ ]),
397
+ "});"
371
398
  ]),
372
- "});"
373
- ]),
374
- "} else if(typeof WebAssembly.instantiateStreaming === 'function') {",
375
- Template.indent([
376
- `promise = WebAssembly.instantiateStreaming(req, ${createImportObject(
377
- "importObject"
378
- )});`
399
+ "} else if(typeof WebAssembly.instantiateStreaming === 'function') {",
400
+ Template.indent([
401
+ "promise = req.then(function(res) {",
402
+ Template.indent([
403
+ `return WebAssembly.instantiateStreaming(res, ${createImportObject(
404
+ "importObject"
405
+ )}).then(undefined, function(e) {`,
406
+ Template.indent([
407
+ 'if(res.headers.get("Content-Type") !== "application/wasm") {',
408
+ Template.indent([
409
+ streamingMimeFallbackWarning,
410
+ "return res.arrayBuffer().then(function(bytes) {",
411
+ Template.indent([
412
+ `return WebAssembly.instantiate(bytes, ${createImportObject(
413
+ "importObject"
414
+ )});`
415
+ ]),
416
+ "});"
417
+ ]),
418
+ "}",
419
+ "throw e;"
420
+ ]),
421
+ "});"
422
+ ]),
423
+ "});"
424
+ ])
425
+ ])
426
+ : Template.asString([
427
+ "if(importObject && typeof importObject.then === 'function' && typeof WebAssembly.compileStreaming === 'function') {",
428
+ Template.indent([
429
+ "promise = Promise.all([WebAssembly.compileStreaming(req), importObject]).then(function(items) {",
430
+ Template.indent([
431
+ `return WebAssembly.instantiate(items[0], ${createImportObject(
432
+ "items[1]"
433
+ )});`
434
+ ]),
435
+ "});"
436
+ ]),
437
+ "} else if(typeof WebAssembly.instantiateStreaming === 'function') {",
438
+ Template.indent([
439
+ `promise = WebAssembly.instantiateStreaming(req, ${createImportObject(
440
+ "importObject"
441
+ )});`
442
+ ])
379
443
  ])
380
- ])
381
444
  : Template.asString([
382
445
  "if(importObject && typeof importObject.then === 'function') {",
383
446
  Template.indent([
@@ -7,12 +7,21 @@
7
7
 
8
8
  const { WEBASSEMBLY_MODULE_TYPE_ASYNC } = require("../ModuleTypeConstants");
9
9
  const RuntimeGlobals = require("../RuntimeGlobals");
10
+ const { getPresentKinds } = require("../TemplatedPathPlugin");
10
11
  const AsyncWasmCompileRuntimeModule = require("../wasm-async/AsyncWasmCompileRuntimeModule");
11
12
  const AsyncWasmLoadingRuntimeModule = require("../wasm-async/AsyncWasmLoadingRuntimeModule");
12
13
 
13
14
  /** @typedef {import("../Chunk")} Chunk */
14
15
  /** @typedef {import("../Compiler")} Compiler */
15
16
 
17
+ /**
18
+ * The wasm runtime inlines `[fullhash]` as a runtime `getFullHash()` call, so
19
+ * that runtime module must be requested (`[hash]` is the per-module hash here).
20
+ * @param {string} filename `output.webassemblyModuleFilename`
21
+ * @returns {boolean} whether it references the compilation `[fullhash]`
22
+ */
23
+ const usesFullHash = (filename) => getPresentKinds(filename).has("fullhash");
24
+
16
25
  const PLUGIN_NAME = "FetchCompileAsyncWasmPlugin";
17
26
 
18
27
  /**
@@ -65,6 +74,11 @@ class FetchCompileAsyncWasmPlugin {
65
74
  return;
66
75
  }
67
76
  set.add(RuntimeGlobals.publicPath);
77
+ if (
78
+ usesFullHash(compilation.outputOptions.webassemblyModuleFilename)
79
+ ) {
80
+ set.add(RuntimeGlobals.getFullHash);
81
+ }
68
82
  compilation.addRuntimeModule(
69
83
  chunk,
70
84
  new AsyncWasmLoadingRuntimeModule({
@@ -87,6 +101,11 @@ class FetchCompileAsyncWasmPlugin {
87
101
  return;
88
102
  }
89
103
  set.add(RuntimeGlobals.publicPath);
104
+ if (
105
+ usesFullHash(compilation.outputOptions.webassemblyModuleFilename)
106
+ ) {
107
+ set.add(RuntimeGlobals.getFullHash);
108
+ }
90
109
  compilation.addRuntimeModule(
91
110
  chunk,
92
111
  new AsyncWasmCompileRuntimeModule({
@@ -7,11 +7,20 @@
7
7
 
8
8
  const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants");
9
9
  const RuntimeGlobals = require("../RuntimeGlobals");
10
+ const { getPresentKinds } = require("../TemplatedPathPlugin");
10
11
  const WasmChunkLoadingRuntimeModule = require("../wasm-sync/WasmChunkLoadingRuntimeModule");
11
12
 
12
13
  /** @typedef {import("../Chunk")} Chunk */
13
14
  /** @typedef {import("../Compiler")} Compiler */
14
15
 
16
+ /**
17
+ * The wasm runtime inlines `[fullhash]` as a runtime `getFullHash()` call, so
18
+ * that runtime module must be requested (`[hash]` is the per-module hash here).
19
+ * @param {string} filename `output.webassemblyModuleFilename`
20
+ * @returns {boolean} whether it references the compilation `[fullhash]`
21
+ */
22
+ const usesFullHash = (filename) => getPresentKinds(filename).has("fullhash");
23
+
15
24
  /**
16
25
  * Options that influence how synchronous WebAssembly modules are emitted for
17
26
  * the fetch-based wasm loading runtime.
@@ -81,6 +90,11 @@ class FetchCompileWasmPlugin {
81
90
  }
82
91
  set.add(RuntimeGlobals.moduleCache);
83
92
  set.add(RuntimeGlobals.publicPath);
93
+ if (
94
+ usesFullHash(compilation.outputOptions.webassemblyModuleFilename)
95
+ ) {
96
+ set.add(RuntimeGlobals.getFullHash);
97
+ }
84
98
  compilation.addRuntimeModule(
85
99
  chunk,
86
100
  new WasmChunkLoadingRuntimeModule({
@@ -175,6 +175,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
175
175
  "error.name = 'ChunkLoadError';",
176
176
  "error.type = errorType;",
177
177
  "error.request = realSrc;",
178
+ "error.event = event;",
178
179
  "installedChunkData[1](error);"
179
180
  ]),
180
181
  "}"
@@ -315,6 +316,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
315
316
  "error.name = 'ChunkLoadError';",
316
317
  "error.type = errorType;",
317
318
  "error.request = realSrc;",
319
+ "error.event = event;",
318
320
  "reject(error);"
319
321
  ]),
320
322
  "}"
package/lib/webpack.js CHANGED
@@ -37,6 +37,51 @@ const memoize = require("./util/memoize");
37
37
  /** @typedef {(compiler: Compiler) => void} WebpackPluginInstanceApplyFunction */
38
38
 
39
39
  const getValidateSchema = memoize(() => require("./validateSchema"));
40
+ const getProgressPlugin = memoize(() => require("./ProgressPlugin"));
41
+
42
+ /**
43
+ * Whether core should auto-apply progress, from `infrastructureLogging.progress`.
44
+ * Like other bundlers, `"auto"` shows it in a TTY and stays silent in CI; `true`
45
+ * forces it on (unless logging is off), `false` disables it.
46
+ * @param {WebpackOptionsNormalizedWithDefaults} options resolved options
47
+ * @returns {boolean} true when progress should be applied by default
48
+ */
49
+ const isDefaultProgressEnabled = (options) => {
50
+ const infrastructureLogging = options.infrastructureLogging;
51
+ if (!infrastructureLogging) return false;
52
+ const progress = infrastructureLogging.progress;
53
+ if (!progress) return false;
54
+ if (
55
+ infrastructureLogging.level === "none" ||
56
+ /** @type {EXPECTED_ANY} */ (infrastructureLogging.level) === false
57
+ ) {
58
+ return false;
59
+ }
60
+ return progress === "auto" ? !infrastructureLogging.appendOnly : true;
61
+ };
62
+
63
+ /**
64
+ * @param {WebpackOptionsNormalizedWithDefaults} options resolved options
65
+ * @returns {boolean} true when the user already added a ProgressPlugin
66
+ */
67
+ const hasUserProgressPlugin = (options) =>
68
+ Array.isArray(options.plugins) &&
69
+ options.plugins.some((p) => p instanceof getProgressPlugin());
70
+
71
+ /**
72
+ * Auto-applies a default `ProgressPlugin` driven by `infrastructureLogging.progress`,
73
+ * unless the user already added one. `hasUserPlugin` is lazy so the plugin scan
74
+ * only runs when progress is actually enabled.
75
+ * @param {Compiler | MultiCompiler} compiler compiler to apply to
76
+ * @param {WebpackOptionsNormalizedWithDefaults} options options deciding whether progress is on
77
+ * @param {() => boolean} hasUserPlugin whether a ProgressPlugin is already present
78
+ * @returns {void}
79
+ */
80
+ const applyDefaultProgressPlugin = (compiler, options, hasUserPlugin) => {
81
+ if (!isDefaultProgressEnabled(options) || hasUserPlugin()) return;
82
+ const ProgressPlugin = getProgressPlugin();
83
+ new ProgressPlugin({ progressBar: "auto" }).apply(compiler);
84
+ };
40
85
 
41
86
  /**
42
87
  * Defines the callback callback.
@@ -69,6 +114,18 @@ const createMultiCompiler = (childOptions, options) => {
69
114
  );
70
115
  }
71
116
  }
117
+ const firstOptions =
118
+ compilers.length > 0 &&
119
+ /** @type {WebpackOptionsNormalizedWithDefaults} */ (compilers[0].options);
120
+ if (firstOptions) {
121
+ applyDefaultProgressPlugin(compiler, firstOptions, () =>
122
+ compilers.some((c) =>
123
+ hasUserProgressPlugin(
124
+ /** @type {WebpackOptionsNormalizedWithDefaults} */ (c.options)
125
+ )
126
+ )
127
+ );
128
+ }
72
129
  return compiler;
73
130
  };
74
131
 
@@ -110,6 +167,14 @@ const createCompiler = (rawOptions, compilerIndex) => {
110
167
  if (resolvedDefaultOptions.platform) {
111
168
  compiler.platform = resolvedDefaultOptions.platform;
112
169
  }
170
+ // Child compilers skip this; the MultiCompiler applies one aggregated reporter.
171
+ if (compilerIndex === undefined) {
172
+ const resolvedOptions =
173
+ /** @type {WebpackOptionsNormalizedWithDefaults} */ (options);
174
+ applyDefaultProgressPlugin(compiler, resolvedOptions, () =>
175
+ hasUserProgressPlugin(resolvedOptions)
176
+ );
177
+ }
113
178
  if (options.validate) {
114
179
  compiler.hooks.validate.call();
115
180
  }
@@ -171,6 +171,9 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
171
171
  "",
172
172
  `var chunkLoadingGlobal = ${runtimeTemplate.assignOr(chunkLoadingGlobalExpr, "[]")};`,
173
173
  "var parentChunkLoadingFunction = chunkLoadingGlobal.push.bind(chunkLoadingGlobal);",
174
+ // Install chunks pushed before this runtime loaded (worklets
175
+ // pre-load every chunk via `addModule` before the entry runs).
176
+ "chunkLoadingGlobal.forEach(installChunk);",
174
177
  "chunkLoadingGlobal.push = installChunk;"
175
178
  ])
176
179
  : "// no chunk loading",
package/module.d.ts CHANGED
@@ -159,6 +159,17 @@ declare namespace webpack {
159
159
  id: string | number;
160
160
  (dependency: string): unknown;
161
161
  }
162
+
163
+ type ImportMetaGlobPattern = string | readonly string[];
164
+ type ImportMetaGlobQuery = string | Record<string, string | number | boolean>;
165
+ type ImportMetaGlobOptions<Eager extends boolean = boolean> = {
166
+ eager?: Eager;
167
+ import?: string;
168
+ query?: ImportMetaGlobQuery;
169
+ exhaustive?: boolean;
170
+ base?: string;
171
+ caseSensitive?: boolean;
172
+ };
162
173
  }
163
174
 
164
175
  interface ImportMetaEnv {
@@ -185,6 +196,16 @@ interface ImportMeta {
185
196
  mode?: "sync" | "eager" | "weak" | "lazy" | "lazy-once";
186
197
  }
187
198
  ) => webpack.Context;
199
+ glob: {
200
+ <T = unknown>(
201
+ pattern: webpack.ImportMetaGlobPattern,
202
+ options?: webpack.ImportMetaGlobOptions<false>
203
+ ): Record<string, () => Promise<T>>;
204
+ <T = unknown>(
205
+ pattern: webpack.ImportMetaGlobPattern,
206
+ options: webpack.ImportMetaGlobOptions<true>
207
+ ): Record<string, T>;
208
+ };
188
209
  }
189
210
 
190
211
  declare const __resourceQuery: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.108.3",
3
+ "version": "5.109.0",
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 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",
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 && node tooling/generate-internal-serializables.js",
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,8 @@
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 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",
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 && node tooling/generate-internal-serializables.js --write",
52
+ "fix:serializables": "node tooling/generate-internal-serializables.js --write",
52
53
  "build:examples": "cd examples && node buildAll.js",
53
54
  "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
55
  "pretest": "yarn lint",
@@ -64,7 +65,7 @@
64
65
  "test:test262": "yarn test:base --testMatch \"<rootDir>/test/test262.spectest.js\"",
65
66
  "test:html5lib": "yarn test:base --testMatch \"<rootDir>/test/html5lib.spectest.js\"",
66
67
  "test:css-parsing": "yarn test:base --testMatch \"<rootDir>/test/cssParsing-webpack.spectest.js\"",
67
- "test:deno": "yarn test:base:deno --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/\"",
68
+ "test:deno": "yarn test:base:deno --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/|test/HotTestCases\"",
68
69
  "test:base:deno": "deno --allow-read --allow-env --allow-sys --allow-ffi --allow-write --allow-run --allow-net --import-map=test/deno-import-map.json --v8-flags='--max-old-space-size=4096' ./node_modules/jest-cli/bin/jest.js --workerIdleMemoryLimit=512MB --logHeapUsage",
69
70
  "test:bun": "yarn test:base:bun --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/\"",
70
71
  "test:base:bun": "bun --bun --smol --preload ./test/bun-preload.js ./node_modules/jest-cli/bin/jest.js --workerThreads --workerIdleMemoryLimit=512MB --logHeapUsage",
@@ -102,22 +103,20 @@
102
103
  "@webassemblyjs/wasm-edit": "^1.14.1",
103
104
  "@webassemblyjs/wasm-parser": "^1.14.1",
104
105
  "acorn": "^8.16.0",
105
- "acorn-import-phases": "^1.0.3",
106
106
  "browserslist": "^4.28.1",
107
107
  "chrome-trace-event": "^1.0.2",
108
- "enhanced-resolve": "^5.22.2",
108
+ "enhanced-resolve": "^5.24.2",
109
109
  "es-module-lexer": "^2.1.0",
110
110
  "eslint-scope": "5.1.1",
111
111
  "events": "^3.2.0",
112
112
  "graceful-fs": "^4.2.11",
113
- "loader-runner": "^4.3.2",
114
113
  "mime-db": "^1.54.0",
115
114
  "minimizer-webpack-plugin": "^5.6.1",
116
115
  "neo-async": "^2.6.2",
117
116
  "schema-utils": "^4.3.3",
118
117
  "tapable": "^2.3.0",
119
118
  "watchpack": "^2.5.2",
120
- "webpack-sources": "^3.5.0"
119
+ "webpack-sources": "^3.5.1"
121
120
  },
122
121
  "devDependencies": {
123
122
  "@babel/core": "^8.0.1",
@@ -162,6 +161,7 @@
162
161
  "jest-environment-node": "^30.3.0",
163
162
  "jest-junit": "^17.0.0",
164
163
  "jest-snapshot": "^30.3.0",
164
+ "jest-worker": "^30.2.0",
165
165
  "json-loader": "^0.5.7",
166
166
  "json5": "^2.1.3",
167
167
  "less": "^4.6.4",
@@ -176,13 +176,13 @@
176
176
  "node-gyp": "^13.0.0",
177
177
  "nyc": "^18.0.0",
178
178
  "open-cli": "^9.0.0",
179
- "oxc-parser": "^0.137.0",
180
- "pkg-pr-new": "^0.0.75",
179
+ "oxc-parser": "^0.141.0",
180
+ "pkg-pr-new": "^0.0.79",
181
181
  "prettier": "^3.8.2",
182
182
  "prettier-2": "npm:prettier@^2",
183
183
  "pretty-format": "^30.0.5",
184
184
  "pug": "^3.0.3",
185
- "puppeteer-core": "^23.11.1",
185
+ "puppeteer-core": "^25.3.0",
186
186
  "raw-loader": "^4.0.1",
187
187
  "react": "^19.2.7",
188
188
  "react-dom": "^19.2.7",
@@ -197,7 +197,7 @@
197
197
  "simple-git": "^3.28.0",
198
198
  "style-loader": "^4.0.0",
199
199
  "terser": "^5.46.2",
200
- "three": "^0.184.0",
200
+ "three": "^0.185.1",
201
201
  "tinybench": "^6.0.1",
202
202
  "toml": "^4.1.1",
203
203
  "tooling": "webpack/tooling#v1.26.4",
@@ -207,7 +207,8 @@
207
207
  "url-loader": "^4.1.0",
208
208
  "wast-loader": "^1.12.1",
209
209
  "webassembly-feature": "1.3.0",
210
- "webpack-cli": "^7.0.2",
210
+ "webpack-cli": "^7.2.1",
211
+ "webpack-dev-server": "^6.0.0",
211
212
  "xxhashjs": "^0.2.2",
212
213
  "yamljs": "^0.3.0"
213
214
  },