@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
package/README.md CHANGED
@@ -13,23 +13,22 @@ npm install @depup/webpack
13
13
 
14
14
  | Field | Value |
15
15
  |-------|-------|
16
- | Original | [webpack](https://www.npmjs.com/package/webpack) @ 5.110.3 |
17
- | Processed | 2026-09-06 |
16
+ | Original | [webpack](https://www.npmjs.com/package/webpack) @ 5.111.1 |
17
+ | Processed | 2026-09-20 |
18
18
  | Smoke test | passed |
19
- | Deps updated | 9 |
19
+ | Deps updated | 8 |
20
20
 
21
21
  ## Dependency Changes
22
22
 
23
23
  | Dependency | From | To |
24
24
  |------------|------|-----|
25
25
  | @types/estree | ^1.0.8 | ^1.0.9 |
26
- | acorn | ^8.16.0 | ^8.18.0 |
27
- | browserslist | ^4.28.1 | ^4.28.9 |
26
+ | browserslist | ^4.28.1 | ^4.29.0 |
28
27
  | chrome-trace-event | ^1.0.2 | ^1.0.4 |
29
- | enhanced-resolve | ^5.24.4 | ^5.24.5 |
30
- | es-module-lexer | ^2.1.0 | ^2.3.2 |
28
+ | enhanced-resolve | ^5.25.0 | ^5.25.1 |
29
+ | es-module-lexer | ^2.1.0 | ^3.0.2 |
31
30
  | events | ^3.2.0 | ^3.3.0 |
32
- | minimizer-webpack-plugin | ^5.7.0 | ^5.9.0 |
31
+ | minimizer-webpack-plugin | ^5.7.0 | ^5.11.0 |
33
32
  | tapable | ^2.3.0 | ^2.3.3 |
34
33
 
35
34
  ---
package/changes.json CHANGED
@@ -4,25 +4,21 @@
4
4
  "from": "^1.0.8",
5
5
  "to": "^1.0.9"
6
6
  },
7
- "acorn": {
8
- "from": "^8.16.0",
9
- "to": "^8.18.0"
10
- },
11
7
  "browserslist": {
12
8
  "from": "^4.28.1",
13
- "to": "^4.28.9"
9
+ "to": "^4.29.0"
14
10
  },
15
11
  "chrome-trace-event": {
16
12
  "from": "^1.0.2",
17
13
  "to": "^1.0.4"
18
14
  },
19
15
  "enhanced-resolve": {
20
- "from": "^5.24.4",
21
- "to": "^5.24.5"
16
+ "from": "^5.25.0",
17
+ "to": "^5.25.1"
22
18
  },
23
19
  "es-module-lexer": {
24
20
  "from": "^2.1.0",
25
- "to": "^2.3.2"
21
+ "to": "^3.0.2"
26
22
  },
27
23
  "events": {
28
24
  "from": "^3.2.0",
@@ -30,13 +26,13 @@
30
26
  },
31
27
  "minimizer-webpack-plugin": {
32
28
  "from": "^5.7.0",
33
- "to": "^5.9.0"
29
+ "to": "^5.11.0"
34
30
  },
35
31
  "tapable": {
36
32
  "from": "^2.3.0",
37
33
  "to": "^2.3.3"
38
34
  }
39
35
  },
40
- "timestamp": "2026-09-06T01:00:50.036Z",
41
- "totalUpdated": 9
36
+ "timestamp": "2026-09-20T01:00:33.211Z",
37
+ "totalUpdated": 8
42
38
  }
package/lib/APIPlugin.js CHANGED
@@ -42,12 +42,12 @@ const getConcatenatedModule = memoize(() =>
42
42
  */
43
43
  /** @import Compilation from "./Compilation" */
44
44
  /** @import ChunkGraph from "./ChunkGraph" */
45
+ /** @import { RuntimeSpec } from "./util/runtime" */
45
46
  /** @import JavascriptParser, { Range } from "./javascript/JavascriptParser" */
46
47
 
47
- // Modules that reassign `__webpack_public_path__` at runtime, by compilation. A baked
48
- // analyzable specifier can't reflect that, so those forms fall back. Also recorded per
49
- // module in `buildInfo`, because a module restored from the persistent cache is never
50
- // re-parsed and would otherwise lose the flag.
48
+ // Modules reassigning `__webpack_public_path__` at runtime, per compilation, since
49
+ // a baked specifier cannot reflect that. Also kept in `buildInfo`: a module
50
+ // restored from the persistent cache is never re-parsed.
51
51
  /** @type {WeakMap<Compilation, Set<Module>>} */
52
52
  const runtimePublicPathOverride = new WeakMap();
53
53
 
@@ -79,17 +79,30 @@ const usesRuntimePublicPathOverride = (compilation) =>
79
79
  const overriddenRuntimes = new WeakMap();
80
80
 
81
81
  /**
82
- * Whether the public path is reassigned in any runtime `module` belongs to. Falls back
83
- * to the whole compilation when there is no chunk graph to place the module in.
82
+ * Whether the public path is reassigned in any runtime the reference belongs to,
83
+ * named either by the module emitting it or by `runtime` directly — a caller holding
84
+ * a chunk rather than a module has only the latter. Falls back to the whole
85
+ * compilation when neither can place it.
84
86
  * @param {Compilation} compilation compilation
85
87
  * @param {ChunkGraph=} chunkGraph the chunk graph
86
88
  * @param {Module=} module the module a reference is emitted into
87
- * @returns {boolean} true when a reassignment can reach this module's runtimes
89
+ * @param {RuntimeSpec=} runtime the runtime it is emitted for, where no module names it
90
+ * @returns {boolean} true when a reassignment can reach those runtimes
88
91
  */
89
- const runtimeUsesPublicPathOverride = (compilation, chunkGraph, module) => {
92
+ const runtimeUsesPublicPathOverride = (
93
+ compilation,
94
+ chunkGraph,
95
+ module,
96
+ runtime
97
+ ) => {
90
98
  const modules = runtimePublicPathOverride.get(compilation);
91
99
  if (modules === undefined) return false;
92
- if (chunkGraph === undefined || module === undefined) return true;
100
+ if (
101
+ chunkGraph === undefined ||
102
+ (module === undefined && runtime === undefined)
103
+ ) {
104
+ return true;
105
+ }
93
106
  // Keyed by the chunk graph, not the compilation: `executeModule` asks with a
94
107
  // throw-away one whose answer must not outlive it.
95
108
  let runtimes = overriddenRuntimes.get(chunkGraph);
@@ -115,8 +128,10 @@ const runtimeUsesPublicPathOverride = (compilation, chunkGraph, module) => {
115
128
  if (overridden.size === 0) return false;
116
129
  /** @type {Set<string>} */
117
130
  const own = new Set();
118
- for (const runtime of chunkGraph.getModuleRuntimes(module)) {
119
- forEachRuntime(runtime, (key) => {
131
+ const reached =
132
+ module === undefined ? [runtime] : chunkGraph.getModuleRuntimes(module);
133
+ for (const each of reached) {
134
+ forEachRuntime(each, (key) => {
120
135
  own.add(/** @type {string} */ (key));
121
136
  });
122
137
  }
@@ -5,9 +5,9 @@
5
5
 
6
6
  "use strict";
7
7
 
8
- const asyncLib = require("neo-async");
9
8
  const NormalModule = require("./NormalModule");
10
9
  const PrefetchDependency = require("./dependencies/PrefetchDependency");
10
+ const asyncLib = require("./util/async");
11
11
 
12
12
  /** @import Compiler from "./Compiler" */
13
13
 
package/lib/Cache.js CHANGED
@@ -70,8 +70,11 @@ class Cache {
70
70
  get: new AsyncSeriesBailHook(["identifier", "etag", "gotHandlers"]),
71
71
  /** @type {AsyncParallelHook<[string, Etag | null, Data]>} */
72
72
  store: new AsyncParallelHook(["identifier", "etag", "data"]),
73
- /** @type {AsyncParallelHook<[Iterable<string>]>} */
74
- storeBuildDependencies: new AsyncParallelHook(["dependencies"]),
73
+ /** @type {AsyncParallelHook<[Iterable<string>, Iterable<string>]>} */
74
+ storeBuildDependencies: new AsyncParallelHook([
75
+ "dependencies",
76
+ "optionalDependencies"
77
+ ]),
75
78
  /** @type {SyncHook<[]>} */
76
79
  beginIdle: new SyncHook([]),
77
80
  /** @type {AsyncParallelHook<[]>} */
@@ -139,12 +142,14 @@ class Cache {
139
142
  * Persists the set of build dependencies required to determine whether the
140
143
  * cache can be restored in a future compilation.
141
144
  * @param {Iterable<string>} dependencies list of all build dependencies
145
+ * @param {Iterable<string>} optionalDependencies list of optional build dependencies
142
146
  * @param {CallbackCache<void>} callback signals when the dependencies are stored
143
147
  * @returns {void}
144
148
  */
145
- storeBuildDependencies(dependencies, callback) {
149
+ storeBuildDependencies(dependencies, optionalDependencies, callback) {
146
150
  this.hooks.storeBuildDependencies.callAsync(
147
151
  dependencies,
152
+ optionalDependencies,
148
153
  makeWebpackErrorCallback(callback, "Cache.hooks.storeBuildDependencies")
149
154
  );
150
155
  }
@@ -6,9 +6,9 @@
6
6
  "use strict";
7
7
 
8
8
  const { forEachBail } = require("enhanced-resolve");
9
- const asyncLib = require("neo-async");
10
9
  const getLazyHashedEtag = require("./cache/getLazyHashedEtag");
11
10
  const mergeEtags = require("./cache/mergeEtags");
11
+ const asyncLib = require("./util/async");
12
12
 
13
13
  /** @import Cache, { Etag } from "./Cache" */
14
14
  /** @import { HashableObject } from "./cache/getLazyHashedEtag" */
@@ -5,6 +5,8 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ const HarmonyImportDependency = require("./dependencies/HarmonyImportDependency");
9
+ const HarmonyImportSideEffectDependency = require("./dependencies/HarmonyImportSideEffectDependency");
8
10
  const CircularDependenciesWarning = require("./errors/CircularDependenciesWarning");
9
11
  const { compareModulesByIdentifier } = require("./util/comparators");
10
12
 
@@ -20,6 +22,22 @@ const PLUGIN_NAME = "CircularModulesPlugin";
20
22
  // Enough to name the worst tangles without printing the module graph.
21
23
  const MAX_REPORTED_CYCLES = 5;
22
24
 
25
+ // After SideEffectsFlagPlugin / FlagDependencyUsagePlugin (stage 0).
26
+ const STAGE_DETECT = 1;
27
+
28
+ /**
29
+ * Bit flags for why a module is treated as circular.
30
+ * A module may carry both bits when it sits in a sync SCC and is a binding-read target.
31
+ * @enum {number}
32
+ */
33
+ const CircularKind = {
34
+ None: 0,
35
+ /** ESM binding-observable target; blocks const export inlining (TDZ). */
36
+ Binding: 1 << 0,
37
+ /** Any synchronous SCC member; blocks value binding. */
38
+ Synchronous: 1 << 1
39
+ };
40
+
23
41
  /**
24
42
  * The module a connection makes its origin evaluate before it can run, or
25
43
  * `null` when it does not: a weak reference never loads its target, and an
@@ -120,12 +138,26 @@ const formatShortestCycle = (members, moduleGraph, requestShortener) => {
120
138
  .join(" -> ");
121
139
  };
122
140
 
141
+ /**
142
+ * Whether a sync connection may observe the target's live export binding.
143
+ * Bare side-effect imports do not, so their cycles stay Binding-free.
144
+ * @param {ModuleGraphConnection} connection an outgoing connection
145
+ * @returns {boolean} true when the dependency can read a named/default binding
146
+ */
147
+ const isBindingRead = (connection) => {
148
+ const dependency = connection.dependency;
149
+ return (
150
+ dependency instanceof HarmonyImportDependency &&
151
+ !(dependency instanceof HarmonyImportSideEffectDependency)
152
+ );
153
+ };
154
+
123
155
  /**
124
156
  * Detects circular dependencies among synchronous module imports.
125
157
  *
126
- * Builds an adjacency layout from each module's synchronous outgoing
127
- * connections (skipping weak and async-block edges), then runs an iterative
128
- * SCC algorithm to find circular modules.
158
+ * One sync-edge SCC pass yields Synchronous members; Binding is derived from
159
+ * the same components for targets of binding-reads that share a component
160
+ * (or self-import), without a second Tarjan.
129
161
  *
130
162
  * Use the static `build()` method to create an instance. All intermediate data
131
163
  * (adjacency layout, index mappings) is local to `build()` and released on
@@ -133,12 +165,15 @@ const formatShortestCycle = (members, moduleGraph, requestShortener) => {
133
165
  */
134
166
  class CycleGraph {
135
167
  /**
136
- * @param {Set<Module>} circularModules modules in a multi-module SCC or with a self-loop (for isCircular)
168
+ * @param {Set<Module>} synchronousModules sync SCC members / self-loops
169
+ * @param {Set<Module>} bindingModules binding-read targets sharing a sync SCC
137
170
  * @param {Module[][]} circularGroups multi-module SCC groups only (for reporting; self-loops omitted)
138
171
  */
139
- constructor(circularModules, circularGroups) {
172
+ constructor(synchronousModules, bindingModules, circularGroups) {
140
173
  /** @type {Set<Module>} */
141
- this.circularModules = circularModules;
174
+ this.synchronousModules = synchronousModules;
175
+ /** @type {Set<Module>} */
176
+ this.bindingModules = bindingModules;
142
177
  /** @type {Module[][]} */
143
178
  this.circularGroups = circularGroups;
144
179
  }
@@ -149,7 +184,7 @@ class CycleGraph {
149
184
  * @param {Iterable<Module>} modules the set of modules
150
185
  * @param {ModuleGraph} moduleGraph the module graph
151
186
  * @param {boolean=} collectGroups also group the modules of each cycle, which
152
- * only the hint reads — marking `isCircular` needs the set alone
187
+ * only the hint reads — marking kinds needs the sets alone
153
188
  * @returns {CycleGraph} the result
154
189
  */
155
190
  static build(modules, moduleGraph, collectGroups = false) {
@@ -163,12 +198,16 @@ class CycleGraph {
163
198
  }
164
199
 
165
200
  const size = moduleList.length;
166
- if (size === 0) return new CycleGraph(new Set(), []);
201
+ if (size === 0) {
202
+ return new CycleGraph(new Set(), new Set(), []);
203
+ }
167
204
 
168
205
  /** @type {number[][]} */
169
206
  const edges = Array.from({ length: size });
170
207
  /** @type {boolean[]} */
171
208
  const selfLoops = Array.from({ length: size }, () => false);
209
+ /** @type {[number, number][]} */
210
+ const bindingReads = [];
172
211
 
173
212
  for (let i = 0; i < size; i++) {
174
213
  const module = moduleList[i];
@@ -177,13 +216,16 @@ class CycleGraph {
177
216
  for (const connection of moduleGraph.getOutgoingConnections(module)) {
178
217
  const target = getSynchronousTarget(connection, module, moduleGraph);
179
218
  if (target === null) continue;
219
+ const binding = isBindingRead(connection);
180
220
  if (target === module) {
181
221
  selfLoops[i] = true;
222
+ if (binding) bindingReads.push([i, i]);
182
223
  continue;
183
224
  }
184
225
  const targetIdx = moduleToIndex.get(target);
185
226
  if (targetIdx !== undefined) {
186
227
  deps.push(targetIdx);
228
+ if (binding) bindingReads.push([i, targetIdx]);
187
229
  }
188
230
  }
189
231
  edges[i] = deps;
@@ -191,9 +233,12 @@ class CycleGraph {
191
233
 
192
234
  // Iterative SCC algorithm
193
235
  /** @type {Set<Module>} */
194
- const circularModules = new Set();
236
+ const synchronousModules = new Set();
195
237
  /** @type {Module[][]} */
196
238
  const circularGroups = [];
239
+ /** @type {Int32Array} */
240
+ const componentOf = new Int32Array(size).fill(-1);
241
+ let nextComponent = 0;
197
242
  let nextIndex = 0;
198
243
  const nodeIndex = new Int32Array(size).fill(-1);
199
244
  const nodeLowLink = new Int32Array(size);
@@ -246,16 +291,17 @@ class CycleGraph {
246
291
  w = /** @type {number} */ (sccStack.pop());
247
292
  nodeOnStack[w] = 0;
248
293
  group.push(w);
294
+ componentOf[w] = nextComponent;
249
295
  } while (w !== v);
296
+ nextComponent++;
250
297
 
251
298
  if (group.length > 1 || selfLoops[v]) {
252
299
  for (const idx of group) {
253
- circularModules.add(moduleList[idx]);
300
+ synchronousModules.add(moduleList[idx]);
254
301
  }
255
302
  }
256
303
 
257
- // A module that only references itself is no cycle, so it is
258
- // circular for inlining but never a group to report.
304
+ // A self-loop is synchronous-circular but not a group to report.
259
305
  if (collectGroups && group.length > 1) {
260
306
  circularGroups.push(group.map((idx) => moduleList[idx]));
261
307
  }
@@ -272,7 +318,18 @@ class CycleGraph {
272
318
  }
273
319
  }
274
320
 
275
- return new CycleGraph(circularModules, circularGroups);
321
+ /** @type {Set<Module>} */
322
+ const bindingModules = new Set();
323
+ for (const [originIdx, targetIdx] of bindingReads) {
324
+ if (
325
+ originIdx === targetIdx ||
326
+ componentOf[originIdx] === componentOf[targetIdx]
327
+ ) {
328
+ bindingModules.add(moduleList[targetIdx]);
329
+ }
330
+ }
331
+
332
+ return new CycleGraph(synchronousModules, bindingModules, circularGroups);
276
333
  }
277
334
  }
278
335
 
@@ -282,7 +339,7 @@ class CycleGraph {
282
339
  */
283
340
 
284
341
  /**
285
- * One SCC scan: marks isCircular on every module, and reports groups when hints are set.
342
+ * One sync SCC scan: marks Synchronous and Binding kinds, reports groups when hints are set.
286
343
  */
287
344
  class CircularModulesPlugin {
288
345
  /**
@@ -293,6 +350,32 @@ class CircularModulesPlugin {
293
350
  this.hints = options && options.hints;
294
351
  }
295
352
 
353
+ /**
354
+ * The circular kind recorded on `module.buildInfo`, or `undefined` when this
355
+ * plugin did not run for the compilation.
356
+ * @param {Module} module the module
357
+ * @returns {number | undefined} bit flags from CircularKind
358
+ */
359
+ static getCircularKind(module) {
360
+ const buildInfo = /** @type {BuildInfo | undefined} */ (module.buildInfo);
361
+ if (!buildInfo || buildInfo.circularKind === undefined) return undefined;
362
+ return buildInfo.circularKind;
363
+ }
364
+
365
+ /**
366
+ * Whether the module is circular. With `kind`, requires that bit to be set.
367
+ * Without `kind`, any non-None kind counts. Missing kind (plugin off) is false.
368
+ * @param {Module} module the module
369
+ * @param {number=} kind CircularKind bit to test (e.g. CircularKind.Binding)
370
+ * @returns {boolean} true when the module matches
371
+ */
372
+ static isCircular(module, kind) {
373
+ const value = CircularModulesPlugin.getCircularKind(module);
374
+ if (value === undefined) return false;
375
+ if (kind === undefined) return value !== CircularKind.None;
376
+ return (value & kind) === kind;
377
+ }
378
+
296
379
  /**
297
380
  * @param {Compiler} compiler the compiler instance
298
381
  * @returns {void}
@@ -304,48 +387,62 @@ class CircularModulesPlugin {
304
387
  /** @type {CircularDependenciesWarning | undefined} */
305
388
  let warning;
306
389
 
307
- compilation.hooks.optimizeModules.tap(PLUGIN_NAME, (modules) => {
308
- const { circularModules, circularGroups } = CycleGraph.build(
309
- modules,
310
- compilation.moduleGraph,
311
- Boolean(hints)
312
- );
313
-
314
- // Must be an explicit boolean: ConstExportsPlugin checks `=== false`.
315
- for (const m of modules) {
316
- /** @type {BuildInfo} */
317
- (m.buildInfo).isCircular = circularModules.has(m);
318
- }
390
+ compilation.hooks.optimizeDependencies.tap(
391
+ {
392
+ name: PLUGIN_NAME,
393
+ stage: STAGE_DETECT
394
+ },
395
+ (modules) => {
396
+ const { synchronousModules, bindingModules, circularGroups } =
397
+ CycleGraph.build(modules, compilation.moduleGraph, Boolean(hints));
398
+
399
+ for (const m of modules) {
400
+ let kind = CircularKind.None;
401
+ if (synchronousModules.has(m)) {
402
+ kind |= CircularKind.Synchronous;
403
+ }
404
+ if (bindingModules.has(m)) {
405
+ kind |= CircularKind.Binding;
406
+ }
407
+ const buildInfo = /** @type {BuildInfo} */ (m.buildInfo);
408
+ buildInfo.circularKind = kind;
409
+ // Kept for existing tests / readers that still check the boolean.
410
+ buildInfo.isCircular = (kind & CircularKind.Synchronous) !== 0;
411
+ }
319
412
 
320
- if (!hints) return;
321
- if (circularGroups.length === 0) return;
322
-
323
- const { moduleGraph, requestShortener } = compilation;
324
-
325
- // Largest tangle first; ties break by name, as the order groups are
326
- // discovered in is not stable.
327
- circularGroups.sort(
328
- (a, b) =>
329
- b.length - a.length ||
330
- compareModulesByIdentifier(
331
- getCanonicalMember(a),
332
- getCanonicalMember(b)
333
- )
334
- );
335
-
336
- // The shortest cycle of a large group names two of its modules, so the
337
- // size travels with it — otherwise the group reads as a pair.
338
- const groups = circularGroups
339
- .slice(0, MAX_REPORTED_CYCLES)
340
- .map((members) => ({
341
- size: members.length,
342
- cycle: formatShortestCycle(members, moduleGraph, requestShortener)
343
- }));
344
- warning = new CircularDependenciesWarning(
345
- groups,
346
- circularGroups.length
347
- );
348
- });
413
+ if (!hints) return;
414
+ if (circularGroups.length === 0) {
415
+ warning = undefined;
416
+ return;
417
+ }
418
+
419
+ const { moduleGraph, requestShortener } = compilation;
420
+
421
+ // Largest tangle first; ties break by name, as the order groups are
422
+ // discovered in is not stable.
423
+ circularGroups.sort(
424
+ (a, b) =>
425
+ b.length - a.length ||
426
+ compareModulesByIdentifier(
427
+ getCanonicalMember(a),
428
+ getCanonicalMember(b)
429
+ )
430
+ );
431
+
432
+ // The shortest cycle of a large group names two of its modules, so the
433
+ // size travels with it — otherwise the group reads as a pair.
434
+ const groups = circularGroups
435
+ .slice(0, MAX_REPORTED_CYCLES)
436
+ .map((members) => ({
437
+ size: members.length,
438
+ cycle: formatShortestCycle(members, moduleGraph, requestShortener)
439
+ }));
440
+ warning = new CircularDependenciesWarning(
441
+ groups,
442
+ circularGroups.length
443
+ );
444
+ }
445
+ );
349
446
 
350
447
  // Reported past the hash: `createHash` folds every message into it, so
351
448
  // a hint pushed earlier would change the build's identity.
@@ -364,4 +461,9 @@ class CircularModulesPlugin {
364
461
  }
365
462
  }
366
463
 
464
+ /** @type {typeof CircularKind} */
465
+ CircularModulesPlugin.CircularKind = CircularKind;
466
+ /** @type {number} */
467
+ CircularModulesPlugin.STAGE_DETECT = STAGE_DETECT;
468
+
367
469
  module.exports = CircularModulesPlugin;
@@ -6,8 +6,8 @@
6
6
  "use strict";
7
7
 
8
8
  const path = require("path");
9
- const asyncLib = require("neo-async");
10
9
  const { SyncBailHook } = require("tapable");
10
+ const asyncLib = require("./util/async");
11
11
  const createHooksRegistry = require("./util/createHooksRegistry");
12
12
  const { join } = require("./util/fs");
13
13
  const { ABSOLUTE_PATH_REGEXP } = require("./util/identifier");
@@ -98,7 +98,7 @@ const getDiffToFs = (fs, outputPath, currentAssets, callback) => {
98
98
  const directories = getDirectories(currentAssets);
99
99
  /** @type {Diff} */
100
100
  const diff = new Set();
101
- asyncLib.forEachLimit(
101
+ asyncLib.eachLimit(
102
102
  directories,
103
103
  10,
104
104
  (directory, callback) => {
@@ -180,10 +180,9 @@ class CompatibilityPlugin {
180
180
  });
181
181
  return true;
182
182
  });
183
- // `const`/`let` are block-pre-walked, by which point the name is no
184
- // longer free and `hooks.pattern` is not dispatched for it — tag
185
- // them through the kind-specific declaration hooks instead.
186
- // Returning nothing lets the variable be defined, keeping the tag.
183
+ // `const` and `let` are block-pre-walked, by which point the name is no
184
+ // longer free and `hooks.pattern` never fires, so they are tagged
185
+ // through the declaration hooks instead.
187
186
  for (const hookMap of [
188
187
  parser.hooks.varDeclarationConst,
189
188
  parser.hooks.varDeclarationLet