@atlaspack/core 2.16.2-canary.48 → 2.16.2-canary.481

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 (380) hide show
  1. package/CHANGELOG.md +1324 -0
  2. package/dist/AssetGraph.js +523 -0
  3. package/dist/Atlaspack.js +701 -0
  4. package/dist/AtlaspackConfig.js +324 -0
  5. package/dist/AtlaspackConfig.schema.js +117 -0
  6. package/dist/BundleGraph.js +1906 -0
  7. package/dist/CommittedAsset.js +142 -0
  8. package/dist/Dependency.js +125 -0
  9. package/dist/Environment.js +132 -0
  10. package/dist/EnvironmentManager.js +108 -0
  11. package/dist/IdentifierRegistry.js +38 -0
  12. package/dist/InternalConfig.js +37 -0
  13. package/dist/PackagerRunner.js +470 -0
  14. package/dist/ReporterRunner.js +151 -0
  15. package/dist/RequestTracker.js +1297 -0
  16. package/dist/SymbolPropagation.js +624 -0
  17. package/dist/TargetDescriptor.schema.js +146 -0
  18. package/dist/Transformation.js +514 -0
  19. package/dist/UncommittedAsset.js +310 -0
  20. package/dist/Validation.js +196 -0
  21. package/dist/applyRuntimes.js +384 -0
  22. package/dist/assetUtils.js +169 -0
  23. package/dist/atlaspack-v3/AtlaspackV3.js +83 -0
  24. package/dist/atlaspack-v3/NapiWorkerPool.js +114 -0
  25. package/dist/atlaspack-v3/fs.js +53 -0
  26. package/dist/atlaspack-v3/index.js +25 -0
  27. package/dist/atlaspack-v3/jsCallable.js +16 -0
  28. package/dist/atlaspack-v3/worker/compat/asset-symbols.js +190 -0
  29. package/dist/atlaspack-v3/worker/compat/bitflags.js +98 -0
  30. package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
  31. package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
  32. package/dist/atlaspack-v3/worker/compat/index.js +24 -0
  33. package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
  34. package/dist/atlaspack-v3/worker/compat/plugin-config.js +64 -0
  35. package/dist/atlaspack-v3/worker/compat/plugin-options.js +137 -0
  36. package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
  37. package/dist/atlaspack-v3/worker/compat/target.js +14 -0
  38. package/dist/atlaspack-v3/worker/side-effect-detector.js +243 -0
  39. package/dist/atlaspack-v3/worker/worker.js +398 -0
  40. package/dist/constants.js +17 -0
  41. package/dist/dumpGraphToGraphViz.js +281 -0
  42. package/dist/index.js +62 -0
  43. package/dist/loadAtlaspackPlugin.js +128 -0
  44. package/dist/loadDotEnv.js +41 -0
  45. package/dist/projectPath.js +83 -0
  46. package/dist/public/Asset.js +279 -0
  47. package/dist/public/Bundle.js +224 -0
  48. package/dist/public/BundleGraph.js +371 -0
  49. package/dist/public/BundleGroup.js +53 -0
  50. package/dist/public/Config.js +286 -0
  51. package/dist/public/Dependency.js +138 -0
  52. package/dist/public/Environment.js +278 -0
  53. package/dist/public/MutableBundleGraph.js +277 -0
  54. package/dist/public/PluginOptions.js +80 -0
  55. package/dist/public/Symbols.js +248 -0
  56. package/dist/public/Target.js +69 -0
  57. package/dist/registerCoreWithSerializer.js +38 -0
  58. package/dist/requests/AssetGraphRequest.js +430 -0
  59. package/dist/requests/AssetGraphRequestRust.js +471 -0
  60. package/dist/requests/AssetRequest.js +130 -0
  61. package/dist/requests/AtlaspackBuildRequest.js +98 -0
  62. package/dist/requests/AtlaspackConfigRequest.js +493 -0
  63. package/dist/requests/BundleGraphRequest.js +381 -0
  64. package/dist/requests/BundleGraphRequestRust.js +324 -0
  65. package/dist/requests/BundleGraphRequestUtils.js +262 -0
  66. package/dist/requests/ConfigRequest.js +246 -0
  67. package/dist/requests/DevDepRequest.js +204 -0
  68. package/dist/requests/EntryRequest.js +314 -0
  69. package/dist/requests/PackageRequest.js +89 -0
  70. package/dist/requests/PathRequest.js +349 -0
  71. package/dist/requests/TargetRequest.js +1316 -0
  72. package/dist/requests/ValidationRequest.js +49 -0
  73. package/dist/requests/WriteBundleRequest.js +522 -0
  74. package/dist/requests/WriteBundlesRequest.js +190 -0
  75. package/dist/requests/asset-graph-diff.js +128 -0
  76. package/dist/requests/asset-graph-dot.js +131 -0
  77. package/dist/resolveOptions.js +267 -0
  78. package/dist/rustWorkerThreadDylibHack.js +19 -0
  79. package/dist/serializerCore.browser.js +43 -0
  80. package/dist/summarizeRequest.js +39 -0
  81. package/dist/types.js +31 -0
  82. package/dist/utils.js +172 -0
  83. package/dist/worker.js +123 -0
  84. package/lib/AssetGraph.js +53 -15
  85. package/lib/Atlaspack.js +140 -56
  86. package/lib/AtlaspackConfig.js +17 -6
  87. package/lib/AtlaspackConfig.schema.js +16 -5
  88. package/lib/BundleGraph.js +390 -43
  89. package/lib/CommittedAsset.js +8 -2
  90. package/lib/Dependency.js +9 -3
  91. package/lib/Environment.js +16 -10
  92. package/lib/EnvironmentManager.js +143 -0
  93. package/lib/IdentifierRegistry.js +2 -4
  94. package/lib/InternalConfig.js +3 -2
  95. package/lib/PackagerRunner.js +46 -82
  96. package/lib/ReporterRunner.js +8 -12
  97. package/lib/RequestTracker.js +191 -152
  98. package/lib/SymbolPropagation.js +52 -29
  99. package/lib/TargetDescriptor.schema.js +10 -1
  100. package/lib/Transformation.js +68 -19
  101. package/lib/UncommittedAsset.js +17 -24
  102. package/lib/Validation.js +20 -5
  103. package/lib/applyRuntimes.js +98 -7
  104. package/lib/assetUtils.js +16 -6
  105. package/lib/atlaspack-v3/AtlaspackV3.js +58 -15
  106. package/lib/atlaspack-v3/NapiWorkerPool.js +63 -2
  107. package/lib/atlaspack-v3/fs.js +4 -1
  108. package/lib/atlaspack-v3/index.js +28 -1
  109. package/lib/atlaspack-v3/jsCallable.js +0 -2
  110. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +7 -4
  111. package/lib/atlaspack-v3/worker/compat/bitflags.js +31 -25
  112. package/lib/atlaspack-v3/worker/compat/dependency.js +4 -1
  113. package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
  114. package/lib/atlaspack-v3/worker/compat/index.js +0 -11
  115. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +16 -11
  116. package/lib/atlaspack-v3/worker/compat/plugin-config.js +14 -35
  117. package/lib/atlaspack-v3/worker/compat/plugin-options.js +16 -2
  118. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
  119. package/lib/atlaspack-v3/worker/compat/target.js +2 -0
  120. package/lib/atlaspack-v3/worker/index.js +3 -0
  121. package/lib/atlaspack-v3/worker/side-effect-detector.js +214 -0
  122. package/lib/atlaspack-v3/worker/worker.js +231 -79
  123. package/lib/constants.js +0 -1
  124. package/lib/dumpGraphToGraphViz.js +72 -17
  125. package/lib/index.js +46 -3
  126. package/lib/loadAtlaspackPlugin.js +2 -3
  127. package/lib/loadDotEnv.js +5 -2
  128. package/lib/projectPath.js +6 -1
  129. package/lib/public/Asset.js +22 -12
  130. package/lib/public/Bundle.js +16 -18
  131. package/lib/public/BundleGraph.js +27 -25
  132. package/lib/public/BundleGroup.js +5 -6
  133. package/lib/public/Config.js +118 -18
  134. package/lib/public/Dependency.js +9 -7
  135. package/lib/public/Environment.js +13 -8
  136. package/lib/public/MutableBundleGraph.js +56 -15
  137. package/lib/public/PluginOptions.js +2 -2
  138. package/lib/public/Symbols.js +12 -12
  139. package/lib/public/Target.js +8 -7
  140. package/lib/registerCoreWithSerializer.js +7 -4
  141. package/lib/requests/AssetGraphRequest.js +61 -40
  142. package/lib/requests/AssetGraphRequestRust.js +314 -82
  143. package/lib/requests/AssetRequest.js +24 -7
  144. package/lib/requests/AtlaspackBuildRequest.js +53 -7
  145. package/lib/requests/AtlaspackConfigRequest.js +29 -19
  146. package/lib/requests/BundleGraphRequest.js +61 -130
  147. package/lib/requests/BundleGraphRequestRust.js +381 -0
  148. package/lib/requests/BundleGraphRequestUtils.js +280 -0
  149. package/lib/requests/ConfigRequest.js +55 -7
  150. package/lib/requests/DevDepRequest.js +32 -6
  151. package/lib/requests/EntryRequest.js +4 -3
  152. package/lib/requests/PackageRequest.js +56 -12
  153. package/lib/requests/PathRequest.js +26 -6
  154. package/lib/requests/TargetRequest.js +129 -60
  155. package/lib/requests/ValidationRequest.js +6 -2
  156. package/lib/requests/WriteBundleRequest.js +329 -20
  157. package/lib/requests/WriteBundlesRequest.js +64 -10
  158. package/lib/requests/asset-graph-diff.js +13 -8
  159. package/lib/requests/asset-graph-dot.js +2 -8
  160. package/lib/resolveOptions.js +37 -14
  161. package/lib/rustWorkerThreadDylibHack.js +0 -1
  162. package/lib/serializerCore.browser.js +1 -2
  163. package/lib/summarizeRequest.js +1 -1
  164. package/lib/types/AssetGraph.d.ts +55 -0
  165. package/lib/types/Atlaspack.d.ts +52 -0
  166. package/lib/types/AtlaspackConfig.d.ts +65 -0
  167. package/lib/types/AtlaspackConfig.schema.d.ts +53 -0
  168. package/lib/types/BundleGraph.d.ts +232 -0
  169. package/lib/types/CommittedAsset.d.ts +23 -0
  170. package/lib/types/Dependency.d.ts +44 -0
  171. package/lib/types/Environment.d.ts +11 -0
  172. package/lib/types/EnvironmentManager.d.ts +37 -0
  173. package/lib/types/IdentifierRegistry.d.ts +6 -0
  174. package/lib/types/InternalConfig.d.ts +23 -0
  175. package/lib/types/PackagerRunner.d.ts +85 -0
  176. package/lib/types/ReporterRunner.d.ts +25 -0
  177. package/lib/types/RequestTracker.d.ts +385 -0
  178. package/lib/types/SymbolPropagation.d.ts +11 -0
  179. package/lib/types/TargetDescriptor.schema.d.ts +5 -0
  180. package/lib/types/Transformation.d.ts +72 -0
  181. package/lib/types/UncommittedAsset.d.ts +61 -0
  182. package/lib/types/Validation.d.ts +37 -0
  183. package/lib/types/applyRuntimes.d.ts +25 -0
  184. package/lib/types/assetUtils.d.ts +42 -0
  185. package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +35 -0
  186. package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +13 -0
  187. package/lib/types/atlaspack-v3/fs.d.ts +13 -0
  188. package/lib/types/atlaspack-v3/index.d.ts +6 -0
  189. package/lib/types/atlaspack-v3/jsCallable.d.ts +1 -0
  190. package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
  191. package/lib/types/atlaspack-v3/worker/compat/bitflags.d.ts +14 -0
  192. package/lib/types/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
  193. package/lib/types/atlaspack-v3/worker/compat/environment.d.ts +27 -0
  194. package/{src/atlaspack-v3/worker/compat/index.js → lib/types/atlaspack-v3/worker/compat/index.d.ts} +0 -2
  195. package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
  196. package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +29 -0
  197. package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +23 -0
  198. package/lib/types/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
  199. package/lib/types/atlaspack-v3/worker/compat/target.d.ts +11 -0
  200. package/lib/types/atlaspack-v3/worker/side-effect-detector.d.ts +76 -0
  201. package/lib/types/atlaspack-v3/worker/worker.d.ts +81 -0
  202. package/lib/types/constants.d.ts +13 -0
  203. package/lib/types/dumpGraphToGraphViz.d.ts +10 -0
  204. package/lib/types/index.d.ts +8 -0
  205. package/lib/types/loadAtlaspackPlugin.d.ts +8 -0
  206. package/lib/types/loadDotEnv.d.ts +3 -0
  207. package/lib/types/projectPath.d.ts +19 -0
  208. package/lib/types/public/Asset.d.ts +74 -0
  209. package/lib/types/public/Bundle.d.ts +45 -0
  210. package/lib/types/public/BundleGraph.d.ts +72 -0
  211. package/lib/types/public/BundleGroup.d.ts +12 -0
  212. package/lib/types/public/Config.d.ts +75 -0
  213. package/lib/types/public/Dependency.d.ts +32 -0
  214. package/lib/types/public/Environment.d.ts +34 -0
  215. package/lib/types/public/MutableBundleGraph.d.ts +26 -0
  216. package/lib/types/public/PluginOptions.d.ts +25 -0
  217. package/lib/types/public/Symbols.d.ts +81 -0
  218. package/lib/types/public/Target.d.ts +16 -0
  219. package/lib/types/registerCoreWithSerializer.d.ts +2 -0
  220. package/lib/types/requests/AssetGraphRequest.d.ts +76 -0
  221. package/lib/types/requests/AssetGraphRequestRust.d.ts +21 -0
  222. package/lib/types/requests/AssetRequest.d.ts +16 -0
  223. package/lib/types/requests/AtlaspackBuildRequest.d.ts +33 -0
  224. package/lib/types/requests/AtlaspackConfigRequest.d.ts +45 -0
  225. package/lib/types/requests/BundleGraphRequest.d.ts +28 -0
  226. package/lib/types/requests/BundleGraphRequestRust.d.ts +34 -0
  227. package/lib/types/requests/BundleGraphRequestUtils.d.ts +38 -0
  228. package/lib/types/requests/ConfigRequest.d.ts +67 -0
  229. package/lib/types/requests/DevDepRequest.d.ts +30 -0
  230. package/lib/types/requests/EntryRequest.d.ts +36 -0
  231. package/lib/types/requests/PackageRequest.d.ts +27 -0
  232. package/lib/types/requests/PathRequest.d.ts +48 -0
  233. package/lib/types/requests/TargetRequest.d.ts +48 -0
  234. package/lib/types/requests/ValidationRequest.d.ts +20 -0
  235. package/lib/types/requests/WriteBundleRequest.d.ts +80 -0
  236. package/lib/types/requests/WriteBundlesRequest.d.ts +32 -0
  237. package/lib/types/requests/asset-graph-diff.d.ts +1 -0
  238. package/lib/types/requests/asset-graph-dot.d.ts +9 -0
  239. package/lib/types/resolveOptions.d.ts +3 -0
  240. package/lib/types/rustWorkerThreadDylibHack.d.ts +9 -0
  241. package/lib/types/serializerCore.browser.d.ts +3 -0
  242. package/lib/types/summarizeRequest.d.ts +10 -0
  243. package/lib/types/types.d.ts +496 -0
  244. package/lib/types/utils.d.ts +23 -0
  245. package/lib/types/worker.d.ts +44 -0
  246. package/lib/types.js +8 -1
  247. package/lib/utils.js +18 -3
  248. package/lib/worker.js +32 -15
  249. package/package.json +26 -36
  250. package/src/{AssetGraph.js → AssetGraph.ts} +87 -51
  251. package/src/{Atlaspack.js → Atlaspack.ts} +181 -72
  252. package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +25 -19
  253. package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
  254. package/src/{BundleGraph.js → BundleGraph.ts} +575 -145
  255. package/src/{CommittedAsset.js → CommittedAsset.ts} +15 -13
  256. package/src/{Dependency.js → Dependency.ts} +59 -42
  257. package/src/{Environment.js → Environment.ts} +24 -15
  258. package/src/EnvironmentManager.ts +154 -0
  259. package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
  260. package/src/{InternalConfig.js → InternalConfig.ts} +22 -23
  261. package/src/{PackagerRunner.js → PackagerRunner.ts} +114 -159
  262. package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
  263. package/src/{RequestTracker.js → RequestTracker.ts} +444 -355
  264. package/src/{SymbolPropagation.js → SymbolPropagation.ts} +178 -61
  265. package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +10 -1
  266. package/src/{Transformation.js → Transformation.ts} +110 -65
  267. package/src/{UncommittedAsset.js → UncommittedAsset.ts} +45 -49
  268. package/src/{Validation.js → Validation.ts} +32 -17
  269. package/src/{applyRuntimes.js → applyRuntimes.ts} +135 -26
  270. package/src/{assetUtils.js → assetUtils.ts} +49 -36
  271. package/src/atlaspack-v3/AtlaspackV3.ts +183 -0
  272. package/src/atlaspack-v3/NapiWorkerPool.ts +129 -0
  273. package/src/atlaspack-v3/{fs.js → fs.ts} +8 -4
  274. package/src/atlaspack-v3/{index.js → index.ts} +3 -4
  275. package/src/atlaspack-v3/jsCallable.ts +14 -0
  276. package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +40 -30
  277. package/src/atlaspack-v3/worker/compat/bitflags.ts +102 -0
  278. package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +13 -13
  279. package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
  280. package/src/atlaspack-v3/worker/compat/index.ts +8 -0
  281. package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +21 -20
  282. package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +25 -56
  283. package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +19 -5
  284. package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
  285. package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
  286. package/src/atlaspack-v3/worker/index.js +2 -1
  287. package/src/atlaspack-v3/worker/side-effect-detector.ts +298 -0
  288. package/src/atlaspack-v3/worker/worker.ts +548 -0
  289. package/src/{constants.js → constants.ts} +0 -3
  290. package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
  291. package/src/index.ts +18 -0
  292. package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +8 -9
  293. package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
  294. package/src/{projectPath.js → projectPath.ts} +20 -9
  295. package/src/public/{Asset.js → Asset.ts} +41 -28
  296. package/src/public/{Bundle.js → Bundle.ts} +28 -29
  297. package/src/public/{BundleGraph.js → BundleGraph.ts} +103 -68
  298. package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
  299. package/src/public/{Config.js → Config.ts} +171 -33
  300. package/src/public/{Dependency.js → Dependency.ts} +20 -17
  301. package/src/public/{Environment.js → Environment.ts} +28 -17
  302. package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
  303. package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
  304. package/src/public/{Symbols.js → Symbols.ts} +75 -36
  305. package/src/public/{Target.js → Target.ts} +10 -8
  306. package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
  307. package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +117 -90
  308. package/src/requests/AssetGraphRequestRust.ts +557 -0
  309. package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
  310. package/src/requests/AtlaspackBuildRequest.ts +168 -0
  311. package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
  312. package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +119 -199
  313. package/src/requests/BundleGraphRequestRust.ts +470 -0
  314. package/src/requests/BundleGraphRequestUtils.ts +323 -0
  315. package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +110 -50
  316. package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +60 -35
  317. package/src/requests/{EntryRequest.js → EntryRequest.ts} +36 -31
  318. package/src/requests/{PackageRequest.js → PackageRequest.ts} +52 -25
  319. package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
  320. package/src/requests/{TargetRequest.js → TargetRequest.ts} +265 -179
  321. package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
  322. package/src/requests/WriteBundleRequest.ts +734 -0
  323. package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +134 -50
  324. package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +25 -21
  325. package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
  326. package/src/{resolveOptions.js → resolveOptions.ts} +57 -27
  327. package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
  328. package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
  329. package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
  330. package/src/types.ts +651 -0
  331. package/src/{utils.js → utils.ts} +52 -21
  332. package/src/{worker.js → worker.ts} +50 -42
  333. package/test/{AssetGraph.test.js → AssetGraph.test.ts} +5 -8
  334. package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
  335. package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
  336. package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +76 -16
  337. package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
  338. package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
  339. package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
  340. package/test/Environment.test.ts +153 -0
  341. package/test/EnvironmentManager.test.ts +188 -0
  342. package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
  343. package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
  344. package/test/PackagerRunner.test.ts +0 -0
  345. package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
  346. package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
  347. package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
  348. package/test/PublicEnvironment.test.ts +49 -0
  349. package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
  350. package/test/{RequestTracker.test.js → RequestTracker.test.ts} +136 -58
  351. package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
  352. package/test/{TargetRequest.test.js → TargetRequest.test.ts} +91 -92
  353. package/test/fixtures/config-with-reporters/.parcelrc +7 -0
  354. package/test/fixtures/custom-targets/package.json +6 -0
  355. package/test/public/Config.test.ts +104 -0
  356. package/test/requests/AssetGraphRequestRust.test.ts +443 -0
  357. package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
  358. package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
  359. package/test/requests/WriteBundleRequest.test.ts +602 -0
  360. package/test/{test-utils.js → test-utils.ts} +3 -4
  361. package/test/{utils.test.js → utils.test.ts} +1 -3
  362. package/tsconfig.json +60 -0
  363. package/tsconfig.tsbuildinfo +1 -0
  364. package/index.d.ts +0 -30
  365. package/lib/atlaspack-v3/worker/compat/plugin-logger.js +0 -29
  366. package/src/atlaspack-v3/AtlaspackV3.js +0 -87
  367. package/src/atlaspack-v3/NapiWorkerPool.js +0 -53
  368. package/src/atlaspack-v3/jsCallable.js +0 -18
  369. package/src/atlaspack-v3/worker/compat/bitflags.js +0 -100
  370. package/src/atlaspack-v3/worker/compat/plugin-logger.js +0 -47
  371. package/src/atlaspack-v3/worker/worker.js +0 -369
  372. package/src/index.js +0 -13
  373. package/src/requests/AssetGraphRequestRust.js +0 -263
  374. package/src/requests/AtlaspackBuildRequest.js +0 -111
  375. package/src/requests/WriteBundleRequest.js +0 -369
  376. package/src/types.js +0 -600
  377. package/test/Environment.test.js +0 -119
  378. package/test/PackagerRunner.test.js +0 -27
  379. package/test/PublicEnvironment.test.js +0 -27
  380. package/test/requests/AssetGraphRequestRust.test.js +0 -411
@@ -1,12 +1,10 @@
1
- // @flow strict-local
2
-
3
1
  import type {
4
2
  GraphVisitor,
5
3
  FilePath,
6
- Symbol,
7
4
  TraversalActions,
8
5
  BundleBehavior as IBundleBehavior,
9
6
  ConditionMeta,
7
+ Symbol,
10
8
  } from '@atlaspack/types';
11
9
  import type {
12
10
  ContentKey,
@@ -49,6 +47,9 @@ import {ISOLATED_ENVS} from './public/Environment';
49
47
  import {fromProjectPath, fromProjectPathRelative} from './projectPath';
50
48
  import {HASH_REF_PREFIX} from './constants';
51
49
  import {getFeatureFlag} from '@atlaspack/feature-flags';
50
+ import logger from '@atlaspack/logger';
51
+ import {fromEnvironmentId} from './EnvironmentManager';
52
+ import type {EnvironmentRef} from './EnvironmentManager';
52
53
 
53
54
  export const bundleGraphEdgeTypes = {
54
55
  // A lack of an edge type indicates to follow the edge while traversing
@@ -75,47 +76,47 @@ export const bundleGraphEdgeTypes = {
75
76
  internal_async: 5,
76
77
  // This type is used to mark an edge between a bundle and a conditional bundle.
77
78
  // This allows efficient discovery of conditional bundles in packaging
78
- conditional: 5,
79
+ conditional: 6,
80
+ } as const;
81
+
82
+ export type BundleGraphEdgeType =
83
+ (typeof bundleGraphEdgeTypes)[keyof typeof bundleGraphEdgeTypes];
84
+
85
+ type InternalSymbolResolution = {
86
+ asset: Asset;
87
+ exportSymbol: string;
88
+ symbol: Symbol | null | undefined | false;
89
+ loc: InternalSourceLocation | null | undefined;
90
+ };
91
+
92
+ type InternalExportSymbolResolution = InternalSymbolResolution & {
93
+ readonly exportAs: Symbol | string;
94
+ };
95
+
96
+ type BundleGraphOpts = {
97
+ graph: ContentGraphOpts<BundleGraphNode, BundleGraphEdgeType>;
98
+ bundleContentHashes: Map<string, string>;
99
+ assetPublicIds: Set<string>;
100
+ publicIdByAssetId: Map<string, string>;
101
+ conditions: Map<string, Condition>;
79
102
  };
80
103
 
81
- export type BundleGraphEdgeType = $Values<typeof bundleGraphEdgeTypes>;
82
-
83
- type InternalSymbolResolution = {|
84
- asset: Asset,
85
- exportSymbol: string,
86
- symbol: ?Symbol | false,
87
- loc: ?InternalSourceLocation,
88
- |};
89
-
90
- type InternalExportSymbolResolution = {|
91
- ...InternalSymbolResolution,
92
- +exportAs: Symbol | string,
93
- |};
94
-
95
- type BundleGraphOpts = {|
96
- graph: ContentGraphOpts<BundleGraphNode, BundleGraphEdgeType>,
97
- bundleContentHashes: Map<string, string>,
98
- assetPublicIds: Set<string>,
99
- publicIdByAssetId: Map<string, string>,
100
- conditions: Map<string, Condition>,
101
- |};
102
-
103
- type SerializedBundleGraph = {|
104
- $$raw: true,
105
- graph: SerializedContentGraph<BundleGraphNode, BundleGraphEdgeType>,
106
- bundleContentHashes: Map<string, string>,
107
- assetPublicIds: Set<string>,
108
- publicIdByAssetId: Map<string, string>,
109
- conditions: Map<string, Condition>,
110
- |};
111
-
112
- function makeReadOnlySet<T>(set: Set<T>): $ReadOnlySet<T> {
104
+ type SerializedBundleGraph = {
105
+ $$raw: true;
106
+ graph: SerializedContentGraph<BundleGraphNode, BundleGraphEdgeType>;
107
+ bundleContentHashes: Map<string, string>;
108
+ assetPublicIds: Set<string>;
109
+ publicIdByAssetId: Map<string, string>;
110
+ conditions: Map<string, Condition>;
111
+ };
112
+
113
+ function makeReadOnlySet<T>(set: Set<T>): ReadonlySet<T> {
113
114
  return new Proxy(set, {
114
- get(target, property) {
115
+ get(target: Set<T>, property: string) {
115
116
  if (property === 'delete' || property === 'add' || property === 'clear') {
116
117
  return undefined;
117
118
  } else {
118
- // $FlowFixMe[incompatible-type]
119
+ // @ts-expect-error TS7053
119
120
  let value = target[property];
120
121
  return typeof value === 'function' ? value.bind(target) : value;
121
122
  }
@@ -155,13 +156,13 @@ export default class BundleGraph {
155
156
  assetPublicIds,
156
157
  bundleContentHashes,
157
158
  conditions,
158
- }: {|
159
- graph: ContentGraph<BundleGraphNode, BundleGraphEdgeType>,
160
- publicIdByAssetId: Map<string, string>,
161
- assetPublicIds: Set<string>,
162
- bundleContentHashes: Map<string, string>,
163
- conditions: Map<string, Condition>,
164
- |}) {
159
+ }: {
160
+ graph: ContentGraph<BundleGraphNode, BundleGraphEdgeType>;
161
+ publicIdByAssetId: Map<string, string>;
162
+ assetPublicIds: Set<string>;
163
+ bundleContentHashes: Map<string, string>;
164
+ conditions: Map<string, Condition>;
165
+ }) {
165
166
  this._graph = graph;
166
167
  this._assetPublicIds = assetPublicIds;
167
168
  this._publicIdByAssetId = publicIdByAssetId;
@@ -219,8 +220,8 @@ export default class BundleGraph {
219
220
  // code need to be mapped to the "real" dependencies, so we need access to a map of placeholders
220
221
  // to dependencies
221
222
  const dep = node.value;
222
- // $FlowFixMe[incompatible-type] Meta is untyped
223
- const placeholder: string | void = dep.meta?.placeholder;
223
+ // @ts-expect-error TS2322
224
+ const placeholder: string | undefined = dep.meta?.placeholder;
224
225
  if (placeholder != null) {
225
226
  placeholderToDependency.set(placeholder, dep);
226
227
  }
@@ -228,7 +229,7 @@ export default class BundleGraph {
228
229
  });
229
230
 
230
231
  let walkVisited = new Set();
231
- function walk(nodeId) {
232
+ function walk(nodeId: NodeId) {
232
233
  if (walkVisited.has(nodeId)) return;
233
234
  walkVisited.add(nodeId);
234
235
 
@@ -237,8 +238,7 @@ export default class BundleGraph {
237
238
  if (getFeatureFlag('conditionalBundlingApi') && node.type === 'asset') {
238
239
  const asset = node.value;
239
240
  if (Array.isArray(asset.meta.conditions)) {
240
- // $FlowFixMe
241
- for (const condition of (asset.meta.conditions: ConditionMeta[])) {
241
+ for (const condition of asset.meta.conditions as ConditionMeta[]) {
242
242
  // Resolve the placeholders that were attached to the asset in JSTransformer to dependencies,
243
243
  // as well as create a public id for the condition.
244
244
  const {
@@ -246,10 +246,9 @@ export default class BundleGraph {
246
246
  ifTruePlaceholder,
247
247
  ifFalsePlaceholder,
248
248
  }: {
249
- key: string,
250
- ifTruePlaceholder: string,
251
- ifFalsePlaceholder: string,
252
- ...
249
+ key: string;
250
+ ifTruePlaceholder: string;
251
+ ifFalsePlaceholder: string;
253
252
  } = condition;
254
253
 
255
254
  const condHash = hashString(
@@ -283,7 +282,7 @@ export default class BundleGraph {
283
282
  if (
284
283
  node.type === 'dependency' &&
285
284
  node.value.symbols != null &&
286
- node.value.env.shouldScopeHoist &&
285
+ fromEnvironmentId(node.value.env).shouldScopeHoist &&
287
286
  // Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
288
287
  isProduction
289
288
  ) {
@@ -333,10 +332,12 @@ export default class BundleGraph {
333
332
  // Don't retarget because this cannot be resolved without also changing the asset symbols
334
333
  // (and the asset content itself).
335
334
  [...targets].every(
336
- ([, t]) => new Set([...t.values()]).size === t.size,
335
+ ([, t]: [any, any]) => new Set([...t.values()]).size === t.size,
337
336
  )
338
337
  ) {
339
- let isReexportAll = nodeValueSymbols.get('*')?.local === '*';
338
+ let isReexportAll =
339
+ nodeValueSymbols.get('*')?.local === '*' ||
340
+ node.value.meta?.hasExportStar;
340
341
  let reexportAllLoc = isReexportAll
341
342
  ? nullthrows(nodeValueSymbols.get('*')).loc
342
343
  : undefined;
@@ -351,13 +352,15 @@ export default class BundleGraph {
351
352
  value: {
352
353
  ...node.value,
353
354
  symbols: new Map(
354
- [...nodeValueSymbols].filter(([k]) =>
355
+ // @ts-expect-error TS2769
356
+ [...nodeValueSymbols].filter(([k]: [any]) =>
355
357
  externalSymbols.has(k),
356
358
  ),
357
359
  ),
358
360
  },
359
361
  usedSymbolsUp: new Map(
360
- [...node.usedSymbolsUp].filter(([k]) =>
362
+ // @ts-expect-error TS2769
363
+ [...node.usedSymbolsUp].filter(([k]: [any]) =>
361
364
  externalSymbols.has(k),
362
365
  ),
363
366
  ),
@@ -365,7 +368,7 @@ export default class BundleGraph {
365
368
  excluded: externalSymbols.size === 0,
366
369
  }),
367
370
  },
368
- ...[...targets].map(([asset, target]) => {
371
+ ...[...targets].map(([asset, target]: [any, any]) => {
369
372
  let newNodeId = hashString(
370
373
  node.id + [...target.keys()].join(','),
371
374
  );
@@ -392,17 +395,28 @@ export default class BundleGraph {
392
395
  local,
393
396
  loc: reexportAllLoc,
394
397
  });
398
+
395
399
  if (node.value.sourceAssetId != null) {
396
- let sourceAssetId = nullthrows(
397
- assetGraphNodeIdToBundleGraphNodeId.get(
398
- assetGraph.getNodeIdByContentKey(
399
- node.value.sourceAssetId,
400
+ let sourceAssetId: NodeId;
401
+
402
+ if (getFeatureFlag('sourceAssetIdBundleGraphFix')) {
403
+ [sourceAssetId] =
404
+ assetGraph.getNodeIdsConnectedTo(nodeId);
405
+ } else {
406
+ sourceAssetId = assetGraph.getNodeIdByContentKey(
407
+ node.value.sourceAssetId,
408
+ );
409
+ }
410
+
411
+ let sourceAsset = nullthrows(
412
+ graph.getNode(
413
+ nullthrows(
414
+ assetGraphNodeIdToBundleGraphNodeId.get(
415
+ sourceAssetId,
416
+ ),
400
417
  ),
401
418
  ),
402
419
  );
403
- let sourceAsset = nullthrows(
404
- graph.getNode(sourceAssetId),
405
- );
406
420
  invariant(sourceAsset.type === 'asset');
407
421
  let sourceAssetSymbols = sourceAsset.value.symbols;
408
422
  if (sourceAssetSymbols) {
@@ -421,8 +435,9 @@ export default class BundleGraph {
421
435
  }
422
436
  let usedSymbolsUp = new Map(
423
437
  [...node.usedSymbolsUp]
424
- .filter(([k]) => target.has(k) || k === '*')
425
- .map(([k, v]) => [target.get(k) ?? k, v]),
438
+ // @ts-expect-error TS2769
439
+ .filter(([k]: [any]) => target.has(k) || k === '*')
440
+ .map(([k, v]: [any, any]) => [target.get(k) ?? k, v]),
426
441
  );
427
442
  return {
428
443
  asset,
@@ -478,6 +493,7 @@ export default class BundleGraph {
478
493
  }
479
494
  walk(nullthrows(assetGraph.rootNodeId));
480
495
 
496
+ // @ts-expect-error TS2488
481
497
  for (let edge of assetGraph.getAllEdges()) {
482
498
  if (assetGroupIds.has(edge.from)) {
483
499
  continue;
@@ -502,10 +518,22 @@ export default class BundleGraph {
502
518
  continue;
503
519
  }
504
520
 
505
- let to: Array<NodeId> = dependencies.get(edge.to)?.map((v) => v.dep) ??
521
+ let to: Array<NodeId> = dependencies.get(edge.to)?.map(
522
+ (
523
+ v:
524
+ | {
525
+ asset: null;
526
+ dep: NodeId;
527
+ }
528
+ | {
529
+ asset: ContentKey;
530
+ dep: NodeId;
531
+ },
532
+ ) => v.dep,
533
+ ) ??
506
534
  assetGroupIds
507
535
  .get(edge.to)
508
- ?.map((id) =>
536
+ ?.map((id: NodeId) =>
509
537
  nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(id)),
510
538
  ) ?? [nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(edge.to))];
511
539
 
@@ -547,31 +575,189 @@ export default class BundleGraph {
547
575
  });
548
576
  }
549
577
 
578
+ /**
579
+ * Serialize the bundle graph for efficient transfer to native Rust code.
580
+ * Returns a JSON string of nodes, an array of edges, and a map of asset IDs to public IDs.
581
+ */
582
+ serializeForNative(): {
583
+ nodesJson: string;
584
+ edges: [number, number, BundleGraphEdgeType][];
585
+ publicIdByAssetId: Record<string, string>;
586
+ environmentsJson: string;
587
+ } {
588
+ const start = performance.now();
589
+
590
+ const nodes = this._graph.nodes as BundleGraphNode[];
591
+ const edges: [number, number, BundleGraphEdgeType][] = [];
592
+
593
+ const edgeIterator = this._graph.getAllEdges();
594
+ let next = edgeIterator.next();
595
+ while (!next.done) {
596
+ const edge = next.value;
597
+ edges.push([edge.from, edge.to, edge.type]);
598
+ next = edgeIterator.next();
599
+ }
600
+
601
+ // Extract and deduplicate environments
602
+ const environmentMap = new Map<string, Environment>();
603
+ const extractEnvironment = (envRef: EnvironmentRef): string => {
604
+ const env = fromEnvironmentId(envRef);
605
+ const envId = env.id;
606
+ if (!environmentMap.has(envId)) {
607
+ environmentMap.set(envId, env);
608
+ }
609
+ return envId;
610
+ };
611
+
612
+ // Replace env objects with env IDs in nodes
613
+ const processedNodes = nodes.map((node) => {
614
+ const processedNode = {...node};
615
+ if (node.type === 'asset' && node.value?.env) {
616
+ processedNode.value = {
617
+ ...node.value,
618
+ env: extractEnvironment(node.value.env),
619
+ };
620
+ } else if (node.type === 'dependency' && node.value?.env) {
621
+ processedNode.value = {
622
+ ...node.value,
623
+ env: extractEnvironment(node.value.env),
624
+ };
625
+ } else if (node.type === 'bundle' && node.value?.env) {
626
+ processedNode.value = {
627
+ ...node.value,
628
+ env: extractEnvironment(node.value.env),
629
+ };
630
+ }
631
+ return processedNode;
632
+ });
633
+
634
+ // Optimize nodes by omitting null/undefined values to reduce JSON size
635
+ const optimizedNodes = processedNodes.map((node) => this._omitNulls(node));
636
+ const nodesJson = JSON.stringify(optimizedNodes);
637
+
638
+ // Serialize environments as array
639
+ const environments = Array.from(environmentMap.values());
640
+ const environmentsJson = JSON.stringify(environments);
641
+
642
+ // Convert Map to plain object for serialization
643
+ const publicIdByAssetId: Record<string, string> = {};
644
+ for (const [assetId, publicId] of this._publicIdByAssetId) {
645
+ publicIdByAssetId[assetId] = publicId;
646
+ }
647
+
648
+ const duration = performance.now() - start;
649
+ const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
650
+ const envsSizeMB = (environmentsJson.length / (1024 * 1024)).toFixed(2);
651
+ logger.verbose({
652
+ origin: '@atlaspack/core',
653
+ message: `serializeForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${envsSizeMB}MB envs (${environmentMap.size} unique), ${nodes.length} nodes, ${edges.length} edges`,
654
+ });
655
+
656
+ return {nodesJson, edges, publicIdByAssetId, environmentsJson};
657
+ }
658
+
659
+ /**
660
+ * Serialize only the given asset nodes for native incremental update.
661
+ * Same node shape and env/omit logic as serializeForNative.
662
+ */
663
+ serializeAssetNodesForNative(assetIds: Array<string>): string {
664
+ const start = performance.now();
665
+
666
+ if (assetIds.length === 0) {
667
+ return '[]';
668
+ }
669
+
670
+ const nodes: Array<BundleGraphNode> = [];
671
+ for (const assetId of assetIds) {
672
+ const node = this._graph.getNodeByContentKey(assetId);
673
+ if (node?.type !== 'asset') {
674
+ continue;
675
+ }
676
+ const processedNode = {...node};
677
+ if (node.value?.env) {
678
+ processedNode.value = {
679
+ ...node.value,
680
+ env: fromEnvironmentId(node.value.env).id,
681
+ };
682
+ }
683
+ nodes.push(processedNode);
684
+ }
685
+ const optimizedNodes = nodes.map((node) => this._omitNulls(node));
686
+ const nodesJson = JSON.stringify(optimizedNodes);
687
+
688
+ const duration = performance.now() - start;
689
+ const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
690
+
691
+ logger.verbose({
692
+ origin: '@atlaspack/core',
693
+ message: `serializeAssetNodesForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${nodes.length} nodes`,
694
+ });
695
+ return nodesJson;
696
+ }
697
+
698
+ /**
699
+ * Remove null and undefined values from an object to reduce JSON size.
700
+ * Preserves false, 0, empty strings, and arrays.
701
+ */
702
+ private _omitNulls(obj: unknown): unknown {
703
+ if (obj === null || obj === undefined) return obj;
704
+ if (typeof obj !== 'object') return obj;
705
+ if (Array.isArray(obj)) {
706
+ return obj.map((item) => this._omitNulls(item));
707
+ }
708
+
709
+ const result: Record<string, unknown> = {};
710
+ for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
711
+ if (value === null || value === undefined) {
712
+ continue;
713
+ }
714
+ if (
715
+ typeof value === 'object' &&
716
+ !Array.isArray(value) &&
717
+ Object.keys(value as object).length === 0
718
+ ) {
719
+ continue;
720
+ }
721
+ if (typeof value === 'object') {
722
+ const processed = this._omitNulls(value);
723
+ if (processed !== undefined) {
724
+ result[key] = processed;
725
+ }
726
+ } else {
727
+ result[key] = value;
728
+ }
729
+ }
730
+ return result;
731
+ }
732
+
550
733
  createBundle(
551
734
  opts:
552
- | {|
553
- +entryAsset: Asset,
554
- +target: Target,
555
- +needsStableName?: ?boolean,
556
- +bundleBehavior?: ?IBundleBehavior,
557
- +shouldContentHash: boolean,
558
- +env: Environment,
559
- |}
560
- | {|
561
- +type: string,
562
- +env: Environment,
563
- +uniqueKey: string,
564
- +target: Target,
565
- +needsStableName?: ?boolean,
566
- +bundleBehavior?: ?IBundleBehavior,
567
- +isSplittable?: ?boolean,
568
- +pipeline?: ?string,
569
- +shouldContentHash: boolean,
570
- |},
735
+ | {
736
+ readonly entryAsset: Asset;
737
+ readonly bundleRoots?: Array<Asset>;
738
+ readonly target: Target;
739
+ readonly needsStableName?: boolean | null | undefined;
740
+ readonly bundleBehavior?: IBundleBehavior | null | undefined;
741
+ readonly shouldContentHash: boolean;
742
+ readonly env: EnvironmentRef;
743
+ }
744
+ | {
745
+ readonly type: string;
746
+ readonly env: EnvironmentRef;
747
+ readonly uniqueKey: string;
748
+ readonly target: Target;
749
+ readonly needsStableName?: boolean | null | undefined;
750
+ readonly bundleBehavior?: IBundleBehavior | null | undefined;
751
+ readonly isSplittable?: boolean | null | undefined;
752
+ readonly pipeline?: string | null | undefined;
753
+ readonly shouldContentHash: boolean;
754
+ },
571
755
  ): Bundle {
756
+ // @ts-expect-error TS2339
572
757
  let {entryAsset, target} = opts;
573
758
  let bundleId = hashString(
574
759
  'bundle:' +
760
+ // @ts-expect-error TS2339
575
761
  (opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) +
576
762
  fromProjectPathRelative(target.distDir) +
577
763
  (opts.bundleBehavior ?? ''),
@@ -603,19 +789,24 @@ export default class BundleGraph {
603
789
  hashReference: opts.shouldContentHash
604
790
  ? HASH_REF_PREFIX + bundleId
605
791
  : bundleId.slice(-8),
792
+ // @ts-expect-error TS2339
606
793
  type: opts.entryAsset ? opts.entryAsset.type : opts.type,
607
794
  env: opts.env,
608
795
  entryAssetIds: entryAsset ? [entryAsset.id] : [],
609
796
  mainEntryId: entryAsset?.id,
797
+ // @ts-expect-error TS2339
610
798
  pipeline: opts.entryAsset ? opts.entryAsset.pipeline : opts.pipeline,
611
799
  needsStableName: opts.needsStableName,
612
800
  bundleBehavior:
613
801
  opts.bundleBehavior != null
614
802
  ? BundleBehavior[opts.bundleBehavior]
615
803
  : null,
804
+ // @ts-expect-error TS2339
616
805
  isSplittable: opts.entryAsset
617
- ? opts.entryAsset.isBundleSplittable
618
- : opts.isSplittable,
806
+ ? // @ts-expect-error TS2339
807
+ opts.entryAsset.isBundleSplittable
808
+ : // @ts-expect-error TS2339
809
+ opts.isSplittable,
619
810
  isPlaceholder,
620
811
  target,
621
812
  name: null,
@@ -626,9 +817,11 @@ export default class BundleGraph {
626
817
 
627
818
  let bundleNodeId = this._graph.addNodeByContentKey(bundleId, bundleNode);
628
819
 
820
+ // @ts-expect-error TS2339
629
821
  if (opts.entryAsset) {
630
822
  this._graph.addEdge(
631
823
  bundleNodeId,
824
+ // @ts-expect-error TS2339
632
825
  this._graph.getNodeIdByContentKey(opts.entryAsset.id),
633
826
  );
634
827
  }
@@ -661,10 +854,13 @@ export default class BundleGraph {
661
854
  for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
662
855
  .getNodeIdsConnectedFrom(dependencyNodeId)
663
856
  .map((id) => [id, nullthrows(this._graph.getNode(id))])
664
- .filter(([, node]) => node.type === 'bundle_group')) {
857
+ // @ts-expect-error TS2769
858
+ .filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
859
+ // @ts-expect-error TS2339
665
860
  invariant(bundleGroupNode.type === 'bundle_group');
666
861
  this._graph.addEdge(
667
862
  bundleNodeId,
863
+ // @ts-expect-error TS2345
668
864
  bundleGroupNodeId,
669
865
  bundleGraphEdgeTypes.bundle,
670
866
  );
@@ -693,7 +889,7 @@ export default class BundleGraph {
693
889
  addAssetGraphToBundle(
694
890
  asset: Asset,
695
891
  bundle: Bundle,
696
- shouldSkipDependency: (Dependency) => boolean = (d) =>
892
+ shouldSkipDependency: (arg1: Dependency) => boolean = (d: Dependency) =>
697
893
  this.isDependencySkipped(d),
698
894
  ) {
699
895
  let assetNodeId = this._graph.getNodeIdByContentKey(asset.id);
@@ -726,10 +922,13 @@ export default class BundleGraph {
726
922
  for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
727
923
  .getNodeIdsConnectedFrom(nodeId)
728
924
  .map((id) => [id, nullthrows(this._graph.getNode(id))])
729
- .filter(([, node]) => node.type === 'bundle_group')) {
925
+ // @ts-expect-error TS2769
926
+ .filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
927
+ // @ts-expect-error TS2339
730
928
  invariant(bundleGroupNode.type === 'bundle_group');
731
929
  this._graph.addEdge(
732
930
  bundleNodeId,
931
+ // @ts-expect-error TS2345
733
932
  bundleGroupNodeId,
734
933
  bundleGraphEdgeTypes.bundle,
735
934
  );
@@ -769,7 +968,7 @@ export default class BundleGraph {
769
968
  addEntryToBundle(
770
969
  asset: Asset,
771
970
  bundle: Bundle,
772
- shouldSkipDependency?: (Dependency) => boolean,
971
+ shouldSkipDependency?: (arg1: Dependency) => boolean,
773
972
  ) {
774
973
  this.addAssetGraphToBundle(asset, bundle, shouldSkipDependency);
775
974
  if (!bundle.entryAssetIds.includes(asset.id)) {
@@ -836,11 +1035,18 @@ export default class BundleGraph {
836
1035
 
837
1036
  resolveAsyncDependency(
838
1037
  dependency: Dependency,
839
- bundle: ?Bundle,
840
- ): ?(
841
- | {|type: 'bundle_group', value: BundleGroup|}
842
- | {|type: 'asset', value: Asset|}
843
- ) {
1038
+ bundle?: Bundle | null,
1039
+ ):
1040
+ | {
1041
+ type: 'bundle_group';
1042
+ value: BundleGroup;
1043
+ }
1044
+ | {
1045
+ type: 'asset';
1046
+ value: Asset;
1047
+ }
1048
+ | null
1049
+ | undefined {
844
1050
  let depNodeId = this._graph.getNodeIdByContentKey(dependency.id);
845
1051
  let bundleNodeId =
846
1052
  bundle != null ? this._graph.getNodeIdByContentKey(bundle.id) : null;
@@ -899,7 +1105,10 @@ export default class BundleGraph {
899
1105
  }
900
1106
 
901
1107
  // eslint-disable-next-line no-unused-vars
902
- getReferencedBundle(dependency: Dependency, fromBundle: Bundle): ?Bundle {
1108
+ getReferencedBundle(
1109
+ dependency: Dependency,
1110
+ fromBundle: Bundle,
1111
+ ): Bundle | null | undefined {
903
1112
  let dependencyNodeId = this._graph.getNodeIdByContentKey(dependency.id);
904
1113
 
905
1114
  // Find an attached bundle via a reference edge (e.g. from createAssetReference).
@@ -931,8 +1140,12 @@ export default class BundleGraph {
931
1140
  return this.getBundlesInBundleGroup(node.value, {
932
1141
  includeInline: true,
933
1142
  }).find((b) => {
934
- let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
935
- return mainEntryId != null && node.value.entryAssetId === mainEntryId;
1143
+ if (getFeatureFlag('supportWebpackChunkName')) {
1144
+ return b.entryAssetIds.some((id) => id === node.value.entryAssetId);
1145
+ } else {
1146
+ let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
1147
+ return mainEntryId != null && node.value.entryAssetId === mainEntryId;
1148
+ }
936
1149
  });
937
1150
  }
938
1151
  }
@@ -1226,7 +1439,10 @@ export default class BundleGraph {
1226
1439
  });
1227
1440
  }
1228
1441
 
1229
- getResolvedAsset(dep: Dependency, bundle: ?Bundle): ?Asset {
1442
+ getResolvedAsset(
1443
+ dep: Dependency,
1444
+ bundle?: Bundle | null,
1445
+ ): Asset | null | undefined {
1230
1446
  let assets = this.getDependencyAssets(dep);
1231
1447
  let firstAsset = assets[0];
1232
1448
  let resolved =
@@ -1240,7 +1456,7 @@ export default class BundleGraph {
1240
1456
 
1241
1457
  // If a resolution still hasn't been found, return the first referenced asset.
1242
1458
  if (resolved == null) {
1243
- let potential = [];
1459
+ let potential: Array<Asset> = [];
1244
1460
  this._graph.traverse(
1245
1461
  (nodeId, _, traversal) => {
1246
1462
  let node = nullthrows(this._graph.getNode(nodeId));
@@ -1255,6 +1471,7 @@ export default class BundleGraph {
1255
1471
  );
1256
1472
 
1257
1473
  if (bundle) {
1474
+ // @ts-expect-error TS2322
1258
1475
  resolved = potential.find((a) => a.type === bundle.type);
1259
1476
  }
1260
1477
  resolved ||= potential[0];
@@ -1276,7 +1493,7 @@ export default class BundleGraph {
1276
1493
  bundle: Bundle,
1277
1494
  visit: GraphVisitor<Asset, TContext>,
1278
1495
  startAsset?: Asset,
1279
- ): ?TContext {
1496
+ ): TContext | null | undefined {
1280
1497
  return this.traverseBundle(
1281
1498
  bundle,
1282
1499
  mapVisitor((node) => (node.type === 'asset' ? node.value : null), visit),
@@ -1359,7 +1576,8 @@ export default class BundleGraph {
1359
1576
 
1360
1577
  if (
1361
1578
  descendant.type !== bundle.type ||
1362
- descendant.env.context !== bundle.env.context
1579
+ fromEnvironmentId(descendant.env).context !==
1580
+ fromEnvironmentId(bundle.env).context
1363
1581
  ) {
1364
1582
  actions.skipChildren();
1365
1583
  return;
@@ -1376,6 +1594,158 @@ export default class BundleGraph {
1376
1594
  });
1377
1595
  }
1378
1596
 
1597
+ // New method: Fast checks only (no caching of results)
1598
+ isAssetReferencedFastCheck(bundle: Bundle, asset: Asset): boolean | null {
1599
+ // Fast Check #1: If asset is in multiple bundles in same target, it's referenced
1600
+ let bundlesWithAsset = this.getBundlesWithAsset(asset).filter(
1601
+ (b) =>
1602
+ b.target.name === bundle.target.name &&
1603
+ b.target.distDir === bundle.target.distDir,
1604
+ );
1605
+
1606
+ if (bundlesWithAsset.length > 1) {
1607
+ return true;
1608
+ }
1609
+
1610
+ // Fast Check #2: If asset is referenced by any async/conditional dependency, it's referenced
1611
+ let assetNodeId = nullthrows(this._graph.getNodeIdByContentKey(asset.id));
1612
+
1613
+ if (
1614
+ this._graph
1615
+ .getNodeIdsConnectedTo(assetNodeId, bundleGraphEdgeTypes.references)
1616
+ .map((id) => this._graph.getNode(id))
1617
+ .some(
1618
+ (node) =>
1619
+ node?.type === 'dependency' &&
1620
+ (node.value.priority === Priority.lazy ||
1621
+ node.value.priority === Priority.conditional) &&
1622
+ node.value.specifierType !== SpecifierType.url,
1623
+ )
1624
+ ) {
1625
+ return true;
1626
+ }
1627
+
1628
+ // Fast checks failed - return null to indicate expensive computation needed
1629
+ return null;
1630
+ }
1631
+
1632
+ getReferencedAssets(bundle: Bundle): Set<Asset> {
1633
+ let referencedAssets = new Set<Asset>();
1634
+
1635
+ // Build a map of all assets in this bundle with their dependencies
1636
+ // This allows us to check all assets in a single traversal
1637
+ let assetDependenciesMap = new Map<Asset, Array<Dependency>>();
1638
+
1639
+ this.traverseAssets(bundle, (asset) => {
1640
+ // Always do fast checks (no caching)
1641
+ let fastCheckResult = this.isAssetReferencedFastCheck(bundle, asset);
1642
+
1643
+ if (fastCheckResult === true) {
1644
+ referencedAssets.add(asset);
1645
+ return;
1646
+ }
1647
+
1648
+ // Fast checks failed (fastCheckResult === null), need expensive computation
1649
+ // Check if it's actually referenced via traversal
1650
+
1651
+ // Store dependencies for later batch checking
1652
+ let dependencies = this._graph
1653
+ .getNodeIdsConnectedTo(
1654
+ nullthrows(this._graph.getNodeIdByContentKey(asset.id)),
1655
+ )
1656
+ .map((id) => nullthrows(this._graph.getNode(id)))
1657
+ .filter((node) => node.type === 'dependency')
1658
+ .map((node) => {
1659
+ invariant(node.type === 'dependency');
1660
+ return node.value;
1661
+ });
1662
+
1663
+ if (dependencies.length > 0) {
1664
+ assetDependenciesMap.set(asset, dependencies);
1665
+ }
1666
+ });
1667
+
1668
+ // If no assets need the expensive check, return early
1669
+ if (assetDependenciesMap.size === 0) {
1670
+ return referencedAssets;
1671
+ }
1672
+
1673
+ // Get the assets we need to check once
1674
+ let assetsToCheck = Array.from(assetDependenciesMap.keys());
1675
+
1676
+ // Helper function to check if all assets from assetDependenciesMap are in referencedAssets
1677
+ const allAssetsReferenced = (): boolean =>
1678
+ assetsToCheck.length <= referencedAssets.size &&
1679
+ assetsToCheck.every((asset) => referencedAssets.has(asset));
1680
+
1681
+ // Do ONE traversal to check all remaining assets
1682
+ // We can share visitedBundles across all assets because we check every asset
1683
+ // against every visited bundle, which matches the original per-asset behavior
1684
+ let siblingBundles = new Set(
1685
+ this.getBundleGroupsContainingBundle(bundle).flatMap((bundleGroup) =>
1686
+ this.getBundlesInBundleGroup(bundleGroup, {includeInline: true}),
1687
+ ),
1688
+ );
1689
+
1690
+ let visitedBundles: Set<Bundle> = new Set();
1691
+
1692
+ // Single traversal from all referencers
1693
+ for (let referencer of siblingBundles) {
1694
+ this.traverseBundles((descendant, _, actions) => {
1695
+ if (descendant.id === bundle.id) {
1696
+ return;
1697
+ }
1698
+
1699
+ if (visitedBundles.has(descendant)) {
1700
+ actions.skipChildren();
1701
+ return;
1702
+ }
1703
+
1704
+ visitedBundles.add(descendant);
1705
+
1706
+ if (
1707
+ descendant.type !== bundle.type ||
1708
+ fromEnvironmentId(descendant.env).context !==
1709
+ fromEnvironmentId(bundle.env).context
1710
+ ) {
1711
+ // Don't skip children - they might be the right type!
1712
+ return;
1713
+ }
1714
+
1715
+ // Check ALL assets at once in this descendant bundle
1716
+ for (let [asset, dependencies] of assetDependenciesMap) {
1717
+ // Skip if already marked as referenced
1718
+ if (referencedAssets.has(asset)) {
1719
+ continue;
1720
+ }
1721
+
1722
+ // Check if this descendant bundle references the asset
1723
+ if (
1724
+ !this.bundleHasAsset(descendant, asset) &&
1725
+ dependencies.some((dependency) =>
1726
+ this.bundleHasDependency(descendant, dependency),
1727
+ )
1728
+ ) {
1729
+ referencedAssets.add(asset);
1730
+ }
1731
+ }
1732
+
1733
+ // If all assets from assetDependenciesMap are now marked as referenced, we can stop early
1734
+ if (allAssetsReferenced()) {
1735
+ actions.stop();
1736
+ return;
1737
+ }
1738
+ }, referencer);
1739
+
1740
+ // If all assets from assetDependenciesMap are referenced, no need to check more sibling bundles
1741
+ if (allAssetsReferenced()) {
1742
+ break;
1743
+ }
1744
+ }
1745
+
1746
+ return referencedAssets;
1747
+ }
1748
+
1379
1749
  hasParentBundleOfType(bundle: Bundle, type: string): boolean {
1380
1750
  let parents = this.getParentBundles(bundle);
1381
1751
  return (
@@ -1400,10 +1770,11 @@ export default class BundleGraph {
1400
1770
  // If a bundle's environment is isolated, it can't access assets present
1401
1771
  // in any ancestor bundles. Don't consider any assets reachable.
1402
1772
  if (
1403
- ISOLATED_ENVS.has(bundle.env.context) ||
1773
+ ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
1404
1774
  !bundle.isSplittable ||
1405
1775
  bundle.bundleBehavior === BundleBehavior.isolated ||
1406
- bundle.bundleBehavior === BundleBehavior.inline
1776
+ bundle.bundleBehavior === BundleBehavior.inline ||
1777
+ bundle.bundleBehavior === BundleBehavior.inlineIsolated
1407
1778
  ) {
1408
1779
  return false;
1409
1780
  }
@@ -1420,6 +1791,7 @@ export default class BundleGraph {
1420
1791
  b.id !== bundle.id &&
1421
1792
  b.bundleBehavior !== BundleBehavior.isolated &&
1422
1793
  b.bundleBehavior !== BundleBehavior.inline &&
1794
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1423
1795
  this.bundleHasAsset(b, asset),
1424
1796
  )
1425
1797
  ) {
@@ -1438,7 +1810,8 @@ export default class BundleGraph {
1438
1810
  if (
1439
1811
  bundleNode.type !== 'bundle' ||
1440
1812
  bundleNode.value.bundleBehavior === BundleBehavior.isolated ||
1441
- bundleNode.value.bundleBehavior === BundleBehavior.inline
1813
+ bundleNode.value.bundleBehavior === BundleBehavior.inline ||
1814
+ bundleNode.value.bundleBehavior === BundleBehavior.inlineIsolated
1442
1815
  ) {
1443
1816
  return false;
1444
1817
  }
@@ -1454,7 +1827,8 @@ export default class BundleGraph {
1454
1827
  node.type === 'root' ||
1455
1828
  (node.type === 'bundle' &&
1456
1829
  (node.value.id === bundle.id ||
1457
- node.value.env.context !== bundle.env.context))
1830
+ fromEnvironmentId(node.value.env).context !==
1831
+ fromEnvironmentId(bundle.env).context))
1458
1832
  ) {
1459
1833
  isReachable = false;
1460
1834
  actions.stop();
@@ -1469,6 +1843,7 @@ export default class BundleGraph {
1469
1843
  b.id !== bundle.id &&
1470
1844
  b.bundleBehavior !== BundleBehavior.isolated &&
1471
1845
  b.bundleBehavior !== BundleBehavior.inline &&
1846
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1472
1847
  this.bundleHasAsset(b, asset),
1473
1848
  )
1474
1849
  ) {
@@ -1486,14 +1861,42 @@ export default class BundleGraph {
1486
1861
  }
1487
1862
 
1488
1863
  /**
1489
- * TODO: Document why this works like this & why visitor order matters
1490
- * on these use-cases.
1864
+ * Performs a depth-first traversal of all assets and dependencies contained
1865
+ * within a bundle. Only visits nodes that are directly contained in the bundle
1866
+ * (connected via a `contains` edge).
1867
+ *
1868
+ * Entry Asset Ordering:
1869
+ * The traversal guarantees that entry assets are visited in the exact order they
1870
+ * appear in `bundle.entryAssetIds`. This ordering is critical for several reasons:
1871
+ *
1872
+ * 1. **Code Execution Order in Packagers**: Packagers (ScopeHoistingPackager,
1873
+ * DevPackager) use this traversal to concatenate assets into the final bundle.
1874
+ * The traversal order determines the execution order of code in the output.
1875
+ * Entry assets must be processed in their defined order to ensure correct
1876
+ * initialization sequences.
1877
+ *
1878
+ * 2. **Runtime Injection**: Runtime assets (HMR, bundle manifests) are prepended
1879
+ * to `entryAssetIds` via `unshift()` in `applyRuntimes.ts`. By honoring the
1880
+ * array order, runtimes are guaranteed to be visited (and thus output) before
1881
+ * application entry points, ensuring the runtime infrastructure is available
1882
+ * when application code executes.
1883
+ *
1884
+ * 3. **Deterministic Builds**: Consistent traversal order ensures reproducible
1885
+ * bundle output, which is essential for caching and build verification.
1886
+ *
1887
+ * The sorting only applies at the first traversal level (direct children of the
1888
+ * start node). Subsequent levels follow standard DFS order based on the graph's
1889
+ * edge structure.
1890
+ *
1891
+ * @param bundle - The bundle to traverse
1892
+ * @param visit - Visitor callback receiving asset or dependency nodes
1893
+ * @param startAsset - Optional asset to start traversal from (defaults to bundle root)
1491
1894
  */
1492
1895
  traverseBundle<TContext>(
1493
1896
  bundle: Bundle,
1494
1897
  visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
1495
1898
  startAsset?: Asset,
1496
- ): ?TContext {
1899
+ ): TContext | null | undefined {
1497
1900
  let entries = !startAsset;
1498
1901
  let bundleNodeId = this._graph.getNodeIdByContentKey(bundle.id);
1499
1902
 
@@ -1531,7 +1934,8 @@ export default class BundleGraph {
1531
1934
 
1532
1935
  let sorted =
1533
1936
  entries && bundle.entryAssetIds.length > 0
1534
- ? children.sort(([, a], [, b]) => {
1937
+ ? // @ts-expect-error TS2345
1938
+ children.sort(([, a]: [any, any], [, b]: [any, any]) => {
1535
1939
  let aIndex = bundle.entryAssetIds.indexOf(a.id);
1536
1940
  let bIndex = bundle.entryAssetIds.indexOf(b.id);
1537
1941
 
@@ -1550,7 +1954,8 @@ export default class BundleGraph {
1550
1954
  : children;
1551
1955
 
1552
1956
  entries = false;
1553
- return sorted.map(([id]) => id);
1957
+ // @ts-expect-error TS2345
1958
+ return sorted.map(([id]: [any]) => id);
1554
1959
  },
1555
1960
  });
1556
1961
  }
@@ -1558,7 +1963,7 @@ export default class BundleGraph {
1558
1963
  traverse<TContext>(
1559
1964
  visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
1560
1965
  start?: Asset,
1561
- ): ?TContext {
1966
+ ): TContext | null | undefined {
1562
1967
  return this._graph.filteredTraverse(
1563
1968
  (nodeId) => {
1564
1969
  let node = nullthrows(this._graph.getNode(nodeId));
@@ -1574,7 +1979,7 @@ export default class BundleGraph {
1574
1979
 
1575
1980
  getChildBundles(bundle: Bundle): Array<Bundle> {
1576
1981
  let siblings = new Set(this.getReferencedBundles(bundle));
1577
- let bundles = [];
1982
+ let bundles: Array<Bundle> = [];
1578
1983
  this.traverseBundles((b, _, actions) => {
1579
1984
  if (bundle.id === b.id) {
1580
1985
  return;
@@ -1591,8 +1996,8 @@ export default class BundleGraph {
1591
1996
 
1592
1997
  traverseBundles<TContext>(
1593
1998
  visit: GraphVisitor<Bundle, TContext>,
1594
- startBundle: ?Bundle,
1595
- ): ?TContext {
1999
+ startBundle?: Bundle | null,
2000
+ ): TContext | null | undefined {
1596
2001
  return this._graph.filteredTraverse(
1597
2002
  (nodeId) => {
1598
2003
  let node = nullthrows(this._graph.getNode(nodeId));
@@ -1604,12 +2009,13 @@ export default class BundleGraph {
1604
2009
  );
1605
2010
  }
1606
2011
 
1607
- getBundles(opts?: {|includeInline: boolean|}): Array<Bundle> {
1608
- let bundles = [];
2012
+ getBundles(opts?: {includeInline: boolean}): Array<Bundle> {
2013
+ let bundles: Array<Bundle> = [];
1609
2014
  this.traverseBundles((bundle) => {
1610
2015
  if (
1611
2016
  opts?.includeInline ||
1612
- bundle.bundleBehavior !== BundleBehavior.inline
2017
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
2018
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1613
2019
  ) {
1614
2020
  bundles.push(bundle);
1615
2021
  }
@@ -1679,7 +2085,9 @@ export default class BundleGraph {
1679
2085
 
1680
2086
  getBundlesInBundleGroup(
1681
2087
  bundleGroup: BundleGroup,
1682
- opts?: {|includeInline: boolean|},
2088
+ opts?: {
2089
+ includeInline: boolean;
2090
+ },
1683
2091
  ): Array<Bundle> {
1684
2092
  let bundles: Set<Bundle> = new Set();
1685
2093
  for (let bundleNodeId of this._graph.getNodeIdsConnectedFrom(
@@ -1691,7 +2099,8 @@ export default class BundleGraph {
1691
2099
  let bundle = bundleNode.value;
1692
2100
  if (
1693
2101
  opts?.includeInline ||
1694
- bundle.bundleBehavior !== BundleBehavior.inline
2102
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
2103
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1695
2104
  ) {
1696
2105
  bundles.add(bundle);
1697
2106
  }
@@ -1708,7 +2117,10 @@ export default class BundleGraph {
1708
2117
 
1709
2118
  getReferencedBundles(
1710
2119
  bundle: Bundle,
1711
- opts?: {|recursive?: boolean, includeInline?: boolean|},
2120
+ opts?: {
2121
+ recursive?: boolean;
2122
+ includeInline?: boolean;
2123
+ },
1712
2124
  ): Array<Bundle> {
1713
2125
  let recursive = opts?.recursive ?? true;
1714
2126
  let includeInline = opts?.includeInline ?? false;
@@ -1726,7 +2138,8 @@ export default class BundleGraph {
1726
2138
 
1727
2139
  if (
1728
2140
  includeInline ||
1729
- node.value.bundleBehavior !== BundleBehavior.inline
2141
+ (node.value.bundleBehavior !== BundleBehavior.inline &&
2142
+ node.value.bundleBehavior !== BundleBehavior.inlineIsolated)
1730
2143
  ) {
1731
2144
  referencedBundles.add(node.value);
1732
2145
  }
@@ -1746,6 +2159,7 @@ export default class BundleGraph {
1746
2159
  ),
1747
2160
  });
1748
2161
 
2162
+ // @ts-expect-error TS2322
1749
2163
  return [...referencedBundles];
1750
2164
  }
1751
2165
 
@@ -1768,7 +2182,7 @@ export default class BundleGraph {
1768
2182
  });
1769
2183
  }
1770
2184
 
1771
- getAssetWithDependency(dep: Dependency): ?Asset {
2185
+ getAssetWithDependency(dep: Dependency): Asset | null | undefined {
1772
2186
  if (!this._graph.hasContentKey(dep.id)) {
1773
2187
  return null;
1774
2188
  }
@@ -1777,6 +2191,7 @@ export default class BundleGraph {
1777
2191
  let count = 0;
1778
2192
  this._graph.forEachNodeIdConnectedTo(
1779
2193
  this._graph.getNodeIdByContentKey(dep.id),
2194
+ // @ts-expect-error TS2345
1780
2195
  (node) => {
1781
2196
  res = node;
1782
2197
  count += 1;
@@ -1817,16 +2232,16 @@ export default class BundleGraph {
1817
2232
 
1818
2233
  filteredTraverse<TValue, TContext>(
1819
2234
  bundleNodeId: NodeId,
1820
- filter: (NodeId, TraversalActions) => ?TValue,
2235
+ filter: (arg1: NodeId, arg2: TraversalActions) => TValue | null | undefined,
1821
2236
  visit: GraphVisitor<TValue, TContext>,
1822
- ): ?TContext {
2237
+ ): TContext | null | undefined {
1823
2238
  return this._graph.filteredTraverse(filter, visit, bundleNodeId);
1824
2239
  }
1825
2240
 
1826
2241
  getSymbolResolution(
1827
2242
  asset: Asset,
1828
2243
  symbol: Symbol,
1829
- boundary: ?Bundle,
2244
+ boundary?: Bundle | null,
1830
2245
  ): InternalSymbolResolution {
1831
2246
  let assetOutside = boundary && !this.bundleHasAsset(boundary, asset);
1832
2247
 
@@ -1853,7 +2268,7 @@ export default class BundleGraph {
1853
2268
  }
1854
2269
  // If this is a re-export, find the original module.
1855
2270
  let symbolLookup = new Map(
1856
- [...depSymbols].map(([key, val]) => [val.local, key]),
2271
+ [...depSymbols].map(([key, val]: [any, any]) => [val.local, key]),
1857
2272
  );
1858
2273
  let depSymbol = symbolLookup.get(identifier);
1859
2274
  if (depSymbol != null) {
@@ -1904,7 +2319,7 @@ export default class BundleGraph {
1904
2319
  // Wildcard reexports are never listed in the reexporting asset's symbols.
1905
2320
  if (
1906
2321
  identifier == null &&
1907
- depSymbols.get('*')?.local === '*' &&
2322
+ (depSymbols.get('*')?.local === '*' || dep.meta?.hasExportStar) &&
1908
2323
  symbol !== 'default'
1909
2324
  ) {
1910
2325
  let resolved = this.getResolvedAsset(dep, boundary);
@@ -1971,17 +2386,20 @@ export default class BundleGraph {
1971
2386
  let result = identifier;
1972
2387
  if (skipped) {
1973
2388
  // ... and it was excluded (by symbol propagation) or deferred.
2389
+ // @ts-expect-error TS2322
1974
2390
  result = false;
1975
2391
  } else {
1976
2392
  // ... and there is no single reexport, but it might still be exported:
1977
2393
  if (found) {
1978
2394
  // Fallback to namespace access, because of a bundle boundary.
2395
+ // @ts-expect-error TS2322
1979
2396
  result = null;
1980
2397
  } else if (result === undefined) {
1981
2398
  // If not exported explicitly by the asset (= would have to be in * or a reexport-all) ...
1982
2399
  if (nonStaticDependency || asset.symbols?.has('*')) {
1983
2400
  // ... and if there are non-statically analyzable dependencies or it's a CJS asset,
1984
2401
  // fallback to namespace access.
2402
+ // @ts-expect-error TS2322
1985
2403
  result = null;
1986
2404
  }
1987
2405
  // (It shouldn't be possible for the symbol to be in a reexport-all and to end up here).
@@ -2019,13 +2437,13 @@ export default class BundleGraph {
2019
2437
 
2020
2438
  getExportedSymbols(
2021
2439
  asset: Asset,
2022
- boundary: ?Bundle,
2440
+ boundary?: Bundle | null,
2023
2441
  ): Array<InternalExportSymbolResolution> {
2024
2442
  if (!asset.symbols) {
2025
2443
  return [];
2026
2444
  }
2027
2445
 
2028
- let symbols = [];
2446
+ let symbols: Array<InternalExportSymbolResolution> = [];
2029
2447
 
2030
2448
  for (let symbol of asset.symbols.keys()) {
2031
2449
  symbols.push({
@@ -2039,7 +2457,7 @@ export default class BundleGraph {
2039
2457
  let depSymbols = dep.symbols;
2040
2458
  if (!depSymbols) continue;
2041
2459
 
2042
- if (depSymbols.get('*')?.local === '*') {
2460
+ if (depSymbols.get('*')?.local === '*' || dep.meta?.hasExportStar) {
2043
2461
  let resolved = this.getResolvedAsset(dep, boundary);
2044
2462
  if (!resolved) continue;
2045
2463
  let exported = this.getExportedSymbols(resolved, boundary)
@@ -2076,9 +2494,9 @@ export default class BundleGraph {
2076
2494
  }
2077
2495
 
2078
2496
  getInlineBundles(bundle: Bundle): Array<Bundle> {
2079
- let bundles = [];
2497
+ let bundles: Array<Bundle> = [];
2080
2498
  let seen = new Set();
2081
- let addReferencedBundles = (bundle) => {
2499
+ let addReferencedBundles = (bundle: Bundle) => {
2082
2500
  if (seen.has(bundle.id)) {
2083
2501
  return;
2084
2502
  }
@@ -2089,7 +2507,10 @@ export default class BundleGraph {
2089
2507
  includeInline: true,
2090
2508
  });
2091
2509
  for (let referenced of referencedBundles) {
2092
- if (referenced.bundleBehavior === BundleBehavior.inline) {
2510
+ if (
2511
+ referenced.bundleBehavior === BundleBehavior.inline ||
2512
+ referenced.bundleBehavior === BundleBehavior.inlineIsolated
2513
+ ) {
2093
2514
  bundles.push(referenced);
2094
2515
  addReferencedBundles(referenced);
2095
2516
  }
@@ -2099,7 +2520,10 @@ export default class BundleGraph {
2099
2520
  addReferencedBundles(bundle);
2100
2521
 
2101
2522
  this.traverseBundles((childBundle, _, traversal) => {
2102
- if (childBundle.bundleBehavior === BundleBehavior.inline) {
2523
+ if (
2524
+ childBundle.bundleBehavior === BundleBehavior.inline ||
2525
+ childBundle.bundleBehavior === BundleBehavior.inlineIsolated
2526
+ ) {
2103
2527
  bundles.push(childBundle);
2104
2528
  } else if (childBundle.id !== bundle.id) {
2105
2529
  traversal.skipChildren();
@@ -2128,7 +2552,9 @@ export default class BundleGraph {
2128
2552
  hash.writeString(referencedBundle.id);
2129
2553
  }
2130
2554
 
2131
- hash.writeString(JSON.stringify(objectSortedEntriesDeep(bundle.env)));
2555
+ hash.writeString(
2556
+ JSON.stringify(objectSortedEntriesDeep(fromEnvironmentId(bundle.env))),
2557
+ );
2132
2558
  return hash.finish();
2133
2559
  }
2134
2560
 
@@ -2172,7 +2598,7 @@ export default class BundleGraph {
2172
2598
  }
2173
2599
  }
2174
2600
 
2175
- getUsedSymbolsAsset(asset: Asset): ?$ReadOnlySet<Symbol> {
2601
+ getUsedSymbolsAsset(asset: Asset): ReadonlySet<Symbol> | null | undefined {
2176
2602
  let node = this._graph.getNodeByContentKey(asset.id);
2177
2603
  invariant(node && node.type === 'asset');
2178
2604
  return node.value.symbols
@@ -2180,7 +2606,9 @@ export default class BundleGraph {
2180
2606
  : null;
2181
2607
  }
2182
2608
 
2183
- getUsedSymbolsDependency(dep: Dependency): ?$ReadOnlySet<Symbol> {
2609
+ getUsedSymbolsDependency(
2610
+ dep: Dependency,
2611
+ ): ReadonlySet<Symbol> | null | undefined {
2184
2612
  let node = this._graph.getNodeByContentKey(dep.id);
2185
2613
  invariant(node && node.type === 'dependency');
2186
2614
  return node.value.symbols
@@ -2228,6 +2656,7 @@ export default class BundleGraph {
2228
2656
  }
2229
2657
  }
2230
2658
 
2659
+ // @ts-expect-error TS2488
2231
2660
  for (let edge of other._graph.getAllEdges()) {
2232
2661
  this._graph.addEdge(
2233
2662
  nullthrows(otherGraphIdToThisNodeId.get(edge.from)),
@@ -2272,7 +2701,7 @@ export default class BundleGraph {
2272
2701
  bundleGraphEdgeTypes.bundle,
2273
2702
  );
2274
2703
 
2275
- let entries = [];
2704
+ let entries: Array<FilePath> = [];
2276
2705
  for (let bundleGroupId of entryBundleGroupIds) {
2277
2706
  let bundleGroupNode = this._graph.getNode(bundleGroupId);
2278
2707
  invariant(bundleGroupNode?.type === 'bundle_group');
@@ -2312,6 +2741,7 @@ export default class BundleGraph {
2312
2741
  ),
2313
2742
  });
2314
2743
 
2744
+ // @ts-expect-error TS2322
2315
2745
  return [...referencedBundles];
2316
2746
  }
2317
2747
  }