webpack 5.110.2 → 5.111.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 (226) hide show
  1. package/README.md +5 -2
  2. package/lib/APIPlugin.js +23 -7
  3. package/lib/AutomaticPrefetchPlugin.js +1 -1
  4. package/lib/Cache.js +8 -3
  5. package/lib/CacheFacade.js +1 -1
  6. package/lib/ChunkGraph.js +20 -18
  7. package/lib/CircularModulesPlugin.js +157 -55
  8. package/lib/CleanPlugin.js +2 -2
  9. package/lib/Compilation.js +321 -303
  10. package/lib/Compiler.js +209 -46
  11. package/lib/ConcatenationScope.js +25 -35
  12. package/lib/ContextModule.js +17 -81
  13. package/lib/ContextModuleFactory.js +1 -1
  14. package/lib/CopyPlugin.js +1054 -0
  15. package/lib/DefinePlugin.js +24 -8
  16. package/lib/DotenvPlugin.js +41 -13
  17. package/lib/ExternalModule.js +41 -14
  18. package/lib/FileSystemInfo.js +17 -14
  19. package/lib/FlagDependencyExportsPlugin.js +45 -21
  20. package/lib/FlagDependencyUsagePlugin.js +8 -2
  21. package/lib/HotModuleReplacementPlugin.js +53 -7
  22. package/lib/JavascriptMetaInfoPlugin.js +5 -3
  23. package/lib/MainTemplate.js +5 -1
  24. package/lib/Module.js +16 -7
  25. package/lib/MultiCompiler.js +1 -1
  26. package/lib/MultiWatching.js +1 -1
  27. package/lib/NormalModule.js +58 -32
  28. package/lib/NormalModuleFactory.js +1 -1
  29. package/lib/RuntimeGlobals.js +21 -7
  30. package/lib/RuntimeModule.js +28 -12
  31. package/lib/RuntimePlugin.js +33 -3
  32. package/lib/RuntimeTemplate.js +794 -477
  33. package/lib/SourceMapDevToolPlugin.js +1 -1
  34. package/lib/Watching.js +9 -0
  35. package/lib/WebpackOptionsApply.js +84 -91
  36. package/lib/asset/AssetGenerator.js +25 -8
  37. package/lib/asset/AssetModule.js +3 -0
  38. package/lib/asset/WebManifestParser.js +7 -5
  39. package/lib/async-modules/AsyncModuleHelpers.js +10 -4
  40. package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
  41. package/lib/cache/IdleFileCachePlugin.js +2 -2
  42. package/lib/cache/PackFileCacheStrategy.js +14 -1
  43. package/lib/config/browserslistTargetHandler.js +19 -0
  44. package/lib/config/defaults.js +110 -64
  45. package/lib/config/normalization.js +100 -20
  46. package/lib/config/target.js +10 -0
  47. package/lib/container/ContainerReferencePlugin.js +6 -0
  48. package/lib/container/RemoteRuntimeModule.js +9 -0
  49. package/lib/container/declaredRemotes.js +39 -0
  50. package/lib/css/CssGenerator.js +8 -0
  51. package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
  52. package/lib/css/CssLoadingRuntimeModule.js +94 -36
  53. package/lib/css/CssModule.js +1 -1
  54. package/lib/css/CssModulesPlugin.js +7 -6
  55. package/lib/css/CssParser.js +144 -11
  56. package/lib/css/CssServerStylesRuntimeModule.js +9 -0
  57. package/lib/css/cssMinify.js +11 -3
  58. package/lib/css/data.js +2814 -678
  59. package/lib/css/syntax.js +4082 -248
  60. package/lib/debug/ProfilingPlugin.js +4 -0
  61. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
  62. package/lib/dependencies/AMDRuntimeModules.js +18 -0
  63. package/lib/dependencies/CommonJsExportRequireDependency.js +3 -1
  64. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
  65. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -0
  66. package/lib/dependencies/CommonJsPlugin.js +19 -3
  67. package/lib/dependencies/CommonJsRequireDependency.js +32 -9
  68. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
  69. package/lib/dependencies/CssIcssExportDependency.js +7 -1
  70. package/lib/dependencies/HarmonyCompatibilityDependency.js +58 -4
  71. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -3
  72. package/lib/dependencies/HarmonyExportExpressionDependency.js +44 -29
  73. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +171 -32
  74. package/lib/dependencies/HarmonyExportInitFragment.js +99 -19
  75. package/lib/dependencies/HarmonyExportSpecifierDependency.js +18 -30
  76. package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
  77. package/lib/dependencies/HarmonyImportDependency.js +99 -41
  78. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +20 -3
  79. package/lib/dependencies/HarmonyImportSpecifierDependency.js +24 -1
  80. package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
  81. package/lib/dependencies/HtmlEntryDependency.js +62 -2
  82. package/lib/dependencies/ImportContextDependency.js +43 -3
  83. package/lib/dependencies/ImportDependency.js +8 -29
  84. package/lib/dependencies/ImportMetaMainDependency.js +104 -0
  85. package/lib/dependencies/ImportMetaPlugin.js +59 -15
  86. package/lib/dependencies/ImportParserPlugin.js +24 -14
  87. package/lib/dependencies/RequireHeaderDependency.js +20 -21
  88. package/lib/dependencies/SystemRuntimeModule.js +9 -0
  89. package/lib/dependencies/WorkerDependency.js +1 -2
  90. package/lib/dependencies/WorkletDependency.js +1 -2
  91. package/lib/dependencies/importOptionsCheck.js +47 -0
  92. package/lib/dll/DelegatedModule.js +18 -1
  93. package/lib/dll/DllReferencePlugin.js +11 -8
  94. package/lib/dll/LibManifestPlugin.js +1 -1
  95. package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
  96. package/lib/errors/DotenvFileError.js +29 -0
  97. package/lib/errors/DuplicateModulesWarning.js +12 -7
  98. package/lib/errors/EmptyCopyPatternWarning.js +26 -0
  99. package/lib/errors/ExternalStarReexportError.js +44 -0
  100. package/lib/errors/ImportedBindingAssignmentError.js +30 -0
  101. package/lib/errors/MissingSourceMapsWarning.js +36 -0
  102. package/lib/errors/ModuleParseError.js +2 -1
  103. package/lib/errors/UnusedAssetsWarning.js +36 -0
  104. package/lib/errors/UnusedFederationWarning.js +35 -0
  105. package/lib/errors/UnusedModulesWarning.js +38 -0
  106. package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
  107. package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
  108. package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
  109. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
  110. package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
  111. package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
  112. package/lib/html/HtmlGenerator.js +11 -5
  113. package/lib/html/HtmlModulesPlugin.js +360 -84
  114. package/lib/html/HtmlParser.js +13 -6
  115. package/lib/html/builtinEmbeddedRenderer.js +107 -0
  116. package/lib/html/data.js +121 -7
  117. package/lib/html/htmlMinify.js +84 -113
  118. package/lib/html/syntax.js +1067 -569
  119. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  120. package/lib/index.js +3 -0
  121. package/lib/javascript/JavascriptModule.js +1 -0
  122. package/lib/javascript/JavascriptModulesPlugin.js +52 -22
  123. package/lib/javascript/JavascriptParser.js +1255 -728
  124. package/lib/javascript/StartupHelpers.js +27 -3
  125. package/lib/javascript/data.js +172 -0
  126. package/lib/javascript/grammar.js +5546 -0
  127. package/lib/javascript/parser.js +1494 -0
  128. package/lib/javascript/regexp.js +1762 -0
  129. package/lib/javascript/regexpData.js +51 -0
  130. package/lib/javascript/syntax.js +8696 -5225
  131. package/lib/library/ModuleLibraryPlugin.js +116 -5
  132. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
  133. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
  134. package/lib/optimize/ConcatenatedModule.js +133 -25
  135. package/lib/optimize/ConstExportsPlugin.js +50 -39
  136. package/lib/optimize/InlineExports.js +20 -123
  137. package/lib/optimize/MangleExportsPlugin.js +10 -0
  138. package/lib/optimize/ModuleConcatenationPlugin.js +24 -1
  139. package/lib/optimize/RealContentHashPlugin.js +68 -9
  140. package/lib/optimize/SideEffectsFlagPlugin.js +17 -9
  141. package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
  142. package/lib/performance/CacheEffectivenessPlugin.js +4 -3
  143. package/lib/performance/DuplicateModulesPlugin.js +57 -13
  144. package/lib/performance/EvalUsagePlugin.js +5 -2
  145. package/lib/performance/MissingSourceMapsPlugin.js +115 -0
  146. package/lib/performance/PureAnnotationsPlugin.js +6 -3
  147. package/lib/performance/TopLevelThisPlugin.js +5 -4
  148. package/lib/performance/UnusedAssetsPlugin.js +109 -0
  149. package/lib/performance/UnusedFederationPlugin.js +147 -0
  150. package/lib/performance/UnusedModulesPlugin.js +141 -0
  151. package/lib/performance/UnusedReexportsPlugin.js +1 -55
  152. package/lib/performance/isOnlyReexported.js +65 -0
  153. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
  154. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +2 -0
  155. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
  156. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
  157. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
  158. package/lib/prefetch/ResourceHintPlugin.js +7 -3
  159. package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
  160. package/lib/prefetch/StartupAssetHintRuntimeModule.js +9 -0
  161. package/lib/rules/RuleSetCompiler.js +211 -4
  162. package/lib/runtime/AsyncModuleRuntimeModule.js +105 -67
  163. package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
  164. package/lib/runtime/BaseUriRuntimeModule.js +9 -0
  165. package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
  166. package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
  167. package/lib/runtime/GetChunkFilenameRuntimeModule.js +9 -0
  168. package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
  169. package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
  170. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
  171. package/lib/runtime/GlobalRuntimeModule.js +9 -0
  172. package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
  173. package/lib/runtime/HelperRuntimeModule.js +10 -0
  174. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +338 -217
  175. package/lib/runtime/NonceRuntimeModule.js +9 -0
  176. package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
  177. package/lib/runtime/PublicPathRuntimeModule.js +9 -0
  178. package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
  179. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
  180. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
  181. package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
  182. package/lib/runtime/SystemContextRuntimeModule.js +9 -0
  183. package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
  184. package/lib/schemes/HttpUriPlugin.js +22 -5
  185. package/lib/serialization/FileMiddleware.js +15 -2
  186. package/lib/serialization/ObjectMiddleware.js +138 -106
  187. package/lib/sharing/ConsumeSharedPlugin.js +12 -0
  188. package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
  189. package/lib/sharing/ShareRuntimeModule.js +9 -0
  190. package/lib/sharing/declaredShared.js +47 -0
  191. package/lib/stats/DefaultStatsFactoryPlugin.js +3 -1
  192. package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
  193. package/lib/util/ArrayQueue.js +3 -3
  194. package/lib/util/SourceProcessor.js +76 -69
  195. package/lib/util/URLAbsoluteSpecifier.js +3 -1
  196. package/lib/util/async.js +292 -0
  197. package/lib/util/buildDiagnostics.js +69 -0
  198. package/lib/util/conventions.js +5 -1
  199. package/lib/util/fs.js +27 -1
  200. package/lib/util/handlerKeys.js +40 -0
  201. package/lib/util/identifier.js +20 -0
  202. package/lib/util/internalSerializables.js +6 -0
  203. package/lib/util/registerExternalSerializer.js +6 -45
  204. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
  205. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
  206. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +9 -0
  207. package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
  208. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
  209. package/package.json +22 -16
  210. package/schemas/WebpackOptions.check.js +1 -1
  211. package/schemas/WebpackOptions.json +388 -76
  212. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  213. package/schemas/plugins/ManifestPlugin.check.js +1 -1
  214. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  215. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  216. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  217. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  218. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  219. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  220. package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
  221. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
  222. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  223. package/types.d.ts +1440 -331
  224. package/lib/dependencies/ExportBindingInitFragment.js +0 -191
  225. package/lib/errors/EntrypointOverlapWarning.js +0 -45
  226. package/lib/performance/EntrypointOverlapPlugin.js +0 -122
@@ -0,0 +1,40 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ */
4
+
5
+ "use strict";
6
+
7
+ /** @import RuntimeModule from "../RuntimeModule" */
8
+
9
+ /**
10
+ * The one key a chunk's runtime modules install on a handler map, or `null` when
11
+ * they install several, none, or one a module could not name. Every module states
12
+ * what it installs, so nothing has to be rendered to find out.
13
+ * @param {RuntimeModule} runtimeModule the runtime module rendering the dispatch
14
+ * @param {string} handlers the handler map global
15
+ * @returns {string | null} the sole handler key, or `null`
16
+ */
17
+ const getOnlyHandlerKey = (runtimeModule, handlers) => {
18
+ const { chunkGraph, chunk } = runtimeModule;
19
+ if (chunkGraph === undefined || chunk === undefined) return null;
20
+ /** @type {string | null} */
21
+ let only = null;
22
+ for (const module of chunkGraph.getChunkRuntimeModulesIterable(chunk)) {
23
+ // TODO webpack 6: call it directly, every runtime module answers by then. A
24
+ // module built against an older webpack extends a base class without it.
25
+ const installed =
26
+ typeof module.getInstalledChunkHandlers === "function"
27
+ ? module.getInstalledChunkHandlers()
28
+ : null;
29
+ // A module that cannot name what it installs leaves every map unknowable.
30
+ if (!Array.isArray(installed)) return null;
31
+ for (const [map, key] of installed) {
32
+ if (map !== handlers) continue;
33
+ if (only !== null && only !== key) return null;
34
+ only = key;
35
+ }
36
+ }
37
+ return only;
38
+ };
39
+
40
+ module.exports.getOnlyHandlerKey = getOnlyHandlerKey;
@@ -5,6 +5,7 @@
5
5
  "use strict";
6
6
 
7
7
  const path = require("path");
8
+ const { fileURLToPath } = require("url");
8
9
 
9
10
  // Any absolute path: POSIX (/foo) and every Windows form — drive-letter (C:\,
10
11
  // C:/), UNC (\\, //), rooted (\, /); equals posix||win32 isAbsolute.
@@ -15,6 +16,23 @@ const WINDOWS_ABS_PATH_REGEXP = /^[a-z]:[\\/]/i;
15
16
  const SEGMENTS_SPLIT_REGEXP = /([|!])/;
16
17
  const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g;
17
18
  const NODE_MODULES_REGEXP = /[\\/]node_modules[\\/]/i;
19
+ // A file URL, the form `import.meta.resolve()` returns a local module in.
20
+ // One slash after the scheme is enough, as Node's own URL parser needs.
21
+ const FILE_URL_REGEXP = /^file:\//i;
22
+ // What `import()` resolves as a place rather than as a package name: relative,
23
+ // rooted, or carrying a scheme.
24
+ const RESOLVABLE_SPECIFIER_REGEXP = /^(?:\.{0,2}\/|[a-zA-Z][\w+.-]*:)/;
25
+
26
+ /**
27
+ * Converts a file URL to the path it names. Any other value is returned
28
+ * unchanged, so this is safe to apply to an option that also takes a path.
29
+ * @param {string} pathOrUrl an absolute path or a file URL
30
+ * @returns {string} an absolute path
31
+ */
32
+ const fileUrlToPath = (pathOrUrl) => {
33
+ if (!FILE_URL_REGEXP.test(pathOrUrl)) return pathOrUrl;
34
+ return fileURLToPath(pathOrUrl);
35
+ };
18
36
 
19
37
  /**
20
38
  * Relative path to request.
@@ -568,12 +586,14 @@ const toJsStringLiteral = (str) =>
568
586
 
569
587
  module.exports.ABSOLUTE_PATH_REGEXP = ABSOLUTE_PATH_REGEXP;
570
588
  module.exports.NODE_MODULES_REGEXP = NODE_MODULES_REGEXP;
589
+ module.exports.RESOLVABLE_SPECIFIER_REGEXP = RESOLVABLE_SPECIFIER_REGEXP;
571
590
  module.exports.WINDOWS_ABS_PATH_REGEXP = WINDOWS_ABS_PATH_REGEXP;
572
591
  module.exports.WINDOWS_PATH_SEPARATOR_REGEXP = WINDOWS_PATH_SEPARATOR_REGEXP;
573
592
  module.exports.absolutify = absolutify;
574
593
  module.exports.contextify = contextify;
575
594
  module.exports.contextifySourceUrl = contextifySourceUrl;
576
595
  module.exports.escapeHashInPathRequest = escapeHashInPathRequest;
596
+ module.exports.fileUrlToPath = fileUrlToPath;
577
597
  module.exports.getUndoPath = getUndoPath;
578
598
  module.exports.makeCacheable = makeCacheable;
579
599
  module.exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
@@ -113,6 +113,8 @@ module.exports = {
113
113
  require("../dependencies/HarmonyExportImportedSpecifierDependency"),
114
114
  "dependencies/HarmonyExportSpecifierDependency": () =>
115
115
  require("../dependencies/HarmonyExportSpecifierDependency"),
116
+ "dependencies/HarmonyImportBareSideEffectDependency": () =>
117
+ require("../dependencies/HarmonyImportBareSideEffectDependency"),
116
118
  "dependencies/HarmonyImportSideEffectDependency": () =>
117
119
  require("../dependencies/HarmonyImportSideEffectDependency"),
118
120
  "dependencies/HarmonyImportSpecifierDependency": () =>
@@ -141,6 +143,8 @@ module.exports = {
141
143
  require("../dependencies/ImportMetaHotAcceptDependency"),
142
144
  "dependencies/ImportMetaHotDeclineDependency": () =>
143
145
  require("../dependencies/ImportMetaHotDeclineDependency"),
146
+ "dependencies/ImportMetaMainDependency": () =>
147
+ require("../dependencies/ImportMetaMainDependency"),
144
148
  "dependencies/ImportMetaResolveDependency": () =>
145
149
  require("../dependencies/ImportMetaResolveDependency"),
146
150
  "dependencies/ImportWeakDependency": () =>
@@ -211,6 +215,8 @@ module.exports = {
211
215
  "errors/EnvironmentNotSupportAsyncWarning": () =>
212
216
  require("../errors/EnvironmentNotSupportAsyncWarning"),
213
217
  "errors/HookWebpackError": () => require("../errors/HookWebpackError"),
218
+ "errors/ImportedBindingAssignmentError": () =>
219
+ require("../errors/ImportedBindingAssignmentError"),
214
220
  "errors/InvalidDependenciesModuleWarning": () =>
215
221
  require("../errors/InvalidDependenciesModuleWarning"),
216
222
  "errors/JSONParseError": () => require("../errors/JSONParseError"),
@@ -5,8 +5,6 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const Position = require("acorn").Position;
9
- const SourceLocation = require("acorn").SourceLocation;
10
8
  const ValidationError = require("schema-utils").ValidationError;
11
9
  const {
12
10
  CachedSource,
@@ -17,9 +15,10 @@ const {
17
15
  ReplaceSource,
18
16
  SourceMapSource
19
17
  } = require("webpack-sources");
18
+ const ParserPosition = require("../javascript/syntax").ParserPosition;
20
19
  const { register } = require("./serialization");
21
20
 
22
- /** @import { RealDependencyLocation, SourcePosition } from "../Dependency" */
21
+ /** @import { SourcePosition } from "../Dependency" */
23
22
  /**
24
23
  * @import {
25
24
  * ObjectDeserializerContext,
@@ -229,51 +228,13 @@ register(
229
228
  );
230
229
 
231
230
  register(
232
- SourceLocation,
231
+ ParserPosition,
233
232
  CURRENT_MODULE,
234
- "acorn/SourceLocation",
235
- new (class SourceLocationSerializer {
233
+ "webpack/ParserPosition",
234
+ new (class ParserPositionSerializer {
236
235
  /**
237
236
  * Serializes this instance into the provided serializer context.
238
- * @param {SourceLocation} loc the location to be serialized
239
- * @param {import("../serialization/ObjectMiddleware").ObjectSerializerContext<number[]>} context context
240
- * @returns {void}
241
- */
242
- serialize(loc, { write }) {
243
- write(loc.start.line);
244
- write(loc.start.column);
245
- write(loc.end.line);
246
- write(loc.end.column);
247
- }
248
-
249
- /**
250
- * Restores this instance from the provided deserializer context.
251
- * @param {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<number[]>} context context
252
- * @returns {RealDependencyLocation} location
253
- */
254
- deserialize({ read }) {
255
- return {
256
- start: {
257
- line: read(),
258
- column: read()
259
- },
260
- end: {
261
- line: read(),
262
- column: read()
263
- }
264
- };
265
- }
266
- })()
267
- );
268
-
269
- register(
270
- Position,
271
- CURRENT_MODULE,
272
- "acorn/Position",
273
- new (class PositionSerializer {
274
- /**
275
- * Serializes this instance into the provided serializer context.
276
- * @param {Position} pos the position to be serialized
237
+ * @param {ParserPosition} pos the position to be serialized
277
238
  * @param {import("../serialization/ObjectMiddleware").ObjectSerializerContext<number[]>} context context
278
239
  * @returns {void}
279
240
  */
@@ -56,6 +56,15 @@ class AsyncWasmCompileRuntimeModule extends RuntimeModule {
56
56
  this.supportsStreaming = supportsStreaming;
57
57
  }
58
58
 
59
+ /**
60
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
61
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
62
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
63
+ */
64
+ getInstalledChunkHandlers() {
65
+ return RuntimeModule.NO_CHUNK_HANDLERS;
66
+ }
67
+
59
68
  /**
60
69
  * Generates runtime code for this runtime module.
61
70
  * @returns {string | null} runtime code
@@ -57,6 +57,15 @@ class AsyncWasmLoadingRuntimeModule extends RuntimeModule {
57
57
  this.supportsStreaming = supportsStreaming;
58
58
  }
59
59
 
60
+ /**
61
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
62
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
63
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
64
+ */
65
+ getInstalledChunkHandlers() {
66
+ return RuntimeModule.NO_CHUNK_HANDLERS;
67
+ }
68
+
60
69
  /**
61
70
  * Generates runtime code for this runtime module.
62
71
  * @returns {string | null} runtime code
@@ -254,6 +254,15 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
254
254
  this._runtimeRequirements = runtimeRequirements;
255
255
  }
256
256
 
257
+ /**
258
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
259
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
260
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
261
+ */
262
+ getInstalledChunkHandlers() {
263
+ return [[RuntimeGlobals.ensureChunkHandlers, "wasm"]];
264
+ }
265
+
257
266
  /**
258
267
  * Generates runtime code for this runtime module.
259
268
  * @returns {string | null} runtime code
@@ -38,6 +38,42 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
38
38
  this._runtimeRequirements = runtimeRequirements;
39
39
  }
40
40
 
41
+ /**
42
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
43
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
44
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
45
+ */
46
+ getInstalledChunkHandlers() {
47
+ const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
48
+ const chunk = /** @type {Chunk} */ (this.chunk);
49
+ const runtimeRequirements = this._runtimeRequirements;
50
+ /** @type {[string, string][]} */
51
+ const handlers = [];
52
+ if (runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)) {
53
+ handlers.push([RuntimeGlobals.ensureChunkHandlers, "j"]);
54
+ }
55
+ // The hot update flow installs this one onto the same map while it runs.
56
+ if (runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers)) {
57
+ handlers.push([RuntimeGlobals.ensureChunkHandlers, "jsonpHmr"]);
58
+ }
59
+ if (
60
+ runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers) &&
61
+ chunk.hasChildByOrder(chunkGraph, "prefetch", true, chunkHasJs)
62
+ ) {
63
+ handlers.push([RuntimeGlobals.prefetchChunkHandlers, "j"]);
64
+ }
65
+ if (
66
+ runtimeRequirements.has(RuntimeGlobals.preloadChunkHandlers) &&
67
+ chunk.hasChildByOrder(chunkGraph, "preload", true, chunkHasJs)
68
+ ) {
69
+ handlers.push([RuntimeGlobals.preloadChunkHandlers, "j"]);
70
+ }
71
+ if (runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)) {
72
+ handlers.push([RuntimeGlobals.onChunksLoaded, "j"]);
73
+ }
74
+ return handlers;
75
+ }
76
+
41
77
  /**
42
78
  * @private
43
79
  * @param {Chunk} chunk chunk
@@ -33,6 +33,25 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
33
33
  this._withCreateScriptUrl = withCreateScriptUrl;
34
34
  }
35
35
 
36
+ /**
37
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
38
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
39
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
40
+ */
41
+ getInstalledChunkHandlers() {
42
+ const runtimeRequirements = this.runtimeRequirements;
43
+ /** @type {[string, string][]} */
44
+ const handlers = [];
45
+ if (runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers)) {
46
+ handlers.push([RuntimeGlobals.ensureChunkHandlers, "i"]);
47
+ }
48
+ // The hot update flow installs this one onto the same map while it runs.
49
+ if (runtimeRequirements.has(RuntimeGlobals.hmrDownloadUpdateHandlers)) {
50
+ handlers.push([RuntimeGlobals.ensureChunkHandlers, "importScriptsHmr"]);
51
+ }
52
+ return handlers;
53
+ }
54
+
36
55
  /**
37
56
  * @private
38
57
  * @param {Chunk} chunk chunk
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webpack",
3
- "version": "5.110.2",
3
+ "version": "5.111.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,12 +34,13 @@
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-css-data.js && node tooling/generate-html-data.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",
37
+ "lint:special": "node tooling/generate-runtime-code.js && node tooling/generate-wasm-code.js && node tooling/generate-css-data.js && node tooling/generate-html-data.js && node tooling/generate-js-data.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",
41
41
  "lint:types-hot": "tsc -p tsconfig.hot.json",
42
42
  "lint:types-module-test": "tsc -p tsconfig.module.test.json",
43
+ "lint:comments": "node tooling/check-comment-length.js",
43
44
  "lint:spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
44
45
  "validate:changeset": "node .changeset/changeset-validate.mjs",
45
46
  "validate:types": "tsc -p tsconfig.validation.json",
@@ -48,12 +49,16 @@
48
49
  "fmt:base": "node node_modules/prettier/bin/prettier.cjs --cache --ignore-unknown .",
49
50
  "fix": "yarn fix:code && yarn fix:special && yarn fmt",
50
51
  "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-css-data.js --write && node tooling/generate-html-data.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:special": "node tooling/generate-runtime-code.js --write && node tooling/generate-wasm-code.js --write && node tooling/generate-css-data.js --write && node tooling/generate-html-data.js --write && node tooling/generate-js-data.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
53
  "fix:serializables": "node tooling/generate-internal-serializables.js --write",
53
54
  "build:examples": "cd examples && node buildAll.js",
54
55
  "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",
55
- "benchmark:css-minifiers": "node tooling/compare-css-minifiers.js",
56
- "benchmark:html-minifiers": "node tooling/compare-html-minifiers.js",
56
+ "benchmark:css-tools": "node tooling/compare-css-tools.js",
57
+ "benchmark:css-tools:setup": "node tooling/compare-css-tools.js --setup",
58
+ "benchmark:html-tools": "node tooling/compare-html-tools.js",
59
+ "benchmark:html-tools:setup": "node tooling/compare-html-tools.js --setup",
60
+ "benchmark:js-tools": "node tooling/compare-js-tools.js",
61
+ "measure:color-agreement": "node tooling/measure-color-agreement.js",
57
62
  "pretest": "yarn lint",
58
63
  "test": "yarn test:base",
59
64
  "test:base": "node --expose-gc --max-old-space-size=4096 --experimental-vm-modules --trace-deprecation node_modules/jest-cli/bin/jest --workerIdleMemoryLimit=512MB --logHeapUsage",
@@ -65,13 +70,14 @@
65
70
  "test:integration:a": "yarn test:base --testMatch \"<rootDir>/test/*.{basictest,test}.js\"",
66
71
  "test:integration:b": "yarn test:base --testMatch \"<rootDir>/test/*.longtest.js\"",
67
72
  "test:test262": "yarn test:base --testMatch \"<rootDir>/test/test262.spectest.js\"",
73
+ "test:test262-parser": "yarn test:base --testMatch \"<rootDir>/test/test262-parser.spectest.js\"",
68
74
  "test:html5lib": "yarn test:base --testMatch \"<rootDir>/test/html5lib.spectest.js\"",
69
75
  "test:syntax-equivalence": "yarn test:base --testMatch \"<rootDir>/test/syntaxEquivalence.spectest.js\"",
70
76
  "test:css-parsing": "yarn test:base --testMatch \"<rootDir>/test/cssParsing-webpack.spectest.js\"",
71
77
  "test:deno": "yarn test:base:deno --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/\" \"(ProfilingPlugin[.]unittest|WebpackDevServer)\"",
72
78
  "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",
73
79
  "test:bun": "yarn test:base:bun --reporters default --reporters \"<rootDir>/test/runtimeCrashReporter.js\" --testMatch \"<rootDir>/test/*.{basictest,longtest,test,unittest}.js\" --testPathIgnorePatterns \"/node_modules/\" \"(ProfilingPlugin[.]unittest|WebpackDevServer)\"",
74
- "test:base:bun": "bun --bun --smol --preload ./test/bun-preload.js ./node_modules/jest-cli/bin/jest.js --workerThreads --workerIdleMemoryLimit=2048MB --logHeapUsage",
80
+ "test:base:bun": "NODE_EXTRA_CA_CERTS=./test/hotCases/lazy-compilation/https/cert.pem bun --bun --smol --preload ./test/bun-preload.js ./node_modules/jest-cli/bin/jest.js --workerThreads --workerIdleMemoryLimit=2048MB --logHeapUsage",
75
81
  "test:update-snapshots": "yarn test:base -u",
76
82
  "test:size": "node --max-old-space-size=4096 ./test/CodeSizeTestCases.size.js",
77
83
  "report:cover": "nyc report --reporter=lcov --reporter=text -t coverage",
@@ -107,17 +113,15 @@
107
113
  "@webassemblyjs/ast": "^1.14.1",
108
114
  "@webassemblyjs/wasm-edit": "^1.14.1",
109
115
  "@webassemblyjs/wasm-parser": "^1.14.1",
110
- "acorn": "^8.16.0",
111
116
  "browserslist": "^4.28.1",
112
117
  "chrome-trace-event": "^1.0.2",
113
- "enhanced-resolve": "^5.24.4",
118
+ "enhanced-resolve": "^5.25.0",
114
119
  "es-module-lexer": "^2.1.0",
115
120
  "events": "^3.2.0",
116
121
  "graceful-fs": "^4.2.11",
117
122
  "mime-db": "^1.54.0",
118
123
  "minimizer-webpack-plugin": "^5.7.0",
119
- "neo-async": "^2.6.2",
120
- "schema-utils": "^4.3.3",
124
+ "schema-utils": "^4.5.0",
121
125
  "tapable": "^2.3.0",
122
126
  "watchpack": "^2.5.2",
123
127
  "webpack-sources": "^3.5.1"
@@ -126,17 +130,19 @@
126
130
  "@babel/core": "^8.0.1",
127
131
  "@babel/preset-react": "^8.0.1",
128
132
  "@changesets/cli": "^3.0.1",
129
- "@changesets/get-github-info": "^0.8.0",
133
+ "@changesets/get-github-info": "^1.0.1",
130
134
  "@codspeed/core": "^5.5.0",
131
135
  "@mdn/browser-compat-data": "^8.0.9",
132
136
  "@types/convert-source-map": "^2.0.3",
133
137
  "@types/graceful-fs": "^4.1.9",
134
138
  "@types/jest": "^30.0.0",
135
139
  "@types/mime-db": "^1.43.6",
136
- "@types/neo-async": "^2.6.7",
137
140
  "@types/node": "^26.2.0",
138
141
  "@types/xxhashjs": "^0.2.4",
139
142
  "@webdiscus/pug-loader": "^2.11.1",
143
+ "@webref/elements": "^2.8.0",
144
+ "@webref/idl": "^3.83.1",
145
+ "acorn": "^8.16.0",
140
146
  "assemblyscript": "^0.28.18",
141
147
  "babel-loader": "^10.0.0",
142
148
  "bundle-loader": "^0.5.6",
@@ -149,8 +155,8 @@
149
155
  "date-fns": "^4.4.0",
150
156
  "es5-ext": "^0.10.53",
151
157
  "es6-promise-polyfill": "^1.2.0",
152
- "eslint": "^9.39.2",
153
- "eslint-config-webpack": "^4.9.3",
158
+ "eslint": "^9.39.5",
159
+ "eslint-config-webpack": "^4.12.0",
154
160
  "eslint-scope": "^9.1.2",
155
161
  "eta": "^4.6.0",
156
162
  "file-loader": "^6.0.0",
@@ -183,7 +189,7 @@
183
189
  "node-gyp": "^13.0.0",
184
190
  "nyc": "^18.0.0",
185
191
  "open-cli": "^9.0.0",
186
- "oxc-parser": "^0.146.0",
192
+ "oxc-parser": "^0.149.0",
187
193
  "pkg-pr-new": "^0.0.88",
188
194
  "prettier": "^3.8.2",
189
195
  "prettier-2": "npm:prettier@^2",
@@ -207,7 +213,7 @@
207
213
  "three": "^0.185.1",
208
214
  "tinybench": "^6.0.1",
209
215
  "toml": "^5.0.0",
210
- "tooling": "webpack/tooling#v1.28.1",
216
+ "tooling": "webpack/tooling#v1.28.3",
211
217
  "ts-loader": "^9.6.0",
212
218
  "typescript": "^6.0.3",
213
219
  "unified": "^11.0.5",