@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
@@ -0,0 +1,44 @@
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
+ const WebpackError = require("./WebpackError");
9
+
10
+ /** @import ExternalModule from "../ExternalModule" */
11
+ /** @import Module from "../Module" */
12
+
13
+ /**
14
+ * Error raised when a `module` library reexports everything from an external
15
+ * whose request names a property path instead of a module.
16
+ */
17
+ class ExternalStarReexportError extends WebpackError {
18
+ /**
19
+ * Captures the external and the library entry reexporting from it.
20
+ * @param {ExternalModule} externalModule the reexported external
21
+ * @param {Module} module the library entry module
22
+ */
23
+ constructor(externalModule, module) {
24
+ const request = /** @type {string[]} */ (
25
+ externalModule.getResolvedRequest()
26
+ );
27
+ super(
28
+ `Can't 'export * from ${JSON.stringify(
29
+ externalModule.userRequest
30
+ )}': the external is configured as ${JSON.stringify(
31
+ request
32
+ )}, which is a property of ${JSON.stringify(
33
+ request[0]
34
+ )} and has no module specifier to reexport. Reexport the names explicitly or configure the external without a property path.`
35
+ );
36
+
37
+ /** @type {string} */
38
+ this.name = "ExternalStarReexportError";
39
+ /** @type {Module} */
40
+ this.module = module;
41
+ }
42
+ }
43
+
44
+ module.exports = ExternalStarReexportError;
@@ -5,6 +5,7 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const { toError } = require("../ErrorHelpers");
8
9
  const makeSerializable = require("../util/makeSerializable");
9
10
  const WebpackError = require("./WebpackError");
10
11
 
@@ -67,13 +68,13 @@ makeSerializable(HookWebpackError, "webpack/lib/errors/HookWebpackError");
67
68
 
68
69
  /**
69
70
  * Creates webpack error.
70
- * @param {Error} error an error
71
+ * @param {EXPECTED_ANY} error what a plugin failed with
71
72
  * @param {string} hook name of the hook
72
73
  * @returns {WebpackError} a webpack error
73
74
  */
74
75
  const makeWebpackError = (error, hook) => {
75
76
  if (error instanceof WebpackError) return error;
76
- return new HookWebpackError(error, hook);
77
+ return new HookWebpackError(toError(error), hook);
77
78
  };
78
79
 
79
80
  HookWebpackError.makeWebpackError = makeWebpackError;
@@ -0,0 +1,36 @@
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
+ const WebpackError = require("./WebpackError");
9
+
10
+ /**
11
+ * @typedef {object} MissingSourceMapDetails
12
+ * @property {string} name the module, by request
13
+ * @property {string[]} loaders the loaders that ran on it
14
+ */
15
+
16
+ class MissingSourceMapsWarning extends WebpackError {
17
+ /**
18
+ * Creates an instance of MissingSourceMapsWarning.
19
+ * @param {MissingSourceMapDetails[]} modules the modules whose map was lost
20
+ * @param {number} total how many such modules there are
21
+ */
22
+ constructor(modules, total) {
23
+ const list = modules
24
+ .map((it) => `\n ${it.name} (${it.loaders.join(", ")})`)
25
+ .join("");
26
+
27
+ super(
28
+ `missing source maps: ${total} ${total === 1 ? "module was" : "modules were"} transformed by a loader that returned no source map:${list}\nA loader that rewrites code without returning a map leaves webpack mapping positions to the loader's output as though it were the file on disk, so every line the map names below that point is likely to be wrong. Have the loader pass its map to 'this.callback(null, code, map)', or take the loader out of the chain for this build.\nFor more info visit https://webpack.js.org/api/loaders/#thiscallback`
29
+ );
30
+
31
+ /** @type {string} */
32
+ this.name = "MissingSourceMapsWarning";
33
+ }
34
+ }
35
+
36
+ module.exports = MissingSourceMapsWarning;
@@ -101,7 +101,8 @@ class ModuleParseError extends WebpackError {
101
101
  }
102
102
  }
103
103
 
104
- loc = { start: err.loc };
104
+ // a plain copy: a parser's own position class must not reach the cache
105
+ loc = { start: { line: lineNumber, column: err.loc.column } };
105
106
  } else if (err && err.stack) {
106
107
  message += `\n${err.stack}`;
107
108
  }
@@ -0,0 +1,36 @@
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
+ const WebpackError = require("./WebpackError");
9
+
10
+ /**
11
+ * @typedef {object} UnusedAssetDetails
12
+ * @property {string} name the module, by request
13
+ * @property {number} size the bytes its file adds to the output
14
+ */
15
+
16
+ class UnusedAssetsWarning extends WebpackError {
17
+ /**
18
+ * Creates an instance of UnusedAssetsWarning.
19
+ * @param {UnusedAssetDetails[]} assets the assets nothing reads
20
+ * @param {number} total the bytes they add between them
21
+ */
22
+ constructor(assets, total) {
23
+ const list = assets
24
+ .map((it) => `\n ${it.name} (${it.size} bytes)`)
25
+ .join("");
26
+
27
+ super(
28
+ `unused assets: ${total} bytes are emitted for ${assets.length === 1 ? "an import whose binding" : "imports whose bindings"} nothing reads:${list}\nThe import brings the file into the output but its value is never used, so the bytes ship for nothing. Drop the import, or write it as 'import "./file"' with no binding where the file is wanted on disk regardless — 'experiments.futureDefaults' already leaves those alone and drops these.\nFor more info visit https://webpack.js.org/guides/asset-modules/`
29
+ );
30
+
31
+ /** @type {string} */
32
+ this.name = "UnusedAssetsWarning";
33
+ }
34
+ }
35
+
36
+ module.exports = UnusedAssetsWarning;
@@ -0,0 +1,35 @@
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
+ const WebpackError = require("./WebpackError");
9
+
10
+ /**
11
+ * @typedef {object} UnusedFederationDetails
12
+ * @property {string} name the share key or remote name, as declared
13
+ * @property {"shared" | "remote"} kind which list declared it
14
+ */
15
+
16
+ class UnusedFederationWarning extends WebpackError {
17
+ /**
18
+ * Creates an instance of UnusedFederationWarning.
19
+ * @param {UnusedFederationDetails[]} entries the entries nothing used
20
+ */
21
+ constructor(entries) {
22
+ const list = entries
23
+ .map((entry) => `\n ${entry.name} (${entry.kind})`)
24
+ .join("");
25
+
26
+ super(
27
+ `unused federation config: ${entries.length} ${entries.length === 1 ? "entry was" : "entries were"} declared but never used:${list}\nA 'shared' key nothing imports is not shared at all — each side keeps its own copy, which for a package holding state breaks at runtime rather than only costing bytes. A 'remotes' name nothing imports is dead configuration, or names a remote the code spells differently.\nFor more info visit https://webpack.js.org/concepts/module-federation/`
28
+ );
29
+
30
+ /** @type {string} */
31
+ this.name = "UnusedFederationWarning";
32
+ }
33
+ }
34
+
35
+ module.exports = UnusedFederationWarning;
@@ -0,0 +1,38 @@
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
+ const WebpackError = require("./WebpackError");
9
+
10
+ /**
11
+ * @typedef {object} UnusedModuleDetails
12
+ * @property {string} name the module, by request
13
+ * @property {number} size the bytes it adds to the bundle
14
+ * @property {string} statement the statement that kept it, as `type at location`
15
+ */
16
+
17
+ class UnusedModulesWarning extends WebpackError {
18
+ /**
19
+ * Creates an instance of UnusedModulesWarning.
20
+ * @param {UnusedModuleDetails[]} modules the modules nothing uses
21
+ * @param {number} total how many such modules there are
22
+ * @param {number} size the bytes they add between them
23
+ */
24
+ constructor(modules, total, size) {
25
+ const list = modules
26
+ .map((it) => `\n ${it.name} (${it.size} bytes) — ${it.statement}`)
27
+ .join("");
28
+
29
+ super(
30
+ `unused modules: ${total} ${total === 1 ? "module is" : "modules are"} bundled although nothing uses what they export, costing ${size} bytes:${list}\nEach is kept only by the statement named above, which runs for its effect rather than for anything the importer reads. Move that effect to where it is wanted, or drop the import — 'sideEffects' in the package's package.json says so for a whole package at once.\nFor more info visit https://webpack.js.org/guides/tree-shaking/#mark-the-file-as-side-effect-free`
31
+ );
32
+
33
+ /** @type {string} */
34
+ this.name = "UnusedModulesWarning";
35
+ }
36
+ }
37
+
38
+ module.exports = UnusedModulesWarning;
@@ -22,6 +22,15 @@ class ExportWebpackRequireRuntimeModule extends RuntimeModule {
22
22
  return false;
23
23
  }
24
24
 
25
+ /**
26
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
27
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
28
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
29
+ */
30
+ getInstalledChunkHandlers() {
31
+ return RuntimeModule.NO_CHUNK_HANDLERS;
32
+ }
33
+
25
34
  /**
26
35
  * Generates runtime code for this runtime module.
27
36
  * @returns {string | null} runtime code
@@ -19,7 +19,10 @@ const {
19
19
  getChunkFilenameTemplate,
20
20
  getCompilationHooks
21
21
  } = require("../javascript/JavascriptModulesPlugin");
22
- const { entryModuleIdExpression } = require("../javascript/StartupHelpers");
22
+ const {
23
+ entryModuleIdExpression,
24
+ renderAwaitedEntries
25
+ } = require("../javascript/StartupHelpers");
23
26
  const { getUndoPath } = require("../util/identifier");
24
27
 
25
28
  /** @import { Source } from "webpack-sources" */
@@ -186,7 +189,8 @@ class ModuleChunkFormatPlugin {
186
189
  }
187
190
  );
188
191
  hooks.renderChunk.tap(PLUGIN_NAME, (modules, renderContext) => {
189
- const { chunk, chunkGraph, runtimeTemplate } = renderContext;
192
+ const { chunk, chunkGraph, moduleGraph, runtimeTemplate } =
193
+ renderContext;
190
194
  const hotUpdateChunk = chunk instanceof HotUpdateChunk ? chunk : null;
191
195
  const source = new ConcatSource();
192
196
  const cst = runtimeTemplate.renderConst();
@@ -239,6 +243,17 @@ class ModuleChunkFormatPlugin {
239
243
  );
240
244
  }
241
245
 
246
+ const entryOptions = chunk.getEntryOptions();
247
+ const library =
248
+ entryOptions && entryOptions.library !== undefined
249
+ ? entryOptions.library
250
+ : runtimeTemplate.outputOptions.library;
251
+ // A module library awaits the entry itself, in `ModuleLibraryPlugin`.
252
+ const canAwaitEntry =
253
+ runtimeTemplate.supportsTopLevelAwait() &&
254
+ !(library !== undefined && library.type === "module");
255
+ /** @type {string[]} */
256
+ const awaitedEntries = [];
242
257
  /** @type {Set<Chunk>} */
243
258
  const loadedChunks = new Set();
244
259
  let ownInstalled = false;
@@ -296,13 +311,23 @@ class ModuleChunkFormatPlugin {
296
311
  startupSource.add(inlinedEntrySource);
297
312
  startupSource.add("\n");
298
313
  } else {
314
+ // An async entry nobody awaits settles after the bundle did,
315
+ // which orphans its rejection.
316
+ const awaitEntry = canAwaitEntry && moduleGraph.isAsync(module);
317
+ const target = final
318
+ ? RuntimeGlobals.exports
319
+ : `${RuntimeGlobals.exports}_${i}`;
299
320
  startupSource.add(
300
321
  `${
301
- final ? `var ${RuntimeGlobals.exports} = ` : ""
322
+ final || awaitEntry ? `var ${target} = ` : ""
302
323
  }__webpack_exec__(${JSON.stringify(moduleId)});\n`
303
324
  );
325
+ if (awaitEntry) awaitedEntries.push(target);
304
326
  }
305
327
  }
328
+ for (const line of renderAwaitedEntries(awaitedEntries)) {
329
+ startupSource.add(`${line}\n`);
330
+ }
306
331
 
307
332
  entrySource.add(
308
333
  hooks.renderStartup.call(
@@ -78,7 +78,6 @@ class ModuleChunkLoadingPlugin {
78
78
  RuntimeGlobals.ensureChunkHandlers,
79
79
  RuntimeGlobals.baseURI,
80
80
  RuntimeGlobals.externalInstallChunk,
81
- RuntimeGlobals.analyzableChunkImport,
82
81
  RuntimeGlobals.onChunksLoaded,
83
82
  RuntimeGlobals.hmrDownloadUpdateHandlers,
84
83
  RuntimeGlobals.hmrDownloadManifest
@@ -90,7 +89,6 @@ class ModuleChunkLoadingPlugin {
90
89
  for (const requirement of [
91
90
  RuntimeGlobals.ensureChunkHandlers,
92
91
  RuntimeGlobals.externalInstallChunk,
93
- RuntimeGlobals.analyzableChunkImport,
94
92
  RuntimeGlobals.hmrDownloadUpdateHandlers
95
93
  ]) {
96
94
  compilation.hooks.runtimeRequirementInTree
@@ -120,23 +118,44 @@ class ModuleChunkLoadingPlugin {
120
118
  if (!isEnabledForChunk(chunk)) return;
121
119
  // A baked url carries where the chunk is, so neither is read for it.
122
120
  // Asked as the runtime module asks, so the two always agree.
123
- const baked = compilation.runtimeTemplate.analyzableChunkScriptUrls(
124
- chunk,
125
- chunkGraph,
126
- set
127
- );
128
- if (baked !== null && baked.complete) return;
121
+ if (
122
+ compilation.runtimeTemplate.analyzableChunkScriptUrls(
123
+ chunk,
124
+ chunkGraph,
125
+ set
126
+ ) !== null
127
+ ) {
128
+ return;
129
+ }
129
130
  set.add(RuntimeGlobals.publicPath);
130
131
  set.add(RuntimeGlobals.getChunkScriptFilename);
131
132
  });
132
133
  }
133
134
 
134
135
  // Keyed on `ensureChunk`, not on the handler map: only the runtime chunk loader
135
- // builds a URL from a chunk id, and an analyzable `import()` carries its own.
136
+ // builds a URL from a chunk id, and a baked specifier carries its own.
136
137
  compilation.hooks.runtimeRequirementInTree
137
138
  .for(RuntimeGlobals.ensureChunk)
138
- .tap(PLUGIN_NAME, (chunk, set) => {
139
- if (!isEnabledForChunk(chunk)) return;
139
+ .tap(PLUGIN_NAME, (chunk, set, { chunkGraph }) => {
140
+ if (!isEnabledForChunk(chunk)) {
141
+ compilation.runtimeTemplate.reportChunkImportBailout(
142
+ chunk,
143
+ chunkGraph
144
+ );
145
+ return;
146
+ }
147
+
148
+ // Asked as the runtime module asks, so the two always agree on whether
149
+ // a chunk id is ever turned into a url here.
150
+ const { runtimeTemplate } = compilation;
151
+ if (
152
+ runtimeTemplate.analyzableChunkImports(chunk, chunkGraph, set) !==
153
+ null &&
154
+ !set.has(RuntimeGlobals.hmrDownloadUpdateHandlers) &&
155
+ !runtimeTemplate.chunkImportsNeedRuntimeUrl(chunk, chunkGraph)
156
+ ) {
157
+ return;
158
+ }
140
159
 
141
160
  if (compilation.outputOptions.publicPath !== "auto") {
142
161
  set.add(RuntimeGlobals.publicPath);
@@ -17,6 +17,7 @@ const { getInitialChunkIds } = require("../javascript/StartupHelpers");
17
17
  const { renderBaseUri } = require("../runtime/baseUri");
18
18
  const compileBooleanMatcher = require("../util/compileBooleanMatcher");
19
19
  const createHooksRegistry = require("../util/createHooksRegistry");
20
+ const { RESOLVABLE_SPECIFIER_REGEXP } = require("../util/identifier");
20
21
  const memoize = require("../util/memoize");
21
22
 
22
23
  const getAPIPlugin = memoize(() => require("../APIPlugin"));
@@ -53,6 +54,54 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
53
54
  this._runtimeRequirements = runtimeRequirements;
54
55
  }
55
56
 
57
+ /**
58
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
59
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
60
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
61
+ */
62
+ getInstalledChunkHandlers() {
63
+ const compilation = /** @type {Compilation} */ (this.compilation);
64
+ const chunkGraph = /** @type {ChunkGraph} */ (this.chunkGraph);
65
+ const chunk = /** @type {Chunk} */ (this.chunk);
66
+ const runtimeRequirements = this._runtimeRequirements;
67
+ const withHmr = runtimeRequirements.has(
68
+ RuntimeGlobals.hmrDownloadUpdateHandlers
69
+ );
70
+ const withHint =
71
+ compilation.outputOptions.environment.document ||
72
+ compilation.runtimeTemplate.isNeutralPlatform();
73
+ /** @type {[string, string][]} */
74
+ const handlers = [];
75
+ if (
76
+ runtimeRequirements.has(RuntimeGlobals.ensureChunkHandlers) &&
77
+ (runtimeRequirements.has(RuntimeGlobals.ensureChunk) || withHmr)
78
+ ) {
79
+ handlers.push([RuntimeGlobals.ensureChunkHandlers, "j"]);
80
+ }
81
+ // The hot update flow installs this one onto the same map while it runs.
82
+ if (withHmr) {
83
+ handlers.push([RuntimeGlobals.ensureChunkHandlers, "moduleHmr"]);
84
+ }
85
+ if (
86
+ withHint &&
87
+ runtimeRequirements.has(RuntimeGlobals.prefetchChunkHandlers) &&
88
+ chunk.hasChildByOrder(chunkGraph, "prefetch", true, chunkHasJs)
89
+ ) {
90
+ handlers.push([RuntimeGlobals.prefetchChunkHandlers, "j"]);
91
+ }
92
+ if (
93
+ withHint &&
94
+ runtimeRequirements.has(RuntimeGlobals.preloadChunkHandlers) &&
95
+ chunk.hasChildByOrder(chunkGraph, "preload", true, chunkHasJs)
96
+ ) {
97
+ handlers.push([RuntimeGlobals.preloadChunkHandlers, "j"]);
98
+ }
99
+ if (runtimeRequirements.has(RuntimeGlobals.onChunksLoaded)) {
100
+ handlers.push([RuntimeGlobals.onChunksLoaded, "j"]);
101
+ }
102
+ return handlers;
103
+ }
104
+
56
105
  /**
57
106
  * Returns generated code.
58
107
  * @private
@@ -96,9 +145,6 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
96
145
  const withExternalInstallChunk = this._runtimeRequirements.has(
97
146
  RuntimeGlobals.externalInstallChunk
98
147
  );
99
- const withAnalyzableImport = this._runtimeRequirements.has(
100
- RuntimeGlobals.analyzableChunkImport
101
- );
102
148
  const withLoading = this._runtimeRequirements.has(
103
149
  RuntimeGlobals.ensureChunkHandlers
104
150
  );
@@ -111,8 +157,8 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
111
157
  const withHmrManifest = this._runtimeRequirements.has(
112
158
  RuntimeGlobals.hmrDownloadManifest
113
159
  );
114
- // `.f.j` serves `ensureChunk`: an analyzable import dispatches every handler but
115
- // this one. HMR's force-load knows only a chunk id, so it needs the loader too.
160
+ // `.f.j` serves `ensureChunk`. HMR's force-load knows only a chunk id, so it
161
+ // needs the loader too.
116
162
  const withJsLoading =
117
163
  withLoading &&
118
164
  (this._runtimeRequirements.has(RuntimeGlobals.ensureChunk) || withHmr);
@@ -129,7 +175,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
129
175
  chunk.hasChildByOrder(chunkGraph, "preload", true, chunkHasJs);
130
176
  // Under module output each hinted chunk is a known file, so the urls are written
131
177
  // out and read by id rather than built from the chunk id at runtime.
132
- const bakedChunkUrls =
178
+ const chunkUrls =
133
179
  withPrefetch || withPreload
134
180
  ? runtimeTemplate.analyzableChunkScriptUrls(
135
181
  chunk,
@@ -138,12 +184,16 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
138
184
  this
139
185
  )
140
186
  : null;
141
- // A hint is best-effort, so an id an incomplete map lacks is not worth a per-id
142
- // fallback — only a complete map replaces the runtime name lookup.
143
- const chunkUrls =
144
- bakedChunkUrls !== null && bakedChunkUrls.complete
145
- ? bakedChunkUrls.urls
146
- : null;
187
+ // Under module output every chunk the loader reaches is a known file, so it
188
+ // imports a literal specifier read by id instead of a url built from that id.
189
+ const chunkImports = withJsLoading
190
+ ? runtimeTemplate.analyzableChunkImports(
191
+ chunk,
192
+ chunkGraph,
193
+ this._runtimeRequirements,
194
+ this
195
+ )
196
+ : null;
147
197
  const conditionMap = chunkGraph.getChunkConditionMap(chunk, chunkHasJs);
148
198
  const hasJsMatcher = compileBooleanMatcher(conditionMap);
149
199
  const initialChunkIds = getInitialChunkIds(chunk, chunkGraph, chunkHasJs);
@@ -158,7 +208,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
158
208
  publicPath === "auto"
159
209
  ? JSON.stringify(rootOutputDir)
160
210
  : typeof publicPath === "string" &&
161
- !/^(?:\.{0,2}\/|[a-zA-Z][\w+.-]*:)/.test(publicPath) &&
211
+ !RESOLVABLE_SPECIFIER_REGEXP.test(publicPath) &&
162
212
  !getAPIPlugin().usesRuntimePublicPathOverride(compilation)
163
213
  ? `"./" + ${RuntimeGlobals.publicPath}`
164
214
  : RuntimeGlobals.publicPath;
@@ -179,7 +229,6 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
179
229
  const withInstalledChunks =
180
230
  withLoading ||
181
231
  withExternalInstallChunk ||
182
- withAnalyzableImport ||
183
232
  withOnChunkLoad ||
184
233
  withHmr ||
185
234
  withPrefetch ||
@@ -194,6 +243,19 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
194
243
  chunkUrls === null
195
244
  ? `${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(${id})`
196
245
  : `chunkUrls[${id}]()`;
246
+ const runtimeImport = `${importFunctionName}(${chunkImportBase} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId))`;
247
+ // A hot update can force-load an id this build never saw, and a chunk with a
248
+ // runtime of its own is never named, so only those keep the url form.
249
+ const withRuntimeUrl =
250
+ chunkImports === null ||
251
+ withHmr ||
252
+ runtimeTemplate.chunkImportsNeedRuntimeUrl(chunk, chunkGraph);
253
+ const chunkImport =
254
+ chunkImports === null
255
+ ? runtimeImport
256
+ : withRuntimeUrl
257
+ ? `(${RuntimeGlobals.hasOwnProperty}(chunkImports, chunkId) ? chunkImports[chunkId]() : ${runtimeImport})`
258
+ : "chunkImports[chunkId]()";
197
259
  return Template.asString([
198
260
  withBaseURI
199
261
  ? this._generateBaseUri(chunk, rootOutputDir)
@@ -211,6 +273,20 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
211
273
  ""
212
274
  ]
213
275
  : []),
276
+ ...(chunkImports
277
+ ? [
278
+ `${cst} chunkImports = {\n${Template.indent(
279
+ Array.from(
280
+ chunkImports,
281
+ ([id, specifier]) =>
282
+ `${JSON.stringify(String(id))}: ${runtimeTemplate.returningFunction(
283
+ `${importFunctionName}(${specifier})`
284
+ )}`
285
+ ).join(",\n")
286
+ )}\n};`,
287
+ ""
288
+ ]
289
+ : []),
214
290
  withInstalledChunks
215
291
  ? Template.asString([
216
292
  "// object to store loaded and loading chunks",
@@ -227,7 +303,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
227
303
  ])
228
304
  : "// no installed chunks",
229
305
  "",
230
- withLoading || withExternalInstallChunk || withAnalyzableImport
306
+ withLoading || withExternalInstallChunk
231
307
  ? `${cst} installChunk = ${runtimeTemplate.basicFunction("data", [
232
308
  runtimeTemplate.destructureObject(
233
309
  [
@@ -286,9 +362,7 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
286
362
  : `if(${hasJsMatcher("chunkId")}) {`,
287
363
  Template.indent([
288
364
  "// setup Promise in chunk cache",
289
- `${lt} promise = ${importFunctionName}(${chunkImportBase} + ${
290
- RuntimeGlobals.getChunkScriptFilename
291
- }(chunkId)).then(installChunk, ${runtimeTemplate.basicFunction(
365
+ `${lt} promise = ${chunkImport}.then(installChunk, ${runtimeTemplate.basicFunction(
292
366
  "e",
293
367
  [
294
368
  "if(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined;",
@@ -428,48 +502,6 @@ class ModuleChunkLoadingRuntimeModule extends RuntimeModule {
428
502
  ])
429
503
  : "// no external install chunk",
430
504
  "",
431
- withAnalyzableImport
432
- ? `${
433
- RuntimeGlobals.analyzableChunkImport
434
- } = ${runtimeTemplate.basicFunction("chunkId, importFn", [
435
- // `ensureChunk` with its `.j` half replaced by a literal `import()` a foreign
436
- // bundler can follow. The remaining handlers still run, so a chunk's css and
437
- // its prefetch/preload children are not lost by taking this path.
438
- `${lt} promises = [];`,
439
- `${lt} installedChunkData = ${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;`,
440
- 'if(installedChunkData !== 0) { // 0 means "already installed".',
441
- Template.indent([
442
- '// a Promise means "currently loading".',
443
- "if(installedChunkData) {",
444
- Template.indent(["promises.push(installedChunkData[1]);"]),
445
- "} else {",
446
- Template.indent([
447
- `${lt} promise = importFn().then(installChunk, ${runtimeTemplate.basicFunction(
448
- "e",
449
- [
450
- "if(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined;",
451
- "throw e;"
452
- ]
453
- )});`,
454
- `promise = Promise.race([promise, new Promise(${runtimeTemplate.expressionFunction(
455
- "installedChunkData = installedChunks[chunkId] = [resolve]",
456
- "resolve"
457
- )})]);`,
458
- "promises.push((installedChunkData[1] = promise));"
459
- ]),
460
- "}"
461
- ]),
462
- "}",
463
- withLoading
464
- ? `Object.keys(${fn}).forEach(${runtimeTemplate.basicFunction(
465
- "key",
466
- [`if(key !== "j") ${fn}[key](chunkId, promises);`]
467
- )});`
468
- : "// no other chunk loading handlers",
469
- "return Promise.all(promises);"
470
- ])};`
471
- : "// no analyzable chunk import",
472
- "",
473
505
  withOnChunkLoad
474
506
  ? `${
475
507
  RuntimeGlobals.onChunksLoaded
@@ -26,14 +26,20 @@
26
26
 
27
27
  /** @typedef {(options: ApplyOptions) => ApplyResult} ApplyHandler */
28
28
  /** @typedef {(moduleId: ModuleId, applyHandlers: ApplyHandler[]) => void} InvalidateModuleHandler */
29
- /** @typedef {(chunkIds: ModuleId[], removedChunks: ModuleId[], removedModules: ModuleId[], promises: Promise<unknown>[], applyHandlers: ApplyHandler[], updatedModulesList: ModuleId[], css: ModuleId[] | undefined, forceLoadChunks: ModuleId[] | undefined) => void} DownloadUpdateHandler */
29
+ /**
30
+ * @typedef {object} CssUpdateManifest
31
+ * @property {ModuleId[]} r updated chunk ids that no longer have a stylesheet
32
+ * @property {Record<string, string>=} n the stylesheet name of each updated chunk whose name moved with its content
33
+ */
34
+
35
+ /** @typedef {(chunkIds: ModuleId[], removedChunks: ModuleId[], removedModules: ModuleId[], promises: Promise<unknown>[], applyHandlers: ApplyHandler[], updatedModulesList: ModuleId[], css: CssUpdateManifest | undefined, forceLoadChunks: ModuleId[] | undefined) => void} DownloadUpdateHandler */
30
36
 
31
37
  /**
32
38
  * @typedef {object} HMRManifest
33
39
  * @property {ModuleId[]} c updated chunk ids
34
40
  * @property {ModuleId[]} r removed chunk ids
35
41
  * @property {ModuleId[]} m removed module ids
36
- * @property {ModuleId[]=} css updated css chunk ids
42
+ * @property {CssUpdateManifest=} css what the stylesheet loader needs to know about the update
37
43
  * @property {ModuleId[]=} f chunk ids to force-load
38
44
  */
39
45
 
@@ -16,6 +16,15 @@ class HotModuleReplacementRuntimeModule extends RuntimeModule {
16
16
  super("hot module replacement", RuntimeModule.STAGE_BASIC);
17
17
  }
18
18
 
19
+ /**
20
+ * The `[handlerMap, key]` pairs this module installs onto a chunk handler map
21
+ * such as `__webpack_require__.f`, or `null` where it cannot name them.
22
+ * @returns {[string, string][] | null} installed chunk handlers (do not mutate)
23
+ */
24
+ getInstalledChunkHandlers() {
25
+ return RuntimeModule.NO_CHUNK_HANDLERS;
26
+ }
27
+
19
28
  /**
20
29
  * Generates runtime code for this runtime module.
21
30
  * @returns {string | null} runtime code