@depup/webpack 5.110.3-depup.0 → 5.111.1-depup.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 (283) hide show
  1. package/README.md +7 -8
  2. package/changes.json +7 -11
  3. package/lib/APIPlugin.js +26 -11
  4. package/lib/AutomaticPrefetchPlugin.js +1 -1
  5. package/lib/Cache.js +8 -3
  6. package/lib/CacheFacade.js +1 -1
  7. package/lib/CircularModulesPlugin.js +157 -55
  8. package/lib/CleanPlugin.js +2 -2
  9. package/lib/CompatibilityPlugin.js +3 -4
  10. package/lib/Compilation.js +336 -337
  11. package/lib/Compiler.js +213 -51
  12. package/lib/ConstPlugin.js +16 -132
  13. package/lib/CopyPlugin.js +1054 -0
  14. package/lib/DefinePlugin.js +24 -8
  15. package/lib/DependencyTemplate.js +2 -1
  16. package/lib/DotenvPlugin.js +24 -28
  17. package/lib/ErrorHelpers.js +113 -0
  18. package/lib/ExportsInfo.js +20 -16
  19. package/lib/ExternalModule.js +47 -22
  20. package/lib/FileSystemInfo.js +17 -14
  21. package/lib/FlagDependencyExportsPlugin.js +53 -34
  22. package/lib/FlagDependencyUsagePlugin.js +9 -13
  23. package/lib/Generator.js +24 -2
  24. package/lib/HotModuleReplacementPlugin.js +55 -7
  25. package/lib/IgnorePlugin.js +1 -1
  26. package/lib/JavascriptMetaInfoPlugin.js +5 -3
  27. package/lib/LoaderOptionsPlugin.js +1 -1
  28. package/lib/MainTemplate.js +5 -1
  29. package/lib/Module.js +19 -10
  30. package/lib/ModuleGraph.js +6 -9
  31. package/lib/MultiCompiler.js +7 -17
  32. package/lib/MultiWatching.js +1 -1
  33. package/lib/NormalModule.js +135 -50
  34. package/lib/NormalModuleFactory.js +1 -1
  35. package/lib/RuntimeGlobals.js +21 -7
  36. package/lib/RuntimeModule.js +28 -12
  37. package/lib/RuntimePlugin.js +30 -3
  38. package/lib/RuntimeTemplate.js +813 -518
  39. package/lib/SourceMapDevToolPlugin.js +54 -104
  40. package/lib/TemplatedPathPlugin.js +16 -59
  41. package/lib/Watching.js +9 -0
  42. package/lib/WebpackOptionsApply.js +84 -91
  43. package/lib/asset/AssetBytesGenerator.js +7 -1
  44. package/lib/asset/AssetGenerator.js +50 -24
  45. package/lib/asset/AssetModule.js +3 -0
  46. package/lib/asset/AssetSourceGenerator.js +7 -1
  47. package/lib/asset/WebManifestParser.js +7 -5
  48. package/lib/buildChunkGraph.js +11 -15
  49. package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
  50. package/lib/cache/IdleFileCachePlugin.js +2 -2
  51. package/lib/cache/MemoryCachePlugin.js +4 -4
  52. package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
  53. package/lib/cache/PackFileCacheStrategy.js +17 -19
  54. package/lib/cache/getLazyHashedEtag.js +3 -5
  55. package/lib/config/browserslistTargetHandler.js +17 -4
  56. package/lib/config/defaults.js +138 -128
  57. package/lib/config/getClaimedAssetTypes.js +10 -11
  58. package/lib/config/normalization.js +82 -12
  59. package/lib/config/target.js +13 -4
  60. package/lib/container/ContainerReferencePlugin.js +6 -0
  61. package/lib/container/RemoteRuntimeModule.js +9 -0
  62. package/lib/container/declaredRemotes.js +39 -0
  63. package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
  64. package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
  65. package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
  66. package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
  67. package/lib/css/CssGenerator.js +27 -11
  68. package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
  69. package/lib/css/CssLoadingRuntimeModule.js +94 -36
  70. package/lib/css/CssModule.js +1 -1
  71. package/lib/css/CssModulesPlugin.js +7 -6
  72. package/lib/css/CssParser.js +162 -31
  73. package/lib/css/CssServerStylesRuntimeModule.js +9 -0
  74. package/lib/css/cssMinify.js +43 -32
  75. package/lib/css/data.js +3514 -869
  76. package/lib/css/syntax.js +6370 -1220
  77. package/lib/debug/ProfilingPlugin.js +7 -4
  78. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
  79. package/lib/dependencies/AMDRuntimeModules.js +18 -0
  80. package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
  81. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
  82. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
  83. package/lib/dependencies/CommonJsPlugin.js +19 -3
  84. package/lib/dependencies/CommonJsRequireDependency.js +14 -5
  85. package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
  86. package/lib/dependencies/ContextDependency.js +1 -1
  87. package/lib/dependencies/ContextDependencyHelpers.js +3 -9
  88. package/lib/dependencies/ContextElementDependency.js +1 -1
  89. package/lib/dependencies/CssIcssExportDependency.js +13 -9
  90. package/lib/dependencies/CssIcssImportDependency.js +3 -6
  91. package/lib/dependencies/CssUrlDependency.js +3 -5
  92. package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
  93. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
  94. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +10 -7
  95. package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
  96. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +74 -17
  97. package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
  98. package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
  99. package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
  100. package/lib/dependencies/HarmonyImportDependency.js +6 -1
  101. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +111 -17
  102. package/lib/dependencies/HarmonyImportSideEffectDependency.js +3 -4
  103. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
  104. package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
  105. package/lib/dependencies/HtmlEntryDependency.js +124 -102
  106. package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
  107. package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
  108. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  109. package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
  110. package/lib/dependencies/ImportMetaMainDependency.js +104 -0
  111. package/lib/dependencies/ImportMetaPlugin.js +67 -25
  112. package/lib/dependencies/ImportParserPlugin.js +1 -1
  113. package/lib/dependencies/LoaderPlugin.js +26 -1
  114. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  115. package/lib/dependencies/SystemRuntimeModule.js +9 -0
  116. package/lib/dependencies/URLContextDependency.js +1 -1
  117. package/lib/dependencies/URLDependency.js +6 -5
  118. package/lib/dependencies/WorkerAndWorkletPlugin.js +15 -21
  119. package/lib/dependencies/WorkerDependency.js +7 -7
  120. package/lib/dependencies/WorkletDependency.js +7 -11
  121. package/lib/dll/DelegatedModule.js +18 -1
  122. package/lib/dll/DllReferencePlugin.js +11 -8
  123. package/lib/dll/LibManifestPlugin.js +1 -1
  124. package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
  125. package/lib/errors/DuplicateModulesWarning.js +12 -7
  126. package/lib/errors/EmptyCopyPatternWarning.js +26 -0
  127. package/lib/errors/ExternalStarReexportError.js +44 -0
  128. package/lib/errors/HookWebpackError.js +3 -2
  129. package/lib/errors/MissingSourceMapsWarning.js +36 -0
  130. package/lib/errors/ModuleParseError.js +2 -1
  131. package/lib/errors/UnusedAssetsWarning.js +36 -0
  132. package/lib/errors/UnusedFederationWarning.js +35 -0
  133. package/lib/errors/UnusedModulesWarning.js +38 -0
  134. package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
  135. package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
  136. package/lib/esm/ModuleChunkLoadingPlugin.js +30 -11
  137. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +92 -60
  138. package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
  139. package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
  140. package/lib/hmr/LazyCompilationPlugin.js +3 -5
  141. package/lib/html/HtmlGenerator.js +72 -87
  142. package/lib/html/HtmlModulesPlugin.js +418 -200
  143. package/lib/html/HtmlParser.js +110 -147
  144. package/lib/html/builtinEmbeddedRenderer.js +107 -0
  145. package/lib/html/data.js +142 -7
  146. package/lib/html/htmlMinify.js +92 -122
  147. package/lib/html/syntax.js +1618 -1391
  148. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  149. package/lib/index.js +49 -3
  150. package/lib/javascript/ChunkFormatHelpers.js +4 -3
  151. package/lib/javascript/JavascriptGenerator.js +8 -1
  152. package/lib/javascript/JavascriptModule.js +1 -0
  153. package/lib/javascript/JavascriptModulesPlugin.js +73 -72
  154. package/lib/javascript/JavascriptParser.js +1970 -900
  155. package/lib/javascript/StartupHelpers.js +27 -3
  156. package/lib/javascript/data.js +172 -0
  157. package/lib/javascript/grammar.js +5546 -0
  158. package/lib/javascript/parser.js +1500 -0
  159. package/lib/javascript/regexp.js +1762 -0
  160. package/lib/javascript/regexpData.js +51 -0
  161. package/lib/javascript/syntax.js +9061 -5262
  162. package/lib/json/JsonGenerator.js +7 -1
  163. package/lib/library/ModuleLibraryPlugin.js +171 -132
  164. package/lib/loaders/LoaderRunner.js +137 -9
  165. package/lib/node/NodeWatchFileSystem.js +3 -9
  166. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
  167. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
  168. package/lib/optimize/AggressiveMergingPlugin.js +3 -5
  169. package/lib/optimize/ConcatenatedModule.js +178 -120
  170. package/lib/optimize/ConstExportsPlugin.js +50 -39
  171. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
  172. package/lib/optimize/InlineExports.js +20 -123
  173. package/lib/optimize/InnerGraphPlugin.js +7 -13
  174. package/lib/optimize/LimitChunkCountPlugin.js +5 -8
  175. package/lib/optimize/MangleExportsPlugin.js +13 -4
  176. package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
  177. package/lib/optimize/RealContentHashPlugin.js +68 -9
  178. package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
  179. package/lib/optimize/SplitChunksPlugin.js +2 -4
  180. package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
  181. package/lib/performance/BroadContextsPlugin.js +1 -1
  182. package/lib/performance/CacheEffectivenessPlugin.js +7 -7
  183. package/lib/performance/DuplicateModulesPlugin.js +57 -13
  184. package/lib/performance/EvalUsagePlugin.js +5 -2
  185. package/lib/performance/MissingSourceMapsPlugin.js +115 -0
  186. package/lib/performance/PureAnnotationsPlugin.js +6 -3
  187. package/lib/performance/SizeLimitsPlugin.js +2 -4
  188. package/lib/performance/TopLevelThisPlugin.js +5 -4
  189. package/lib/performance/UnusedAssetsPlugin.js +109 -0
  190. package/lib/performance/UnusedFederationPlugin.js +147 -0
  191. package/lib/performance/UnusedModulesPlugin.js +141 -0
  192. package/lib/performance/UnusedReexportsPlugin.js +1 -55
  193. package/lib/performance/isOnlyReexported.js +65 -0
  194. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
  195. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
  196. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
  197. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
  198. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
  199. package/lib/prefetch/ResourceHintPlugin.js +18 -23
  200. package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
  201. package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
  202. package/lib/rules/RuleSetCompiler.js +211 -4
  203. package/lib/runtime/AsyncModuleRuntimeModule.js +98 -66
  204. package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
  205. package/lib/runtime/BaseUriRuntimeModule.js +9 -0
  206. package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
  207. package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
  208. package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
  209. package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
  210. package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
  211. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
  212. package/lib/runtime/GlobalRuntimeModule.js +11 -4
  213. package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
  214. package/lib/runtime/HelperRuntimeModule.js +10 -0
  215. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +305 -224
  216. package/lib/runtime/NonceRuntimeModule.js +9 -0
  217. package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
  218. package/lib/runtime/PublicPathRuntimeModule.js +9 -0
  219. package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
  220. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
  221. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
  222. package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
  223. package/lib/runtime/SystemContextRuntimeModule.js +9 -0
  224. package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
  225. package/lib/schemes/DataUriPlugin.js +3 -6
  226. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  227. package/lib/serialization/BinaryMiddleware.js +9 -9
  228. package/lib/serialization/FileMiddleware.js +16 -16
  229. package/lib/serialization/ObjectMiddleware.js +168 -139
  230. package/lib/sharing/ConsumeSharedPlugin.js +12 -0
  231. package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
  232. package/lib/sharing/ShareRuntimeModule.js +9 -0
  233. package/lib/sharing/declaredShared.js +47 -0
  234. package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
  235. package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
  236. package/lib/typescript/TypeScriptPlugin.js +2 -3
  237. package/lib/url/URLParserPlugin.js +6 -8
  238. package/lib/util/LocConverter.js +4 -7
  239. package/lib/util/SourceProcessor.js +91 -91
  240. package/lib/util/async.js +292 -0
  241. package/lib/util/buildDiagnostics.js +69 -0
  242. package/lib/util/chainedImports.js +3 -4
  243. package/lib/util/concatenate.js +4 -4
  244. package/lib/util/createHooksRegistry.js +1 -2
  245. package/lib/util/dataURL.js +2 -3
  246. package/lib/util/deterministicGrouping.js +8 -13
  247. package/lib/util/findGraphRoots.js +6 -13
  248. package/lib/util/fs.js +27 -1
  249. package/lib/util/globUtils.js +1 -1
  250. package/lib/util/handlerKeys.js +40 -0
  251. package/lib/util/hash/wasm-hash.js +3 -4
  252. package/lib/util/identifier.js +20 -0
  253. package/lib/util/internalSerializables.js +5 -1
  254. package/lib/util/registerExternalSerializer.js +6 -45
  255. package/lib/util/semver.js +5 -3
  256. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +9 -0
  257. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +9 -0
  258. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
  259. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
  260. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
  261. package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
  262. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
  263. package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
  264. package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
  265. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
  266. package/package.json +55 -46
  267. package/schemas/WebpackOptions.check.js +1 -1
  268. package/schemas/WebpackOptions.json +379 -66
  269. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  270. package/schemas/plugins/ManifestPlugin.check.js +1 -1
  271. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  272. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  273. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  274. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  275. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  276. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  277. package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
  278. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
  279. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  280. package/types.d.ts +1723 -604
  281. package/lib/dependencies/ExportBindingInitFragment.js +0 -191
  282. package/lib/errors/EntrypointOverlapWarning.js +0 -45
  283. package/lib/performance/EntrypointOverlapPlugin.js +0 -122
@@ -17,19 +17,18 @@ const { matchObject } = require("../ModuleFilenameHelpers");
17
17
  * @returns {boolean} whether the candidate minimizes that file
18
18
  */
19
19
  const claims = (candidate, file) => {
20
- // Every minimizer in the `minimizer-webpack-plugin` family (itself,
21
- // `css-minimizer-webpack-plugin`, `html-minimizer-webpack-plugin`, …) keeps
22
- // the minify implementation on `options.minimizer` and its asset matcher
23
- // alongside it in the shape `matchObject` reads. The matcher alone is not
24
- // enough to recognize one: `BannerPlugin` and `SourceMapDevToolPlugin` carry
25
- // the same three keys, and `LoaderOptionsPlugin` defaults `test` to match
26
- // every file — reading those as minimizers would disable minification.
20
+ // WHY: every minimizer in the `minimizer-webpack-plugin` family — itself,
21
+ // `css-minimizer-webpack-plugin`, `html-minimizer-webpack-plugin`, … — keeps
22
+ // its implementation on `options.minimizer` and its asset matcher alongside
23
+ // it, in the shape `matchObject` reads. The matcher alone is not enough to
24
+ // recognize one: `BannerPlugin` and `SourceMapDevToolPlugin` carry the same
25
+ // three keys, and `LoaderOptionsPlugin` defaults `test` to match every file,
26
+ // so reading those as minimizers would disable minification.
27
27
  const { options } = /** @type {{ options?: MinimizerOptions }} */ (candidate);
28
28
  if (!options || !options.minimizer) return false;
29
- // `test`/`include` say which types it handles, `exclude` only narrows the
30
- // files within them — honouring that narrowing would make a minimizer scoped
31
- // to a subdirectory claim nothing, and webpack would then race it on the very
32
- // files it was configured for.
29
+ // `test` and `include` say which types it handles, while `exclude` only
30
+ // narrows the files within them: honoring that narrowing would let a minimizer
31
+ // scoped to a subdirectory claim nothing, and webpack would then race it.
33
32
  const { test, include } = options;
34
33
  return (
35
34
  (test !== undefined && matchObject({ test }, file)) ||
@@ -6,6 +6,7 @@
6
6
  "use strict";
7
7
 
8
8
  const util = require("util");
9
+ const { fileUrlToPath } = require("../util/identifier");
9
10
 
10
11
  /**
11
12
  * @import {
@@ -138,6 +139,28 @@ const keyedNestedConfig = (value, fn, customKeys) => {
138
139
  return result;
139
140
  };
140
141
 
142
+ /**
143
+ * Converts a file URL to the path it names. Anything that is not a string is
144
+ * returned unchanged, so `false` and `undefined` pass through.
145
+ * @template {string | false | undefined} T
146
+ * @param {T} pathOrUrl an absolute path, a file URL, `false` or `undefined`
147
+ * @returns {T} an absolute path, `false` or `undefined`
148
+ */
149
+ const optionalFileUrlToPath = (pathOrUrl) =>
150
+ typeof pathOrUrl === "string"
151
+ ? /** @type {T} */ (fileUrlToPath(pathOrUrl))
152
+ : pathOrUrl;
153
+
154
+ /**
155
+ * Converts every file URL of a list to the path it names.
156
+ * @param {(string | RegExp)[]} pathsOrUrls absolute paths, file URLs or regular expressions
157
+ * @returns {(string | RegExp)[]} absolute paths and regular expressions
158
+ */
159
+ const fileUrlsToPaths = (pathsOrUrls) =>
160
+ pathsOrUrls.map((pathOrUrl) =>
161
+ typeof pathOrUrl === "string" ? fileUrlToPath(pathOrUrl) : pathOrUrl
162
+ );
163
+
141
164
  /**
142
165
  * Normalize `output.resourceHints` into its object form: the scalar / array /
143
166
  * function shorthand becomes `{ initial: <value> }` (with `"preload"` aliased to
@@ -162,6 +185,40 @@ const normalizeResourceHints = (resourceHints) => {
162
185
  return { initial: alias(resourceHints) };
163
186
  };
164
187
 
188
+ /**
189
+ * @typedef {object} NormalizedBuildDependencyItem
190
+ * @property {string} dependency request to resolve
191
+ * @property {boolean} optional when true the dependency may be missing
192
+ */
193
+
194
+ /**
195
+ * @param {import("../../declarations/WebpackOptions").BuildDependencyItem} item build dependency
196
+ * @returns {NormalizedBuildDependencyItem} normalized build dependency
197
+ */
198
+ const normalizeBuildDependencyItem = (item) => {
199
+ if (typeof item === "string") {
200
+ return { dependency: item, optional: false };
201
+ }
202
+ return {
203
+ dependency: item.dependency,
204
+ optional: item.optional === true
205
+ };
206
+ };
207
+
208
+ /**
209
+ * @param {import("../../declarations/WebpackOptions").FileCacheOptions["buildDependencies"]=} buildDependencies build dependencies
210
+ * @returns {Record<string, NormalizedBuildDependencyItem[]>} normalized build dependencies
211
+ */
212
+ const normalizeBuildDependencies = (buildDependencies) => {
213
+ /** @type {Record<string, NormalizedBuildDependencyItem[]>} */
214
+ const result = Object.create(null);
215
+ if (buildDependencies === undefined) return result;
216
+ for (const key of Object.keys(buildDependencies)) {
217
+ result[key] = buildDependencies[key].map(normalizeBuildDependencyItem);
218
+ }
219
+ return result;
220
+ };
221
+
165
222
  /**
166
223
  * Gets normalized webpack options.
167
224
  * @param {WebpackOptions} config input config
@@ -189,9 +246,11 @@ const getNormalizedWebpackOptions = (config) => ({
189
246
  maxMemoryGenerations: cache.maxMemoryGenerations,
190
247
  maxAge: cache.maxAge,
191
248
  profile: cache.profile,
192
- buildDependencies: cloneObject(cache.buildDependencies),
193
- cacheDirectory: cache.cacheDirectory,
194
- cacheLocation: cache.cacheLocation,
249
+ buildDependencies: normalizeBuildDependencies(
250
+ cache.buildDependencies
251
+ ),
252
+ cacheDirectory: optionalFileUrlToPath(cache.cacheDirectory),
253
+ cacheLocation: optionalFileUrlToPath(cache.cacheLocation),
195
254
  hashAlgorithm: cache.hashAlgorithm,
196
255
  compression: cache.compression,
197
256
  idleTimeout: cache.idleTimeout,
@@ -214,7 +273,7 @@ const getNormalizedWebpackOptions = (config) => ({
214
273
  }
215
274
  })
216
275
  ),
217
- context: config.context,
276
+ context: optionalFileUrlToPath(config.context),
218
277
  dependencies: config.dependencies,
219
278
  devServer: optionalNestedConfig(config.devServer, (devServer) => {
220
279
  if (devServer === false) return false;
@@ -381,6 +440,9 @@ const getNormalizedWebpackOptions = (config) => ({
381
440
  cssChunkFilename: output.cssChunkFilename,
382
441
  clean: output.clean,
383
442
  compareBeforeEmit: output.compareBeforeEmit,
443
+ copy: optionalNestedConfig(output.copy, (copy) => ({
444
+ patterns: typeof copy === "string" ? [copy] : [...copy]
445
+ })),
384
446
  crossOriginLoading: output.crossOriginLoading,
385
447
  devtoolFallbackModuleFilenameTemplate:
386
448
  output.devtoolFallbackModuleFilenameTemplate,
@@ -439,7 +501,7 @@ const getNormalizedWebpackOptions = (config) => ({
439
501
  : libraryBase.umdNamedDefine
440
502
  },
441
503
  module: output.module,
442
- path: output.path,
504
+ path: optionalFileUrlToPath(output.path),
443
505
  pathinfo: output.pathinfo,
444
506
  publicPath: output.publicPath,
445
507
  resourceHints: normalizeResourceHints(output.resourceHints),
@@ -481,14 +543,16 @@ const getNormalizedWebpackOptions = (config) => ({
481
543
  nestedArray(config.plugins, (p) => p.filter(Boolean))
482
544
  ),
483
545
  profile: config.profile,
484
- recordsInputPath:
546
+ recordsInputPath: optionalFileUrlToPath(
485
547
  config.recordsInputPath !== undefined
486
548
  ? config.recordsInputPath
487
- : config.recordsPath,
488
- recordsOutputPath:
549
+ : config.recordsPath
550
+ ),
551
+ recordsOutputPath: optionalFileUrlToPath(
489
552
  config.recordsOutputPath !== undefined
490
553
  ? config.recordsOutputPath
491
- : config.recordsPath,
554
+ : config.recordsPath
555
+ ),
492
556
  resolve: nestedConfig(config.resolve, (resolve) => ({
493
557
  ...resolve,
494
558
  byDependency: keyedNestedConfig(resolve.byDependency, cloneObject)
@@ -524,9 +588,15 @@ const getNormalizedWebpackOptions = (config) => ({
524
588
  hash: contextModule.hash
525
589
  })
526
590
  ),
527
- immutablePaths: optionalNestedArray(snapshot.immutablePaths, (p) => [...p]),
528
- managedPaths: optionalNestedArray(snapshot.managedPaths, (p) => [...p]),
529
- unmanagedPaths: optionalNestedArray(snapshot.unmanagedPaths, (p) => [...p])
591
+ immutablePaths: optionalNestedArray(
592
+ snapshot.immutablePaths,
593
+ fileUrlsToPaths
594
+ ),
595
+ managedPaths: optionalNestedArray(snapshot.managedPaths, fileUrlsToPaths),
596
+ unmanagedPaths: optionalNestedArray(
597
+ snapshot.unmanagedPaths,
598
+ fileUrlsToPaths
599
+ )
530
600
  })),
531
601
  stats: nestedConfig(config.stats, (stats) => {
532
602
  if (stats === false) {
@@ -82,6 +82,7 @@ const getDefaultTarget = (context) => {
82
82
  * @property {boolean | null} templateLiteral template literal is available
83
83
  * @property {boolean | null} asyncFunction async functions and await are available
84
84
  * @property {boolean | null} generator generator functions and yield are available
85
+ * @property {boolean | null} topLevelAwait top-level await is available
85
86
  * @property {(boolean | null)=} deferImport deferred evaluation (`import defer`, `import.defer()`) is available (optional; absent means "assume unavailable")
86
87
  * @property {(boolean | null)=} sourceImport source phase imports (`import source`, `import.source()`) are available (optional; absent means "assume unavailable")
87
88
  */
@@ -269,6 +270,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
269
270
  arrowFunction: v(6),
270
271
  asyncFunction: v(7, 6),
271
272
  generator: v(4),
273
+ // v14.8.0
274
+ topLevelAwait: v(14, 8),
272
275
  forOf: v(5),
273
276
  destructuring: v(6),
274
277
  bigIntLiteral: v(10, 4),
@@ -329,6 +332,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
329
332
  templateLiteral: true,
330
333
  asyncFunction: true,
331
334
  generator: true,
335
+ topLevelAwait: true,
332
336
  // import defer - v2.8.0
333
337
  deferImport: v(2, 8),
334
338
  // import source - v2.6.0
@@ -341,10 +345,9 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
341
345
  "Bun in version X.Y. Output is always ECMAScript modules. Examples: bun, bun1.1.",
342
346
  /^bun((\d+)(?:\.(\d+))?)?$/,
343
347
  () => ({
344
- // Bun is a modern, Node.js-compatible runtime; every released version
345
- // supports the full modern ECMAScript feature set, so the version is
346
- // accepted but does not gate any feature. Output is always ESM, so sync
347
- // CommonJS `require` is never available.
348
+ // Every released Bun supports the full modern feature set, so a version is
349
+ // accepted but gates nothing. Output is always ESM, leaving no synchronous
350
+ // CommonJS `require`.
348
351
  node: true,
349
352
  bun: true,
350
353
  web: false,
@@ -380,6 +383,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
380
383
  arrowFunction: true,
381
384
  asyncFunction: true,
382
385
  generator: true,
386
+ topLevelAwait: true,
383
387
  forOf: true,
384
388
  destructuring: true,
385
389
  bigIntLiteral: true,
@@ -437,6 +441,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
437
441
  arrowFunction: v(1, 1),
438
442
  asyncFunction: v(1, 7),
439
443
  generator: v(1, 1),
444
+ // 12.0.0 - Chromium 89
445
+ topLevelAwait: v(12),
440
446
  forOf: v(0, 36),
441
447
  destructuring: v(1, 1),
442
448
  bigIntLiteral: v(4),
@@ -486,6 +492,8 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
486
492
  arrowFunction: v(0, 15),
487
493
  asyncFunction: v(0, 21),
488
494
  generator: v(0, 15),
495
+ // 0.52.0 - Chromium 89
496
+ topLevelAwait: v(0, 52),
489
497
  forOf: v(0, 13),
490
498
  destructuring: v(0, 15),
491
499
  bigIntLiteral: v(0, 32),
@@ -515,6 +523,7 @@ You can also more options via the 'target' option: 'browserslist' / 'browserslis
515
523
  destructuring: v >= 2015,
516
524
  module: v >= 2015,
517
525
  asyncFunction: v >= 2017,
526
+ topLevelAwait: v >= 2022,
518
527
  generator: v >= 2015,
519
528
  globalThis: v >= 2020,
520
529
  symbol: v >= 2015,
@@ -14,6 +14,7 @@ const FallbackModuleFactory = require("./FallbackModuleFactory");
14
14
  const RemoteModule = require("./RemoteModule");
15
15
  const RemoteRuntimeModule = require("./RemoteRuntimeModule");
16
16
  const RemoteToExternalDependency = require("./RemoteToExternalDependency");
17
+ const { addDeclaredRemotes } = require("./declaredRemotes");
17
18
  const { parseOptions } = require("./options");
18
19
 
19
20
  /**
@@ -91,6 +92,11 @@ class ContainerReferencePlugin {
91
92
  compiler.hooks.compilation.tap(
92
93
  PLUGIN_NAME,
93
94
  (compilation, { normalModuleFactory }) => {
95
+ addDeclaredRemotes(
96
+ compilation,
97
+ remotes.map(([key]) => key)
98
+ );
99
+
94
100
  compilation.dependencyFactories.set(
95
101
  RemoteToExternalDependency,
96
102
  normalModuleFactory
@@ -20,6 +20,15 @@ class RemoteRuntimeModule extends RuntimeModule {
20
20
  super("remotes loading");
21
21
  }
22
22
 
23
+ /**
24
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
25
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
26
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
27
+ */
28
+ getInstalledChunkHandlers() {
29
+ return [[RuntimeGlobals.ensureChunkHandlers, "remotes"]];
30
+ }
31
+
23
32
  /**
24
33
  * Generates runtime code for this runtime module.
25
34
  * @returns {string | null} runtime code
@@ -0,0 +1,39 @@
1
+ /*
2
+ MIT License http://www.opensource.org/licenses/mit-license.php
3
+ Author Alexander Akait @alexander-akait
4
+ */
5
+
6
+ "use strict";
7
+
8
+ /** @import Compilation from "../Compilation" */
9
+
10
+ /** @type {WeakMap<Compilation, Set<string>>} */
11
+ const DECLARED_REMOTES = new WeakMap();
12
+
13
+ /**
14
+ * The remote names this build declared, in declaration order, which is the
15
+ * order `factorize` resolves a request against them in.
16
+ * @param {Compilation} compilation the compilation
17
+ * @returns {Set<string> | undefined} the declared names, when any were declared
18
+ */
19
+ const getDeclaredRemotes = (compilation) => DECLARED_REMOTES.get(compilation);
20
+
21
+ /**
22
+ * Records declared names, adding to any a previous application made.
23
+ * @param {Compilation} compilation the compilation
24
+ * @param {Iterable<string>} names what this application declared
25
+ * @returns {void}
26
+ */
27
+ const addDeclaredRemotes = (compilation, names) => {
28
+ let declared = DECLARED_REMOTES.get(compilation);
29
+
30
+ if (declared === undefined) {
31
+ declared = new Set();
32
+ DECLARED_REMOTES.set(compilation, declared);
33
+ }
34
+
35
+ for (const name of names) declared.add(name);
36
+ };
37
+
38
+ module.exports.addDeclaredRemotes = addDeclaredRemotes;
39
+ module.exports.getDeclaredRemotes = getDeclaredRemotes;
@@ -4,7 +4,7 @@
4
4
 
5
5
  "use strict";
6
6
 
7
- /** @import Compiler from "./Compiler" */
7
+ /** @import Compiler from "../Compiler" */
8
8
 
9
9
  const PLUGIN_NAME = "ContextExclusionPlugin";
10
10
 
@@ -6,49 +6,52 @@
6
6
  "use strict";
7
7
 
8
8
  const { OriginalSource, RawSource } = require("webpack-sources");
9
- const AsyncDependenciesBlock = require("./AsyncDependenciesBlock");
10
- const Module = require("./Module");
9
+ const AsyncDependenciesBlock = require("../AsyncDependenciesBlock");
10
+ const Module = require("../Module");
11
11
  const {
12
12
  JAVASCRIPT_TYPE,
13
13
  JAVASCRIPT_TYPES
14
- } = require("./ModuleSourceTypeConstants");
15
- const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("./ModuleTypeConstants");
16
- const RuntimeGlobals = require("./RuntimeGlobals");
17
- const Template = require("./Template");
14
+ } = require("../ModuleSourceTypeConstants");
15
+ const { JAVASCRIPT_MODULE_TYPE_DYNAMIC } = require("../ModuleTypeConstants");
16
+ const RuntimeGlobals = require("../RuntimeGlobals");
17
+ const Template = require("../Template");
18
18
  const {
19
19
  getOutgoingAsyncModules
20
- } = require("./async-modules/AsyncModuleHelpers");
21
- const { ImportPhase, ImportPhaseUtils } = require("./dependencies/ImportPhase");
22
- const { makeWebpackError } = require("./errors/HookWebpackError");
23
- const WebpackError = require("./errors/WebpackError");
20
+ } = require("../async-modules/AsyncModuleHelpers");
21
+ const {
22
+ ImportPhase,
23
+ ImportPhaseUtils
24
+ } = require("../dependencies/ImportPhase");
25
+ const { makeWebpackError } = require("../errors/HookWebpackError");
26
+ const WebpackError = require("../errors/WebpackError");
24
27
  const {
25
28
  compareLocations,
26
29
  compareModulesById,
27
30
  compareSelect,
28
31
  concatComparators,
29
32
  keepOriginalOrder
30
- } = require("./util/comparators");
33
+ } = require("../util/comparators");
31
34
  const {
32
35
  contextify,
33
36
  makePathsRelative,
34
37
  parseResource
35
- } = require("./util/identifier");
36
- const makeSerializable = require("./util/makeSerializable");
37
- const { propertyAccess } = require("./util/property");
38
+ } = require("../util/identifier");
39
+ const makeSerializable = require("../util/makeSerializable");
40
+ const { propertyAccess } = require("../util/property");
38
41
 
39
42
  /** @import { Source } from "webpack-sources" */
40
- /** @import { ResolveOptions } from "../declarations/WebpackOptions" */
43
+ /** @import { ResolveOptions } from "../../declarations/WebpackOptions" */
41
44
  /**
42
45
  * @import {
43
46
  * WebpackOptionsNormalizedWithDefaults as WebpackOptions
44
- * } from "./config/defaults"
47
+ * } from "../config/defaults"
45
48
  */
46
- /** @import Chunk, { ChunkId, ChunkName } from "./Chunk" */
47
- /** @import ChunkGraph, { ModuleId } from "./ChunkGraph" */
48
- /** @import { RawChunkGroupOptions } from "./ChunkGroup" */
49
- /** @import Compilation, { FileSystemDependencies } from "./Compilation" */
50
- /** @import Dependency, { RawReferencedExports } from "./Dependency" */
51
- /** @import { Snapshot } from "./FileSystemInfo" */
49
+ /** @import Chunk, { ChunkId, ChunkName } from "../Chunk" */
50
+ /** @import ChunkGraph, { ModuleId } from "../ChunkGraph" */
51
+ /** @import { RawChunkGroupOptions } from "../ChunkGroup" */
52
+ /** @import Compilation, { FileSystemDependencies } from "../Compilation" */
53
+ /** @import Dependency, { RawReferencedExports } from "../Dependency" */
54
+ /** @import { Snapshot } from "../FileSystemInfo" */
52
55
  /**
53
56
  * @import {
54
57
  * BuildCallback,
@@ -63,17 +66,17 @@ const { propertyAccess } = require("./util/property");
63
66
  * RuntimeRequirements,
64
67
  * Sources,
65
68
  * SourceTypes
66
- * } from "./Module"
69
+ * } from "../Module"
67
70
  */
68
- /** @import RequestShortener from "./RequestShortener" */
69
- /** @import { ResolverWithOptions } from "./ResolverFactory" */
70
- /** @import RuntimeTemplate from "./RuntimeTemplate" */
71
- /** @import ContextElementDependency from "./dependencies/ContextElementDependency" */
72
- /** @import { ImportAttributes } from "./javascript/JavascriptParser" */
73
- /** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext<[string, boolean]>} ObjectDeserializerContext */
74
- /** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext<[string, boolean]>} ObjectSerializerContext */
75
- /** @import { InputFileSystem } from "./util/fs" */
76
- /** @import { ImportPhaseType } from "./dependencies/ImportPhase" */
71
+ /** @import RequestShortener from "../RequestShortener" */
72
+ /** @import { ResolverWithOptions } from "../ResolverFactory" */
73
+ /** @import RuntimeTemplate from "../RuntimeTemplate" */
74
+ /** @import ContextElementDependency from "../dependencies/ContextElementDependency" */
75
+ /** @import { ImportAttributes } from "../javascript/JavascriptParser" */
76
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext<[string, boolean]>} ObjectDeserializerContext */
77
+ /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext<[string, boolean]>} ObjectSerializerContext */
78
+ /** @import { InputFileSystem } from "../util/fs" */
79
+ /** @import { ImportPhaseType } from "../dependencies/ImportPhase" */
77
80
 
78
81
  /** @typedef {"sync" | "eager" | "weak" | "async-weak" | "lazy" | "lazy-once"} ContextMode Context mode */
79
82
 
@@ -213,6 +216,7 @@ class ContextModule extends Module {
213
216
  * @returns {void}
214
217
  */
215
218
  updateCacheModule(module) {
219
+ super.updateCacheModule(module);
216
220
  const m = /** @type {ContextModule} */ (module);
217
221
  this.resolveDependencies = m.resolveDependencies;
218
222
  this.options = m.options;
@@ -878,7 +882,9 @@ class ContextModule extends Module {
878
882
  }
879
883
  const type =
880
884
  typeof fakeMap === "number" ? fakeMap : fakeMapDataExpression;
881
- return `${asyncDeps} ? ${asyncDeps}.length ? ${RuntimeGlobals.deferredModuleAsyncTransitiveDependencies}(${asyncDeps}).then(${RuntimeGlobals.makeDeferredNamespaceObject}.bind(${RuntimeGlobals.require}, id, ${type} ^ 1, true)) : ${RuntimeGlobals.makeDeferredNamespaceObject}(id, ${type} ^ 1 | 16) : ${source}`;
885
+ // The bound third argument absorbs the promise's resolved value, which
886
+ // would otherwise land in the export-names parameter.
887
+ return `${asyncDeps} ? ${asyncDeps}.length ? ${RuntimeGlobals.deferredModuleAsyncTransitiveDependencies}(${asyncDeps}).then(${RuntimeGlobals.makeDeferredNamespaceObject}.bind(${RuntimeGlobals.require}, id, ${type} ^ 1, undefined)) : ${RuntimeGlobals.makeDeferredNamespaceObject}(id, ${type} ^ 1 | 16) : ${source}`;
882
888
  }
883
889
  return source;
884
890
  }
@@ -1212,60 +1218,11 @@ module.exports = webpackAsyncContext;`;
1212
1218
  }
1213
1219
  const shortMode = hasNoChunk && hasNoModuleDeferred && !hasFakeMap;
1214
1220
  // Sorted before anything is keyed by request, so two items sharing one leave the
1215
- // same last writer in the map and in the loaders beside it.
1221
+ // same last writer in the map.
1216
1222
  const sortedItems = items.sort((a, b) => {
1217
1223
  if (a.userRequest === b.userRequest) return 0;
1218
1224
  return a.userRequest < b.userRequest ? -1 : 1;
1219
1225
  });
1220
- let needEnsureChunk = !hasNoChunk;
1221
- /** @type {Map<string, string[]> | undefined} */
1222
- let loaders;
1223
- // Only module output can name a chunk in an `import()`, so nothing else pays for
1224
- // building the loaders just to throw them away.
1225
- if (!hasNoChunk && runtimeTemplate.isModule()) {
1226
- /** @type {Map<string, string[]>} */
1227
- const perRequest = new Map();
1228
- let hasAnalyzable = false;
1229
- let hasFallback = false;
1230
- /**
1231
- * @param {Chunk} chunk one chunk a request needs
1232
- * @returns {string} a thunk loading it, by literal name where the chunk has one
1233
- */
1234
- const loaderFor = (chunk) => {
1235
- // `.ei` always imports, where `.e` skips a chunk already loaded — the same
1236
- // filter `blockPromise` applies before reaching for it.
1237
- const analyzable =
1238
- chunk.hasRuntime() || chunk.id === null
1239
- ? null
1240
- : runtimeTemplate.analyzableChunkImport(
1241
- chunk,
1242
- "",
1243
- runtimeRequirements,
1244
- this,
1245
- chunkGraph
1246
- );
1247
- if (analyzable !== null) {
1248
- hasAnalyzable = true;
1249
- return runtimeTemplate.returningFunction(analyzable);
1250
- }
1251
- hasFallback = true;
1252
- return runtimeTemplate.returningFunction(
1253
- `${RuntimeGlobals.ensureChunk}(${JSON.stringify(chunk.id)})`
1254
- );
1255
- };
1256
- for (const item of sortedItems) {
1257
- perRequest.set(
1258
- item.userRequest,
1259
- /** @type {Chunk[]} */ (item.chunks).map(loaderFor)
1260
- );
1261
- }
1262
- // Nothing gained when no chunk can be spelled out, and the plain id map is
1263
- // smaller, so the loaders are only written when at least one names its chunk.
1264
- if (hasAnalyzable) {
1265
- loaders = perRequest;
1266
- needEnsureChunk = hasFallback;
1267
- }
1268
- }
1269
1226
  /** @type {Record<string, ModuleId | (ModuleId | FakeMapType | ChunkId[] | (ModuleId[] | undefined))[]>} */
1270
1227
  const map = Object.create(null);
1271
1228
  for (const item of sortedItems) {
@@ -1299,16 +1256,16 @@ module.exports = webpackAsyncContext;`;
1299
1256
  const asyncDepsPosition = hasNoChunk ? chunksPosition : chunksPosition + 1;
1300
1257
  const requestPrefix = hasNoChunk
1301
1258
  ? "Promise.resolve()"
1302
- : loaders !== undefined
1303
- ? hasMultipleOrNoChunks
1304
- ? `Promise.all(ids[${chunksPosition}].map(${runtimeTemplate.returningFunction("load()", "load")}))`
1305
- : `ids[${chunksPosition}][0]()`
1306
- : hasMultipleOrNoChunks
1307
- ? `Promise.all(ids[${chunksPosition}].map(${RuntimeGlobals.ensureChunk}))`
1308
- : `${RuntimeGlobals.ensureChunk}(ids[${chunksPosition}][0])`;
1309
- // Only the id map reads it; nothing loads a chunk when there is none to load, and
1310
- // a map of loaders spells out every one it could reach for.
1311
- if (needEnsureChunk) {
1259
+ : hasMultipleOrNoChunks
1260
+ ? // Wrapped because `map` hands its callback an index too, which the loader
1261
+ // would otherwise read as a fetch priority.
1262
+ `Promise.all(ids[${chunksPosition}].map(${runtimeTemplate.returningFunction(
1263
+ `${RuntimeGlobals.ensureChunk}(id)`,
1264
+ "id"
1265
+ )}))`
1266
+ : `${RuntimeGlobals.ensureChunk}(ids[${chunksPosition}][0])`;
1267
+ // Nothing loads a chunk when there is none to load.
1268
+ if (!hasNoChunk) {
1312
1269
  runtimeRequirements.add(RuntimeGlobals.ensureChunk);
1313
1270
  }
1314
1271
  const returnModuleObject = this.getReturnModuleObjectSource(
@@ -1352,26 +1309,7 @@ function webpackAsyncContext(req) {
1352
1309
  return ${requestPrefix}.then(${runtimeTemplate.returningFunction(returnModuleObject)});
1353
1310
  }`;
1354
1311
 
1355
- // A loader is source, not data, so the map holding one is written out rather than
1356
- // serialized — one entry per line, keeping the request next to what loads it.
1357
- const mapSource =
1358
- loaders === undefined
1359
- ? JSON.stringify(map, null, "\t")
1360
- : `{\n${Object.keys(map)
1361
- .map((request) => {
1362
- const slots =
1363
- /** @type {(ModuleId | FakeMapType | ChunkId[] | (ModuleId[] | undefined))[]} */
1364
- (map[request]).map((slot, index) =>
1365
- index === chunksPosition
1366
- ? `[${/** @type {string[]} */ (loaders.get(request)).join(", ")}]`
1367
- : // An absent `asyncDeps` slot is `null` to `JSON.stringify`.
1368
- slot === undefined
1369
- ? "null"
1370
- : JSON.stringify(slot)
1371
- );
1372
- return `\t${JSON.stringify(request)}: [${slots.join(", ")}]`;
1373
- })
1374
- .join(",\n")}\n}`;
1312
+ const mapSource = JSON.stringify(map, null, "\t");
1375
1313
 
1376
1314
  return `${cst} map = ${mapSource};
1377
1315
  ${webpackAsyncContext}
@@ -1538,7 +1476,7 @@ module.exports = webpackEmptyAsyncContext;`;
1538
1476
  const returnModuleObject = this.getReturnModuleObjectSource(fakeMap);
1539
1477
  const globImportAccess = this.getImportPropertyAccess();
1540
1478
  const sortedDependencies =
1541
- /** @type {import("./dependencies/ContextElementDependency")[]} */
1479
+ /** @type {import("../dependencies/ContextElementDependency")[]} */
1542
1480
  (dependencies).sort((a, b) =>
1543
1481
  a.userRequest < b.userRequest
1544
1482
  ? -1
@@ -1742,6 +1680,7 @@ module.exports = webpackEmptyAsyncContext;`;
1742
1680
  ImportPhaseUtils.isDefer(this.options.phase || ImportPhase.Evaluation)
1743
1681
  ) {
1744
1682
  set.add(RuntimeGlobals.makeDeferredNamespaceObject);
1683
+ set.add(RuntimeGlobals.hasSynthesizedDeferredNamespace);
1745
1684
  }
1746
1685
  }
1747
1686
  return {
@@ -1788,6 +1727,6 @@ module.exports = webpackEmptyAsyncContext;`;
1788
1727
  }
1789
1728
  }
1790
1729
 
1791
- makeSerializable(ContextModule, "webpack/lib/ContextModule");
1730
+ makeSerializable(ContextModule, "webpack/lib/context/ContextModule");
1792
1731
 
1793
1732
  module.exports = ContextModule;