@depup/webpack 5.110.1-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 (304) 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/ChunkGraph.js +20 -18
  8. package/lib/CircularModulesPlugin.js +157 -55
  9. package/lib/CleanPlugin.js +2 -2
  10. package/lib/CompatibilityPlugin.js +3 -4
  11. package/lib/Compilation.js +337 -338
  12. package/lib/Compiler.js +213 -51
  13. package/lib/ConcatenationScope.js +25 -35
  14. package/lib/ConstPlugin.js +16 -132
  15. package/lib/CopyPlugin.js +1054 -0
  16. package/lib/DefinePlugin.js +24 -8
  17. package/lib/DependencyTemplate.js +2 -1
  18. package/lib/DotenvPlugin.js +64 -40
  19. package/lib/ErrorHelpers.js +113 -0
  20. package/lib/ExportsInfo.js +30 -16
  21. package/lib/ExternalModule.js +47 -22
  22. package/lib/FileSystemInfo.js +17 -14
  23. package/lib/FlagDependencyExportsPlugin.js +53 -34
  24. package/lib/FlagDependencyUsagePlugin.js +17 -15
  25. package/lib/Generator.js +24 -2
  26. package/lib/HotModuleReplacementPlugin.js +55 -7
  27. package/lib/IgnorePlugin.js +1 -1
  28. package/lib/JavascriptMetaInfoPlugin.js +5 -3
  29. package/lib/LoaderOptionsPlugin.js +1 -1
  30. package/lib/MainTemplate.js +5 -1
  31. package/lib/Module.js +19 -10
  32. package/lib/ModuleGraph.js +6 -9
  33. package/lib/MultiCompiler.js +7 -17
  34. package/lib/MultiWatching.js +1 -1
  35. package/lib/NormalModule.js +148 -70
  36. package/lib/NormalModuleFactory.js +1 -1
  37. package/lib/RuntimeGlobals.js +21 -7
  38. package/lib/RuntimeModule.js +28 -12
  39. package/lib/RuntimePlugin.js +33 -3
  40. package/lib/RuntimeTemplate.js +1147 -847
  41. package/lib/SourceMapDevToolPlugin.js +54 -104
  42. package/lib/TemplatedPathPlugin.js +16 -59
  43. package/lib/Watching.js +9 -0
  44. package/lib/WebpackOptionsApply.js +84 -91
  45. package/lib/asset/AssetBytesGenerator.js +7 -1
  46. package/lib/asset/AssetGenerator.js +50 -24
  47. package/lib/asset/AssetModule.js +3 -0
  48. package/lib/asset/AssetSourceGenerator.js +7 -1
  49. package/lib/asset/WebManifestParser.js +7 -5
  50. package/lib/async-modules/AsyncModuleHelpers.js +10 -4
  51. package/lib/buildChunkGraph.js +11 -15
  52. package/lib/cache/AddBuildDependenciesPlugin.js +33 -4
  53. package/lib/cache/IdleFileCachePlugin.js +2 -2
  54. package/lib/cache/MemoryCachePlugin.js +4 -4
  55. package/lib/cache/MemoryWithGcCachePlugin.js +7 -8
  56. package/lib/cache/PackFileCacheStrategy.js +17 -19
  57. package/lib/cache/getLazyHashedEtag.js +3 -5
  58. package/lib/config/browserslistTargetHandler.js +17 -4
  59. package/lib/config/defaults.js +162 -142
  60. package/lib/config/getClaimedAssetTypes.js +10 -11
  61. package/lib/config/normalization.js +100 -20
  62. package/lib/config/target.js +13 -4
  63. package/lib/container/ContainerReferencePlugin.js +6 -0
  64. package/lib/container/RemoteRuntimeModule.js +9 -0
  65. package/lib/container/declaredRemotes.js +39 -0
  66. package/lib/{ContextExclusionPlugin.js → context/ContextExclusionPlugin.js} +1 -1
  67. package/lib/{ContextModule.js → context/ContextModule.js} +54 -115
  68. package/lib/{ContextModuleFactory.js → context/ContextModuleFactory.js} +19 -21
  69. package/lib/{ContextReplacementPlugin.js → context/ContextReplacementPlugin.js} +4 -4
  70. package/lib/css/CssGenerator.js +27 -11
  71. package/lib/css/CssInjectStyleRuntimeModule.js +9 -0
  72. package/lib/css/CssLoadingRuntimeModule.js +92 -15
  73. package/lib/css/CssModule.js +1 -1
  74. package/lib/css/CssModulesPlugin.js +3 -10
  75. package/lib/css/CssParser.js +162 -31
  76. package/lib/css/CssServerStylesRuntimeModule.js +9 -0
  77. package/lib/css/cssMinify.js +43 -32
  78. package/lib/css/data.js +3526 -871
  79. package/lib/css/syntax.js +6455 -1237
  80. package/lib/debug/ProfilingPlugin.js +7 -4
  81. package/lib/dependencies/AMDDefineDependencyParserPlugin.js +6 -3
  82. package/lib/dependencies/AMDRuntimeModules.js +18 -0
  83. package/lib/dependencies/CommonJsExportRequireDependency.js +13 -12
  84. package/lib/dependencies/CommonJsExportsParserPlugin.js +12 -13
  85. package/lib/dependencies/CommonJsImportsParserPlugin.js +5 -5
  86. package/lib/dependencies/CommonJsPlugin.js +19 -3
  87. package/lib/dependencies/CommonJsRequireDependency.js +32 -9
  88. package/lib/dependencies/CommonJsSelfReferenceDependency.js +2 -4
  89. package/lib/dependencies/ContextDependency.js +1 -1
  90. package/lib/dependencies/ContextDependencyHelpers.js +3 -9
  91. package/lib/dependencies/ContextDependencyTemplateAsRequireCall.js +20 -7
  92. package/lib/dependencies/ContextElementDependency.js +1 -1
  93. package/lib/dependencies/CssIcssExportDependency.js +13 -9
  94. package/lib/dependencies/CssIcssImportDependency.js +3 -6
  95. package/lib/dependencies/CssUrlDependency.js +3 -5
  96. package/lib/dependencies/HarmonyCompatibilityDependency.js +67 -22
  97. package/lib/dependencies/HarmonyDetectionParserPlugin.js +3 -4
  98. package/lib/dependencies/HarmonyEvaluatedImportSpecifierDependency.js +10 -4
  99. package/lib/dependencies/HarmonyExportDependencyParserPlugin.js +12 -7
  100. package/lib/dependencies/HarmonyExportExpressionDependency.js +47 -33
  101. package/lib/dependencies/HarmonyExportImportedSpecifierDependency.js +217 -34
  102. package/lib/dependencies/HarmonyExportInitFragment.js +110 -23
  103. package/lib/dependencies/HarmonyExportSpecifierDependency.js +25 -58
  104. package/lib/dependencies/HarmonyImportBareSideEffectDependency.js +59 -0
  105. package/lib/dependencies/HarmonyImportDependency.js +99 -41
  106. package/lib/dependencies/HarmonyImportDependencyParserPlugin.js +198 -25
  107. package/lib/dependencies/HarmonyImportSideEffectDependency.js +117 -4
  108. package/lib/dependencies/HarmonyImportSpecifierDependency.js +40 -3
  109. package/lib/dependencies/HarmonyModulesPlugin.js +20 -0
  110. package/lib/dependencies/HtmlEntryDependency.js +136 -104
  111. package/lib/dependencies/HtmlInlineScriptDependency.js +3 -4
  112. package/lib/dependencies/HtmlInlineStyleDependency.js +3 -4
  113. package/lib/dependencies/ImportContextDependency.js +43 -3
  114. package/lib/dependencies/ImportDependency.js +8 -29
  115. package/lib/dependencies/ImportMetaContextDependencyParserPlugin.js +1 -1
  116. package/lib/dependencies/ImportMetaGlobHelpers.js +1 -1
  117. package/lib/dependencies/ImportMetaMainDependency.js +104 -0
  118. package/lib/dependencies/ImportMetaPlugin.js +67 -25
  119. package/lib/dependencies/ImportParserPlugin.js +25 -15
  120. package/lib/dependencies/LoaderPlugin.js +26 -1
  121. package/lib/dependencies/RequireContextDependencyParserPlugin.js +1 -1
  122. package/lib/dependencies/RequireHeaderDependency.js +20 -21
  123. package/lib/dependencies/SystemRuntimeModule.js +9 -0
  124. package/lib/dependencies/URLContextDependency.js +1 -1
  125. package/lib/dependencies/URLDependency.js +6 -5
  126. package/lib/dependencies/WorkerAndWorkletPlugin.js +16 -21
  127. package/lib/dependencies/WorkerDependency.js +12 -18
  128. package/lib/dependencies/WorkletDependency.js +12 -20
  129. package/lib/dependencies/importOptionsCheck.js +47 -0
  130. package/lib/dll/DelegatedModule.js +18 -1
  131. package/lib/dll/DllReferencePlugin.js +11 -8
  132. package/lib/dll/LibManifestPlugin.js +1 -1
  133. package/lib/errors/AnalyzableBailoutsWarning.js +41 -0
  134. package/lib/errors/DotenvFileError.js +29 -0
  135. package/lib/errors/DuplicateModulesWarning.js +12 -7
  136. package/lib/errors/EmptyCopyPatternWarning.js +26 -0
  137. package/lib/errors/ExternalStarReexportError.js +44 -0
  138. package/lib/errors/HookWebpackError.js +3 -2
  139. package/lib/errors/ImportedBindingAssignmentError.js +30 -0
  140. package/lib/errors/MissingSourceMapsWarning.js +36 -0
  141. package/lib/errors/ModuleParseError.js +2 -1
  142. package/lib/errors/UnusedAssetsWarning.js +36 -0
  143. package/lib/errors/UnusedFederationWarning.js +35 -0
  144. package/lib/errors/UnusedModulesWarning.js +38 -0
  145. package/lib/esm/ExportWebpackRequireRuntimeModule.js +9 -0
  146. package/lib/esm/ModuleChunkFormatPlugin.js +28 -3
  147. package/lib/esm/ModuleChunkLoadingPlugin.js +21 -5
  148. package/lib/esm/ModuleChunkLoadingRuntimeModule.js +91 -53
  149. package/lib/hmr/HotModuleReplacement.runtime.js +8 -2
  150. package/lib/hmr/HotModuleReplacementRuntimeModule.js +9 -0
  151. package/lib/hmr/LazyCompilationPlugin.js +3 -5
  152. package/lib/html/HtmlGenerator.js +72 -87
  153. package/lib/html/HtmlModulesPlugin.js +479 -215
  154. package/lib/html/HtmlParser.js +110 -147
  155. package/lib/html/builtinEmbeddedRenderer.js +107 -0
  156. package/lib/html/data.js +142 -7
  157. package/lib/html/htmlMinify.js +92 -122
  158. package/lib/html/syntax.js +2031 -1556
  159. package/lib/ids/HashedModuleIdsPlugin.js +2 -1
  160. package/lib/index.js +49 -3
  161. package/lib/javascript/ChunkFormatHelpers.js +4 -3
  162. package/lib/javascript/JavascriptGenerator.js +8 -1
  163. package/lib/javascript/JavascriptModule.js +1 -0
  164. package/lib/javascript/JavascriptModulesPlugin.js +76 -80
  165. package/lib/javascript/JavascriptParser.js +1970 -900
  166. package/lib/javascript/StartupHelpers.js +27 -3
  167. package/lib/javascript/data.js +172 -0
  168. package/lib/javascript/grammar.js +5546 -0
  169. package/lib/javascript/parser.js +1500 -0
  170. package/lib/javascript/regexp.js +1762 -0
  171. package/lib/javascript/regexpData.js +51 -0
  172. package/lib/javascript/syntax.js +9061 -5262
  173. package/lib/json/JsonGenerator.js +7 -1
  174. package/lib/library/ModuleLibraryPlugin.js +171 -132
  175. package/lib/loaders/LoaderRunner.js +170 -14
  176. package/lib/node/NodeWatchFileSystem.js +3 -9
  177. package/lib/node/ReadFileChunkLoadingRuntimeModule.js +22 -0
  178. package/lib/node/ReadFileCompileAsyncWasmPlugin.js +8 -15
  179. package/lib/node/RequireChunkLoadingRuntimeModule.js +22 -0
  180. package/lib/optimize/AggressiveMergingPlugin.js +3 -5
  181. package/lib/optimize/ConcatenatedModule.js +222 -125
  182. package/lib/optimize/ConstExportsPlugin.js +50 -34
  183. package/lib/optimize/FlagIncludedChunksPlugin.js +3 -11
  184. package/lib/optimize/InlineExports.js +20 -2
  185. package/lib/optimize/InnerGraphPlugin.js +7 -13
  186. package/lib/optimize/LimitChunkCountPlugin.js +5 -8
  187. package/lib/optimize/MangleExportsPlugin.js +13 -4
  188. package/lib/optimize/ModuleConcatenationPlugin.js +27 -5
  189. package/lib/optimize/RealContentHashPlugin.js +179 -44
  190. package/lib/optimize/SideEffectsFlagPlugin.js +24 -28
  191. package/lib/optimize/SplitChunksPlugin.js +2 -4
  192. package/lib/performance/AnalyzableBailoutsPlugin.js +115 -0
  193. package/lib/performance/BroadContextsPlugin.js +1 -1
  194. package/lib/performance/CacheEffectivenessPlugin.js +7 -7
  195. package/lib/performance/DuplicateModulesPlugin.js +57 -13
  196. package/lib/performance/EvalUsagePlugin.js +5 -2
  197. package/lib/performance/MissingSourceMapsPlugin.js +115 -0
  198. package/lib/performance/PureAnnotationsPlugin.js +6 -3
  199. package/lib/performance/SizeLimitsPlugin.js +2 -4
  200. package/lib/performance/TopLevelThisPlugin.js +5 -4
  201. package/lib/performance/UnusedAssetsPlugin.js +109 -0
  202. package/lib/performance/UnusedFederationPlugin.js +147 -0
  203. package/lib/performance/UnusedModulesPlugin.js +141 -0
  204. package/lib/performance/UnusedReexportsPlugin.js +1 -55
  205. package/lib/performance/isOnlyReexported.js +65 -0
  206. package/lib/prefetch/ChunkPrefetchFunctionRuntimeModule.js +25 -5
  207. package/lib/prefetch/ChunkPrefetchPreloadPlugin.js +8 -8
  208. package/lib/prefetch/ChunkPrefetchStartupRuntimeModule.js +9 -0
  209. package/lib/prefetch/ChunkPrefetchTriggerRuntimeModule.js +9 -0
  210. package/lib/prefetch/ChunkPreloadTriggerRuntimeModule.js +9 -0
  211. package/lib/prefetch/ResourceHintPlugin.js +29 -35
  212. package/lib/prefetch/ResourceHintRuntimeModule.js +9 -0
  213. package/lib/prefetch/StartupAssetHintRuntimeModule.js +16 -10
  214. package/lib/rules/RuleSetCompiler.js +211 -4
  215. package/lib/runtime/AsyncModuleRuntimeModule.js +103 -67
  216. package/lib/runtime/AutoPublicPathRuntimeModule.js +9 -0
  217. package/lib/runtime/BaseUriRuntimeModule.js +9 -0
  218. package/lib/runtime/ChunkNameRuntimeModule.js +9 -0
  219. package/lib/runtime/EnsureChunkRuntimeModule.js +35 -16
  220. package/lib/runtime/GetChunkFilenameRuntimeModule.js +12 -4
  221. package/lib/runtime/GetFullHashRuntimeModule.js +9 -0
  222. package/lib/runtime/GetMainFilenameRuntimeModule.js +9 -0
  223. package/lib/runtime/GetWorkletBootstrapRuntimeModule.js +9 -0
  224. package/lib/runtime/GlobalRuntimeModule.js +11 -4
  225. package/lib/runtime/HasOwnPropertyRuntimeModule.js +9 -0
  226. package/lib/runtime/HelperRuntimeModule.js +10 -0
  227. package/lib/runtime/MakeDeferredNamespaceObjectRuntime.js +313 -222
  228. package/lib/runtime/NonceRuntimeModule.js +9 -0
  229. package/lib/runtime/OnChunksLoadedRuntimeModule.js +67 -20
  230. package/lib/runtime/PublicPathRuntimeModule.js +9 -0
  231. package/lib/runtime/RuntimeIdRuntimeModule.js +9 -0
  232. package/lib/runtime/SpecNamespaceObjectRuntimeModule.js +90 -0
  233. package/lib/runtime/StartupChunkDependenciesRuntimeModule.js +9 -0
  234. package/lib/runtime/StartupEntrypointRuntimeModule.js +9 -0
  235. package/lib/runtime/SystemContextRuntimeModule.js +9 -0
  236. package/lib/runtime/ToBinaryRuntimeModule.js +9 -0
  237. package/lib/schemes/DataUriPlugin.js +3 -6
  238. package/lib/schemes/HttpUriPlugin.js +22 -5
  239. package/lib/schemes/VirtualUrlPlugin.js +1 -1
  240. package/lib/serialization/BinaryMiddleware.js +9 -9
  241. package/lib/serialization/FileMiddleware.js +31 -18
  242. package/lib/serialization/ObjectMiddleware.js +168 -139
  243. package/lib/sharing/ConsumeSharedPlugin.js +12 -0
  244. package/lib/sharing/ConsumeSharedRuntimeModule.js +11 -0
  245. package/lib/sharing/ShareRuntimeModule.js +9 -0
  246. package/lib/sharing/declaredShared.js +47 -0
  247. package/lib/stats/DefaultStatsFactoryPlugin.js +6 -5
  248. package/lib/stats/DefaultStatsPrinterPlugin.js +3 -0
  249. package/lib/typescript/TypeScriptPlugin.js +10 -13
  250. package/lib/url/URLParserPlugin.js +6 -8
  251. package/lib/util/ArrayQueue.js +3 -3
  252. package/lib/util/LocConverter.js +4 -7
  253. package/lib/util/SourceProcessor.js +115 -99
  254. package/lib/util/URLAbsoluteSpecifier.js +3 -1
  255. package/lib/util/async.js +292 -0
  256. package/lib/util/buildDiagnostics.js +69 -0
  257. package/lib/util/chainedImports.js +3 -4
  258. package/lib/util/concatenate.js +4 -4
  259. package/lib/util/conventions.js +5 -1
  260. package/lib/util/createHooksRegistry.js +1 -2
  261. package/lib/util/createMappings.js +25 -3
  262. package/lib/util/dataURL.js +2 -3
  263. package/lib/util/deterministicGrouping.js +8 -13
  264. package/lib/util/findGraphRoots.js +6 -13
  265. package/lib/util/fs.js +27 -1
  266. package/lib/util/globUtils.js +1 -1
  267. package/lib/util/handlerKeys.js +40 -0
  268. package/lib/util/hash/wasm-hash.js +3 -4
  269. package/lib/util/identifier.js +20 -0
  270. package/lib/util/internalSerializables.js +7 -1
  271. package/lib/util/registerExternalSerializer.js +6 -45
  272. package/lib/util/removeBOM.js +82 -1
  273. package/lib/util/semver.js +5 -3
  274. package/lib/wasm-async/AsyncWasmCompileRuntimeModule.js +14 -3
  275. package/lib/wasm-async/AsyncWasmLoadingRuntimeModule.js +14 -3
  276. package/lib/wasm-async/AsyncWebAssemblyGenerator.js +6 -1
  277. package/lib/wasm-async/AsyncWebAssemblyJavascriptGenerator.js +5 -1
  278. package/lib/wasm-async/UniversalCompileAsyncWasmPlugin.js +7 -12
  279. package/lib/wasm-sync/WasmChunkLoadingRuntimeModule.js +12 -4
  280. package/lib/wasm-sync/WebAssemblyGenerator.js +6 -1
  281. package/lib/wasm-sync/WebAssemblyJavascriptGenerator.js +5 -1
  282. package/lib/wasm-sync/WebAssemblyUtils.js +2 -4
  283. package/lib/web/FetchCompileAsyncWasmPlugin.js +10 -6
  284. package/lib/web/FetchCompileWasmPlugin.js +4 -2
  285. package/lib/web/JsonpChunkLoadingRuntimeModule.js +36 -0
  286. package/lib/webworker/ImportScriptsChunkLoadingRuntimeModule.js +19 -0
  287. package/package.json +55 -46
  288. package/schemas/WebpackOptions.check.js +1 -1
  289. package/schemas/WebpackOptions.json +388 -76
  290. package/schemas/plugins/LoaderOptionsPlugin.check.js +1 -1
  291. package/schemas/plugins/ManifestPlugin.check.js +1 -1
  292. package/schemas/plugins/SourceMapDevToolPlugin.check.js +1 -1
  293. package/schemas/plugins/asset/AssetGeneratorOptions.check.js +1 -1
  294. package/schemas/plugins/asset/AssetResourceGeneratorOptions.check.js +1 -1
  295. package/schemas/plugins/container/ContainerPlugin.check.js +1 -1
  296. package/schemas/plugins/container/ModuleFederationPlugin.check.js +1 -1
  297. package/schemas/plugins/debug/ProfilingPlugin.check.js +1 -1
  298. package/schemas/plugins/dll/DllReferencePlugin.check.js +1 -1
  299. package/schemas/plugins/ids/HashedModuleIdsPlugin.check.js +1 -1
  300. package/schemas/plugins/schemes/HttpUriPlugin.check.js +1 -1
  301. package/types.d.ts +1795 -608
  302. package/lib/dependencies/ExportBindingInitFragment.js +0 -191
  303. package/lib/errors/EntrypointOverlapWarning.js +0 -45
  304. package/lib/performance/EntrypointOverlapPlugin.js +0 -122
@@ -0,0 +1,292 @@
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
+ /**
9
+ * Wraps the shared completion callback for one item, so an iterator that
10
+ * reports twice fails loudly instead of settling the run early.
11
+ * @template E
12
+ * @param {(err?: E | null) => void} done shared completion callback
13
+ * @returns {(err?: E | null) => void} completion callback for a single item
14
+ */
15
+ const once = (done) => {
16
+ /** @type {((err?: E | null) => void) | undefined} */
17
+ let pending = done;
18
+ return (err) => {
19
+ const fn = pending;
20
+ if (fn === undefined) throw new Error("Callback was already called");
21
+ pending = undefined;
22
+ fn(err);
23
+ };
24
+ };
25
+
26
+ /**
27
+ * Runs `iterator` over every item with unlimited concurrency.
28
+ * Every item is started from one flat loop, so a synchronous iterator never
29
+ * grows the stack.
30
+ * @template T
31
+ * @template E
32
+ * @param {Iterable<T>} collection items to iterate
33
+ * @param {(item: T, callback: (err?: E | null) => void) => void} iterator called once per item
34
+ * @param {(err?: E | null) => void} callback called when every item is done, or with the first error
35
+ * @returns {void}
36
+ */
37
+ const each = (collection, iterator, callback) => {
38
+ let remaining = 1;
39
+ let finished = false;
40
+
41
+ /**
42
+ * @param {(E | null)=} err error
43
+ * @returns {void}
44
+ */
45
+ const done = (err) => {
46
+ if (finished) return;
47
+ if (err) {
48
+ finished = true;
49
+ callback(err);
50
+ return;
51
+ }
52
+ if (--remaining === 0) {
53
+ finished = true;
54
+ callback(null);
55
+ }
56
+ };
57
+
58
+ if (Array.isArray(collection)) {
59
+ const array = /** @type {T[]} */ (collection);
60
+ const length = array.length;
61
+ if (length === 0) return callback(null);
62
+ remaining = length;
63
+ // Dispatching continues past an error on purpose: callers rely on every
64
+ // item being started, e.g. to close every watcher when one close fails.
65
+ for (let i = 0; i < length; i++) iterator(array[i], once(done));
66
+ return;
67
+ }
68
+
69
+ // `remaining` starts at 1 so that completion cannot fire while items of a
70
+ // collection of unknown length are still being dispatched.
71
+ for (const item of collection) {
72
+ remaining++;
73
+ iterator(item, once(done));
74
+ }
75
+ done(null);
76
+ };
77
+
78
+ /**
79
+ * Runs `iterator` over every item, keeping at most `limit` of them in flight.
80
+ * A synchronous iterator is drained by the dispatch loop instead of by
81
+ * recursion, so the stack stays flat however long the collection is.
82
+ * @template T
83
+ * @template E
84
+ * @param {Iterable<T>} collection items to iterate
85
+ * @param {number} limit maximum number of items in flight
86
+ * @param {(item: T, callback: (err?: E | null) => void) => void} iterator called once per item
87
+ * @param {(err?: E | null) => void} callback called when every item is done, or with the first error
88
+ * @returns {void}
89
+ */
90
+ const eachLimit = (collection, limit, iterator, callback) => {
91
+ const array = Array.isArray(collection)
92
+ ? /** @type {T[]} */ (collection)
93
+ : undefined;
94
+ const length = array === undefined ? 0 : array.length;
95
+ const values =
96
+ array === undefined ? collection[Symbol.iterator]() : undefined;
97
+ let index = 0;
98
+ let running = 0;
99
+ let exhausted = false;
100
+ let finished = false;
101
+ let dispatching = false;
102
+
103
+ const dispatch = () => {
104
+ // A re-entrant call returns at once; the loop already running sees the
105
+ // slot the completed item freed and takes the next one itself.
106
+ if (dispatching) return;
107
+ dispatching = true;
108
+ while (running < limit && !exhausted) {
109
+ // `finished` is set from `done`, which an iterator may call before it
110
+ // returns, so it has to be re-read on every turn of this loop.
111
+ if (finished) break;
112
+ /** @type {T} */
113
+ let item;
114
+ if (array === undefined) {
115
+ const next = /** @type {Iterator<T>} */ (values).next();
116
+ if (next.done) {
117
+ exhausted = true;
118
+ break;
119
+ }
120
+ item = next.value;
121
+ } else {
122
+ if (index === length) {
123
+ exhausted = true;
124
+ break;
125
+ }
126
+ item = array[index++];
127
+ }
128
+ running++;
129
+ iterator(item, once(done));
130
+ }
131
+ dispatching = false;
132
+ if (exhausted && running === 0 && !finished) {
133
+ finished = true;
134
+ callback(null);
135
+ }
136
+ };
137
+
138
+ /**
139
+ * @param {(E | null)=} err error
140
+ * @returns {void}
141
+ */
142
+ const done = (err) => {
143
+ if (finished) return;
144
+ running--;
145
+ if (err) {
146
+ finished = true;
147
+ callback(err);
148
+ return;
149
+ }
150
+ dispatch();
151
+ };
152
+
153
+ if (limit < 1) return callback(null);
154
+
155
+ dispatch();
156
+ };
157
+
158
+ /**
159
+ * Runs `iterator` over every item with unlimited concurrency and collects the
160
+ * results in the order of the collection, not the order of completion.
161
+ * @template T
162
+ * @template R
163
+ * @template E
164
+ * @param {Iterable<T>} collection items to iterate
165
+ * @param {(item: T, callback: (err?: E | null, result?: R) => void) => void} iterator called once per item
166
+ * @param {(err?: E | null, results?: R[]) => void} callback called with every result, or with the first error
167
+ * @returns {void}
168
+ */
169
+ const map = (collection, iterator, callback) => {
170
+ const array = Array.isArray(collection)
171
+ ? /** @type {T[]} */ (collection)
172
+ : undefined;
173
+ // Pre-sized, because growing it or `Array.from` costs measurably more on
174
+ // the small collections this is called with.
175
+ /** @type {R[]} */
176
+ // eslint-disable-next-line unicorn/no-new-array
177
+ const results = array === undefined ? [] : new Array(array.length);
178
+ let remaining = 1;
179
+ let finished = false;
180
+
181
+ /**
182
+ * @param {(E | null)=} err error
183
+ * @returns {void}
184
+ */
185
+ const settle = (err) => {
186
+ if (finished) return;
187
+ if (err) {
188
+ finished = true;
189
+ callback(err, results);
190
+ return;
191
+ }
192
+ if (--remaining === 0) {
193
+ finished = true;
194
+ callback(null, results);
195
+ }
196
+ };
197
+
198
+ /**
199
+ * @param {number} index position the result of that item belongs at
200
+ * @returns {(err?: E | null, result?: R) => void} completion callback for that item
201
+ */
202
+ const createCallback = (index) => {
203
+ let position = index;
204
+ return (err, result) => {
205
+ const at = position;
206
+ if (at === -1) throw new Error("Callback was already called");
207
+ position = -1;
208
+ // A result arriving after the run settled must not reach `results`,
209
+ // which the callback already handed to the caller.
210
+ if (finished) return;
211
+ if (!err) results[at] = /** @type {R} */ (result);
212
+ settle(err);
213
+ };
214
+ };
215
+
216
+ if (array !== undefined) {
217
+ const length = array.length;
218
+ if (length === 0) return callback(null, results);
219
+ remaining = length;
220
+ for (let i = 0; i < length; i++) iterator(array[i], createCallback(i));
221
+ return;
222
+ }
223
+
224
+ let index = 0;
225
+ for (const item of collection) {
226
+ remaining++;
227
+ iterator(item, createCallback(index++));
228
+ }
229
+ results.length = index;
230
+ settle(null);
231
+ };
232
+
233
+ /**
234
+ * Runs `iterator` over every item, at most `limit` of them in flight, and
235
+ * collects the results in the order of the collection, not of completion.
236
+ * @template T
237
+ * @template R
238
+ * @template E
239
+ * @param {Iterable<T>} collection items to iterate
240
+ * @param {number} limit maximum number of items in flight
241
+ * @param {(item: T, callback: (err?: E | null, result?: R) => void) => void} iterator called once per item
242
+ * @param {(err?: E | null, results?: R[]) => void} callback called with every result, or with the first error
243
+ * @returns {void}
244
+ */
245
+ const mapLimit = (collection, limit, iterator, callback) => {
246
+ /** @type {R[]} */
247
+ const results = [];
248
+ let index = 0;
249
+ eachLimit(
250
+ collection,
251
+ limit,
252
+ (item, done) => {
253
+ // the dispatch loop hands out one item at a time, so this counts the
254
+ // position of the item rather than of whichever finishes first
255
+ const position = index++;
256
+ iterator(item, (err, result) => {
257
+ if (err) return done(err);
258
+ results[position] = /** @type {R} */ (result);
259
+ done(null);
260
+ });
261
+ },
262
+ (err) => {
263
+ if (err) return callback(err);
264
+ callback(null, results);
265
+ }
266
+ );
267
+ };
268
+
269
+ /**
270
+ * @template R
271
+ * @template E
272
+ * @param {(callback: (err?: E | null, result?: R) => void) => void} task task to run
273
+ * @param {(err?: E | null, result?: R) => void} callback called when the task is done
274
+ * @returns {void}
275
+ */
276
+ const runTask = (task, callback) => task(callback);
277
+
278
+ /**
279
+ * Runs every task in parallel and collects the results in task order.
280
+ * @template R
281
+ * @template E
282
+ * @param {((callback: (err?: E | null, result?: R) => void) => void)[]} tasks tasks to run
283
+ * @param {(err?: E | null, results?: R[]) => void} callback called with every result, or with the first error
284
+ * @returns {void}
285
+ */
286
+ const parallel = (tasks, callback) => map(tasks, runTask, callback);
287
+
288
+ module.exports.each = each;
289
+ module.exports.eachLimit = eachLimit;
290
+ module.exports.map = map;
291
+ module.exports.mapLimit = mapLimit;
292
+ module.exports.parallel = parallel;
@@ -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
+ };
@@ -39,10 +39,9 @@ module.exports.getTrimmedIdsAndRange = (
39
39
  );
40
40
  let trimmedRange = untrimmedRange;
41
41
  if (trimmedIds.length !== untrimmedIds.length) {
42
- // The array returned from dep.idRanges is right-aligned with the array returned from dep.names.
43
- // Meaning, the two arrays may not always have the same number of elements, but the last element of
44
- // dep.idRanges corresponds to [the expression fragment to the left of] the last element of dep.names.
45
- // Use this to find the correct replacement range based on the number of ids that were trimmed.
42
+ // `dep.idRanges` is right-aligned with `dep.names`: the two may differ in
43
+ // length, but their last elements correspond, which is what turns the count
44
+ // of trimmed ids into the replacement range.
46
45
  const idx =
47
46
  ranges === undefined
48
47
  ? -1 /* trigger failure case below */
@@ -324,10 +324,10 @@ const addScopeSymbols = (s, nameSet, scopeSet1, scopeSet2) => {
324
324
  }
325
325
  };
326
326
 
327
- // Declared by the chunk bootstrap in the scope module code is hoisted into.
328
- // Hit when a webpack bundle is bundled again, since its output declares exactly
329
- // these: the `const` one then fails to parse, the `var` one silently clobbers
330
- // the module table. CompatibilityPlugin renames the other two runtime names.
327
+ // WHY: Declared by the chunk bootstrap in the scope module code is hoisted
328
+ // into, so re-bundling a webpack bundle collides with them: the `const` one
329
+ // fails to parse and the `var` one silently clobbers the module table.
330
+ // CompatibilityPlugin renames the other two runtime names.
331
331
  const CHUNK_RUNTIME_DECLARATIONS = new Set([
332
332
  "__webpack_modules__",
333
333
  "__webpack_module_cache__"
@@ -115,7 +115,11 @@ module.exports.cssExportConvention = (input, convention) => {
115
115
  const set = new Set();
116
116
  if (typeof convention === "function") {
117
117
  const result = convention(input);
118
- const validate = (/** @type {string} */ name) => {
118
+ /**
119
+ * @param {string} name name returned by the convention function
120
+ * @returns {void}
121
+ */
122
+ const validate = (name) => {
119
123
  if (typeof name !== "string" || name.length === 0) {
120
124
  throw new Error(
121
125
  `exportsConvention function must return a non-empty string or an array of non-empty strings, got ${safeStringify(result)}`
@@ -15,8 +15,7 @@ const createHooksRegistry = (createHooks) => {
15
15
  return (compilation) => {
16
16
  let hooks = map.get(compilation);
17
17
  if (hooks === undefined) {
18
- // validated once per compilation — this runs on every render and
19
- // codegen. Matched by class name, not `instanceof`: a compilation from
18
+ // Matched by class name rather than `instanceof`: a compilation from
20
19
  // another webpack copy has to pass too, and importing `Compilation`
21
20
  // here cycles.
22
21
  const candidate =
@@ -13,9 +13,9 @@
13
13
  * while richer call sites can pass arrays of segments.
14
14
  *
15
15
  * TODO move this encoder into `webpack-sources` and replace the body of this
16
- * file with re-exports. The public shape (`encodeVLQ`, `encodeMappings(lines)`,
17
- * `MappingSegment`, `LineMappings`) is intended to match what would land
18
- * upstream so call sites don't have to change.
16
+ * file with re-exports. The public shape (`encodeVLQ`, `decodeVLQ`,
17
+ * `encodeMappings(lines)`, `MappingSegment`, `LineMappings`) is intended to
18
+ * match what would land upstream so call sites don't have to change.
19
19
  */
20
20
 
21
21
  const VLQ_BASE64 =
@@ -38,6 +38,27 @@ const encodeVLQ = (value) => {
38
38
  return result;
39
39
  };
40
40
 
41
+ /**
42
+ * Decode one base64 VLQ value per the source-map V3 spec.
43
+ * @param {string} mappings a VLQ encoded `mappings` string
44
+ * @param {number} start index of the value's first character
45
+ * @returns {{ value: number, end: number }} the decoded value and the index just past it; `end` equals `start` when there is no valid value at `start`
46
+ */
47
+ const decodeVLQ = (mappings, start) => {
48
+ let value = 0;
49
+ let shift = 0;
50
+ let index = start;
51
+ let digit;
52
+ do {
53
+ digit = index < mappings.length ? VLQ_BASE64.indexOf(mappings[index]) : -1;
54
+ if (digit < 0) return { value: 0, end: start };
55
+ value += (digit & 0x1f) << shift;
56
+ shift += 5;
57
+ index++;
58
+ } while (digit & 0x20);
59
+ return { value: value & 1 ? -(value >>> 1) : value >>> 1, end: index };
60
+ };
61
+
41
62
  /**
42
63
  * @typedef {object} MappingSegment
43
64
  * @property {number=} generatedColumn 0-based generated column (defaults to 0)
@@ -114,5 +135,6 @@ const encodeMappings = (lines) => {
114
135
  return encodedLines.join(";");
115
136
  };
116
137
 
138
+ module.exports.decodeVLQ = decodeVLQ;
117
139
  module.exports.encodeMappings = encodeMappings;
118
140
  module.exports.encodeVLQ = encodeVLQ;
@@ -44,9 +44,8 @@ const decodeDataURI = (uri) => {
44
44
  */
45
45
 
46
46
  // `URIRegEx`'s `.` stops at a newline, which a raw `<svg>` payload carries, and
47
- // its `base64` group is optional in a way that reads `;charset=utf8` as one.
48
- // This one is the strict split a rewriter needs; that one stays as the matcher
49
- // module requests are recognized by.
47
+ // its optional `base64` group reads `;charset=utf8` as one. This is the strict
48
+ // split a rewriter needs; that one stays as the matcher for module requests.
50
49
  const STRICT_URI_REGEXP = /^data:([^,;]*)((?:;[^,;]*)*),([\s\S]*)$/i;
51
50
 
52
51
  const JSON_TYPE = "json";
@@ -450,12 +450,11 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
450
450
  right--;
451
451
  }
452
452
 
453
+ // WHY: both sides already clear minSize here.
453
454
  // left v v right
454
455
  // [ O O O ] O O O [ O O O ]
455
456
  // ^^^^^^^^^ leftSize
456
457
  // rightSize ^^^^^^^^^
457
- // leftSize > minSize
458
- // rightSize > minSize
459
458
 
460
459
  // Perfect split: [ O O O ] [ O O O ]
461
460
  // right === left - 1
@@ -476,26 +475,22 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
476
475
  queue.push(group);
477
476
  continue;
478
477
  }
479
- // can't split group while holding minSize
480
- // because minSize is preferred of maxSize we return
481
- // the problematic nodes as result here even while it's too big
482
- // To avoid this make sure maxSize > minSize * 3
478
+ // No split holds minSize, which is preferred over maxSize, so these
479
+ // nodes are returned oversized. Keeping maxSize > minSize * 3
480
+ // avoids it.
483
481
  result.push(group);
484
482
  continue;
485
483
  }
486
484
  if (left <= right) {
487
- // when there is a area between left and right
488
- // we look for best split point
489
- // we split at the minimum similarity
490
- // here key space is separated the most
491
- // But we also need to make sure to not create too small groups
485
+ // In the area between left and right, split at the minimum
486
+ // similarity, where the key space is separated the most — without
487
+ // creating groups that are too small.
492
488
  let best = -1;
493
489
  let bestSimilarity = Infinity;
494
490
  let pos = left;
495
491
  const rightSize = sumSize(group.nodes, pos);
496
492
 
497
- // pos v v right
498
- // [ O O O ] O O O [ O O O ]
493
+ // [ O O O ] O O O [ O O O ] pos, then right
499
494
  // ^^^^^^^^^ leftSize
500
495
  // rightSize ^^^^^^^^^^^^^^^
501
496
 
@@ -125,12 +125,9 @@ module.exports = (items, getDependencies) => {
125
125
  depSCC.marker = IN_PROGRESS_MARKER;
126
126
  break;
127
127
  case IN_PROGRESS_MARKER: {
128
- // Back-edge to an SCC that is still on the stack
129
- // Example:
130
- // A -> B -> C -> D
131
- // ^ |
132
- // |_________|
133
- // If we are at `D` and traverse `D` -> `B`, then `B/C/D` must be in one SCC
128
+ // A back-edge to an SCC still on the stack merges every SCC
129
+ // above it — in `A -> B -> C -> D` with `D -> B`, reaching `B`
130
+ // from `D` puts `B`, `C` and `D` into one SCC.
134
131
  /** @type {Set<SCC<T>>} */
135
132
  const sccsToMerge = new Set();
136
133
  for (
@@ -162,13 +159,9 @@ module.exports = (items, getDependencies) => {
162
159
  // All dependencies of the current node have been processed
163
160
  // So we leave the node
164
161
  stack.pop();
165
- // Mark an SCC as DONE only when the popped node is the last
166
- // node from that SCC remaining on the current stack.
167
- // A -> B -> C -> D
168
- // ^ |
169
- // |_________|
170
- // If `B` is popped and the new stack top is `A`, they are in
171
- // different SCCs, so B's SCC can be finalized.
162
+ // An SCC is DONE only once the popped node is its last one on
163
+ // the stack. In `A -> B -> C -> D` with `D -> B`, popping `B` onto a
164
+ // stack topped by `A` — a different SCC — finalizes B's.
172
165
  if (
173
166
  stack.length &&
174
167
  topOfStack.node.scc !== stack[stack.length - 1].node.scc
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;
@@ -558,7 +558,7 @@ const braceFreeGlobToPathRegExpSource = (glob) => {
558
558
  * pattern built with `path.resolve` works everywhere; use `[*]` to match a
559
559
  * literal `*`), and a relative pattern matches at any depth. Matching follows
560
560
  * `path.matchesGlob`, except where its minimatch shows through — see the
561
- * divergences listed above the corpus in `test/globUtils.unittest.js`.
561
+ * divergences listed above the corpus in `test/unitCases/globUtils.unittest.js`.
562
562
  * @param {string} pattern glob pattern
563
563
  * @param {GlobMatchOptions=} options options
564
564
  * @returns {((str: string) => boolean) | null} matcher, null for un-compilable patterns
@@ -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;