webpack 5.110.3 → 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 (208) hide show
  1. package/README.md +5 -0
  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/CircularModulesPlugin.js +157 -55
  7. package/lib/CleanPlugin.js +2 -2
  8. package/lib/Compilation.js +320 -302
  9. package/lib/Compiler.js +209 -46
  10. package/lib/ContextModule.js +17 -81
  11. package/lib/ContextModuleFactory.js +1 -1
  12. package/lib/CopyPlugin.js +1054 -0
  13. package/lib/DefinePlugin.js +24 -8
  14. package/lib/ExternalModule.js +41 -14
  15. package/lib/FileSystemInfo.js +17 -14
  16. package/lib/FlagDependencyExportsPlugin.js +45 -21
  17. package/lib/HotModuleReplacementPlugin.js +53 -7
  18. package/lib/JavascriptMetaInfoPlugin.js +5 -3
  19. package/lib/MainTemplate.js +5 -1
  20. package/lib/Module.js +16 -7
  21. package/lib/MultiCompiler.js +1 -1
  22. package/lib/MultiWatching.js +1 -1
  23. package/lib/NormalModule.js +45 -12
  24. package/lib/NormalModuleFactory.js +1 -1
  25. package/lib/RuntimeGlobals.js +21 -7
  26. package/lib/RuntimeModule.js +28 -12
  27. package/lib/RuntimePlugin.js +30 -3
  28. package/lib/RuntimeTemplate.js +780 -475
  29. package/lib/SourceMapDevToolPlugin.js +1 -1
  30. package/lib/Watching.js +9 -0
  31. package/lib/WebpackOptionsApply.js +84 -91
  32. package/lib/asset/AssetGenerator.js +25 -8
  33. package/lib/asset/AssetModule.js +3 -0
  34. package/lib/asset/WebManifestParser.js +7 -5
  35. package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
  36. package/lib/cache/IdleFileCachePlugin.js +2 -2
  37. package/lib/cache/PackFileCacheStrategy.js +14 -1
  38. package/lib/config/browserslistTargetHandler.js +19 -0
  39. package/lib/config/defaults.js +86 -50
  40. package/lib/config/normalization.js +82 -12
  41. package/lib/config/target.js +10 -0
  42. package/lib/container/ContainerReferencePlugin.js +6 -0
  43. package/lib/container/RemoteRuntimeModule.js +9 -0
  44. package/lib/container/declaredRemotes.js +39 -0
  45. package/lib/css/CssGenerator.js +8 -0
  46. package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
  47. package/lib/css/CssLoadingRuntimeModule.js +94 -36
  48. package/lib/css/CssModule.js +1 -1
  49. package/lib/css/CssModulesPlugin.js +7 -6
  50. package/lib/css/CssParser.js +144 -11
  51. package/lib/css/CssServerStylesRuntimeModule.js +9 -0
  52. package/lib/css/cssMinify.js +11 -3
  53. package/lib/css/data.js +2814 -678
  54. package/lib/css/syntax.js +4082 -248
  55. package/lib/debug/ProfilingPlugin.js +4 -0
  56. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
  57. package/lib/dependencies/AMDRuntimeModules.js +18 -0
  58. package/lib/dependencies/CommonJsExportRequireDependency.js +3 -1
  59. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
  60. package/lib/dependencies/CommonJsImportsParserPlugin.js +1 -0
  61. package/lib/dependencies/CommonJsPlugin.js +19 -3
  62. package/lib/dependencies/CommonJsRequireDependency.js +14 -5
  63. package/lib/dependencies/CssIcssExportDependency.js +7 -1
  64. package/lib/dependencies/HarmonyCompatibilityDependency.js +58 -4
  65. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +8 -3
  66. package/lib/dependencies/HarmonyExportExpressionDependency.js +44 -29
  67. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +71 -13
  68. package/lib/dependencies/HarmonyExportInitFragment.js +99 -19
  69. package/lib/dependencies/HarmonyExportSpecifierDependency.js +18 -30
  70. package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
  71. package/lib/dependencies/HarmonyImportDependency.js +6 -1
  72. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +8 -1
  73. package/lib/dependencies/HarmonyImportSpecifierDependency.js +24 -1
  74. package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
  75. package/lib/dependencies/HtmlEntryDependency.js +50 -0
  76. package/lib/dependencies/ImportMetaMainDependency.js +104 -0
  77. package/lib/dependencies/ImportMetaPlugin.js +59 -15
  78. package/lib/dependencies/SystemRuntimeModule.js +9 -0
  79. package/lib/dependencies/WorkerDependency.js +1 -2
  80. package/lib/dependencies/WorkletDependency.js +1 -2
  81. package/lib/dll/DelegatedModule.js +18 -1
  82. package/lib/dll/DllReferencePlugin.js +11 -8
  83. package/lib/dll/LibManifestPlugin.js +1 -1
  84. package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
  85. package/lib/errors/DuplicateModulesWarning.js +12 -7
  86. package/lib/errors/EmptyCopyPatternWarning.js +26 -0
  87. package/lib/errors/ExternalStarReexportError.js +44 -0
  88. package/lib/errors/MissingSourceMapsWarning.js +36 -0
  89. package/lib/errors/ModuleParseError.js +2 -1
  90. package/lib/errors/UnusedAssetsWarning.js +36 -0
  91. package/lib/errors/UnusedFederationWarning.js +35 -0
  92. package/lib/errors/UnusedModulesWarning.js +38 -0
  93. package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
  94. package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
  95. package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
  96. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
  97. package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
  98. package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
  99. package/lib/html/HtmlGenerator.js +11 -5
  100. package/lib/html/HtmlModulesPlugin.js +331 -62
  101. package/lib/html/HtmlParser.js +13 -6
  102. package/lib/html/builtinEmbeddedRenderer.js +107 -0
  103. package/lib/html/data.js +121 -7
  104. package/lib/html/htmlMinify.js +84 -113
  105. package/lib/html/syntax.js +763 -426
  106. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  107. package/lib/index.js +3 -0
  108. package/lib/javascript/JavascriptModule.js +1 -0
  109. package/lib/javascript/JavascriptModulesPlugin.js +52 -24
  110. package/lib/javascript/JavascriptParser.js +1255 -728
  111. package/lib/javascript/StartupHelpers.js +27 -3
  112. package/lib/javascript/data.js +172 -0
  113. package/lib/javascript/grammar.js +5546 -0
  114. package/lib/javascript/parser.js +1494 -0
  115. package/lib/javascript/regexp.js +1762 -0
  116. package/lib/javascript/regexpData.js +51 -0
  117. package/lib/javascript/syntax.js +8696 -5225
  118. package/lib/library/ModuleLibraryPlugin.js +116 -5
  119. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
  120. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
  121. package/lib/optimize/ConcatenatedModule.js +97 -20
  122. package/lib/optimize/ConstExportsPlugin.js +50 -39
  123. package/lib/optimize/InlineExports.js +20 -123
  124. package/lib/optimize/MangleExportsPlugin.js +10 -0
  125. package/lib/optimize/ModuleConcatenationPlugin.js +24 -1
  126. package/lib/optimize/RealContentHashPlugin.js +68 -9
  127. package/lib/optimize/SideEffectsFlagPlugin.js +17 -9
  128. package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
  129. package/lib/performance/CacheEffectivenessPlugin.js +4 -3
  130. package/lib/performance/DuplicateModulesPlugin.js +57 -13
  131. package/lib/performance/EvalUsagePlugin.js +5 -2
  132. package/lib/performance/MissingSourceMapsPlugin.js +115 -0
  133. package/lib/performance/PureAnnotationsPlugin.js +6 -3
  134. package/lib/performance/TopLevelThisPlugin.js +5 -4
  135. package/lib/performance/UnusedAssetsPlugin.js +109 -0
  136. package/lib/performance/UnusedFederationPlugin.js +147 -0
  137. package/lib/performance/UnusedModulesPlugin.js +141 -0
  138. package/lib/performance/UnusedReexportsPlugin.js +1 -55
  139. package/lib/performance/isOnlyReexported.js +65 -0
  140. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
  141. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +2 -0
  142. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
  143. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
  144. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
  145. package/lib/prefetch/ResourceHintPlugin.js +1 -2
  146. package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
  147. package/lib/prefetch/StartupAssetHintRuntimeModule.js +9 -0
  148. package/lib/rules/RuleSetCompiler.js +211 -4
  149. package/lib/runtime/AsyncModuleRuntimeModule.js +100 -66
  150. package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
  151. package/lib/runtime/BaseUriRuntimeModule.js +9 -0
  152. package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
  153. package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
  154. package/lib/runtime/GetChunkFilenameRuntimeModule.js +9 -0
  155. package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
  156. package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
  157. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
  158. package/lib/runtime/GlobalRuntimeModule.js +9 -0
  159. package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
  160. package/lib/runtime/HelperRuntimeModule.js +10 -0
  161. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +330 -219
  162. package/lib/runtime/NonceRuntimeModule.js +9 -0
  163. package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
  164. package/lib/runtime/PublicPathRuntimeModule.js +9 -0
  165. package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
  166. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
  167. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
  168. package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
  169. package/lib/runtime/SystemContextRuntimeModule.js +9 -0
  170. package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
  171. package/lib/serialization/ObjectMiddleware.js +138 -106
  172. package/lib/sharing/ConsumeSharedPlugin.js +12 -0
  173. package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
  174. package/lib/sharing/ShareRuntimeModule.js +9 -0
  175. package/lib/sharing/declaredShared.js +47 -0
  176. package/lib/stats/DefaultStatsFactoryPlugin.js +3 -1
  177. package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
  178. package/lib/util/SourceProcessor.js +76 -69
  179. package/lib/util/async.js +292 -0
  180. package/lib/util/buildDiagnostics.js +69 -0
  181. package/lib/util/fs.js +27 -1
  182. package/lib/util/handlerKeys.js +40 -0
  183. package/lib/util/identifier.js +20 -0
  184. package/lib/util/internalSerializables.js +4 -0
  185. package/lib/util/registerExternalSerializer.js +6 -45
  186. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
  187. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
  188. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +9 -0
  189. package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
  190. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
  191. package/package.json +22 -16
  192. package/schemas/WebpackOptions.check.js +1 -1
  193. package/schemas/WebpackOptions.json +379 -66
  194. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  195. package/schemas/plugins/ManifestPlugin.check.js +1 -1
  196. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  197. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  198. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  199. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  200. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  201. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  202. package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
  203. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
  204. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  205. package/types.d.ts +1414 -314
  206. package/lib/dependencies/ExportBindingInitFragment.js +0 -191
  207. package/lib/errors/EntrypointOverlapWarning.js +0 -45
  208. package/lib/performance/EntrypointOverlapPlugin.js +0 -122
@@ -0,0 +1,69 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Haijie Xie @hai-x
4
+ */
5
+
6
+ "use strict";
7
+
8
+ /** @import Module, { BuildDiagnostics, BuildInfo } from "../Module" */
9
+ /** @import ModuleGraph from "../ModuleGraph" */
10
+
11
+ /**
12
+ * The diagnostics record of a build info, created on first use so a module nothing reports about carries none.
13
+ * @param {BuildInfo} buildInfo the build info of the module
14
+ * @returns {BuildDiagnostics} the record
15
+ */
16
+ const getBuildDiagnostics = (buildInfo) => {
17
+ let diagnostics = buildInfo.diagnostics;
18
+ if (diagnostics === undefined) {
19
+ diagnostics = buildInfo.diagnostics = {
20
+ optimizationBailouts: undefined,
21
+ sideEffectStatement: undefined,
22
+ ineffectivePureAnnotations: undefined,
23
+ topLevelThis: undefined,
24
+ usesEval: undefined,
25
+ notCacheableReasons: undefined
26
+ };
27
+ }
28
+ return diagnostics;
29
+ };
30
+
31
+ /**
32
+ * Records a bailout a parser plugin found, where a module restored from the cache still has it for the module graph to report.
33
+ * @param {BuildInfo} buildInfo the build info of the module being parsed
34
+ * @param {string} reason the bailout as reported
35
+ * @returns {void}
36
+ */
37
+ const recordOptimizationBailout = (buildInfo, reason) => {
38
+ const diagnostics = getBuildDiagnostics(buildInfo);
39
+ const bailouts =
40
+ diagnostics.optimizationBailouts || (diagnostics.optimizationBailouts = []);
41
+ bailouts.push(reason);
42
+ };
43
+
44
+ /**
45
+ * Replays the bailouts parser plugins recorded for a module into the module graph,
46
+ * which a module reused from the cache never parses into.
47
+ * @param {ModuleGraph} moduleGraph the module graph
48
+ * @param {Module} module the built or still valid module
49
+ * @returns {void}
50
+ */
51
+ const replayOptimizationBailouts = (moduleGraph, module) => {
52
+ const buildInfo = module.buildInfo;
53
+ if (buildInfo === undefined) return;
54
+ const diagnostics = buildInfo.diagnostics;
55
+ if (
56
+ diagnostics === undefined ||
57
+ diagnostics.optimizationBailouts === undefined
58
+ ) {
59
+ return;
60
+ }
61
+ const bailouts = moduleGraph.getOptimizationBailout(module);
62
+ for (const reason of diagnostics.optimizationBailouts) bailouts.push(reason);
63
+ };
64
+
65
+ module.exports = {
66
+ getBuildDiagnostics,
67
+ recordOptimizationBailout,
68
+ replayOptimizationBailouts
69
+ };
package/lib/util/fs.js CHANGED
@@ -167,7 +167,7 @@ const { ABSOLUTE_PATH_REGEXP } = require("./identifier");
167
167
  * @typedef {{
168
168
  * (path: PathOrFileDescriptor, options?: { encoding?: null | undefined, flag?: string | undefined } | null): Buffer,
169
169
  * (path: PathOrFileDescriptor, options: { encoding: BufferEncoding, flag?: string | undefined } | BufferEncoding): string,
170
- * (path: PathOrFileDescriptor, options?: (ObjectEncodingOptions & { flag?: string | undefined }) | BufferEncoding | null): string | Buffer,
170
+ * (path: PathOrFileDescriptor, options: ObjectEncodingOptions & { flag?: string | undefined }): string | Buffer,
171
171
  * }} ReadFileSync
172
172
  */
173
173
 
@@ -402,6 +402,21 @@ const { ABSOLUTE_PATH_REGEXP } = require("./identifier");
402
402
  * @typedef {(path: PathLike, options?: BufferEncoding | ReadStreamOptions) => NodeJS.ReadableStream} CreateReadStream
403
403
  */
404
404
 
405
+ /**
406
+ * Defines the symlink type used by this module.
407
+ * @typedef {(target: PathLike, path: PathLike, type: "dir" | "file" | "junction" | null | undefined, callback: NoParamCallback) => void} Symlink
408
+ */
409
+
410
+ /**
411
+ * Defines the chmod type used by this module.
412
+ * @typedef {(path: PathLike, mode: number | string, callback: NoParamCallback) => void} Chmod
413
+ */
414
+
415
+ /**
416
+ * Defines the utimes type used by this module.
417
+ * @typedef {(path: PathLike, atime: number | string | Date, mtime: number | string | Date, callback: NoParamCallback) => void} Utimes
418
+ */
419
+
405
420
  /**
406
421
  * Defines the output file system type used by this module.
407
422
  * @typedef {object} OutputFileSystem
@@ -410,6 +425,10 @@ const { ABSOLUTE_PATH_REGEXP } = require("./identifier");
410
425
  * @property {Rmdir=} rmdir
411
426
  * @property {WriteFile} writeFile
412
427
  * @property {Unlink=} unlink
428
+ * @property {Symlink=} symlink
429
+ * @property {Readlink=} readlink
430
+ * @property {Chmod=} chmod
431
+ * @property {Utimes=} utimes
413
432
  * @property {Stat} stat
414
433
  * @property {LStat=} lstat
415
434
  * @property {ReadFile} readFile
@@ -755,6 +774,13 @@ const lstatReadlinkAbsolute = (fs, p, callback) => {
755
774
  */
756
775
  const isAbsolute = (pathname) => ABSOLUTE_PATH_REGEXP.test(pathname);
757
776
 
777
+ /**
778
+ * What of a file's mode is its permissions — the type bits above them are not
779
+ * settable, and the set-user-id and sticky bits are not carried over a copy.
780
+ */
781
+ const PERMISSIONS_MASK = 0o777;
782
+
783
+ module.exports.PERMISSIONS_MASK = PERMISSIONS_MASK;
758
784
  module.exports.dirname = dirname;
759
785
  module.exports.isAbsolute = isAbsolute;
760
786
  module.exports.join = join;
@@ -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": () =>
@@ -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.3",
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",