@atlaspack/core 2.16.2-canary.46 → 2.16.2-canary.460

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 +1280 -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 +1905 -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 +620 -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 +384 -37
  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 +44 -21
  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} +570 -142
  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} +165 -57
  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,7 +332,7 @@ 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
338
  let isReexportAll = nodeValueSymbols.get('*')?.local === '*';
@@ -351,13 +350,15 @@ export default class BundleGraph {
351
350
  value: {
352
351
  ...node.value,
353
352
  symbols: new Map(
354
- [...nodeValueSymbols].filter(([k]) =>
353
+ // @ts-expect-error TS2769
354
+ [...nodeValueSymbols].filter(([k]: [any]) =>
355
355
  externalSymbols.has(k),
356
356
  ),
357
357
  ),
358
358
  },
359
359
  usedSymbolsUp: new Map(
360
- [...node.usedSymbolsUp].filter(([k]) =>
360
+ // @ts-expect-error TS2769
361
+ [...node.usedSymbolsUp].filter(([k]: [any]) =>
361
362
  externalSymbols.has(k),
362
363
  ),
363
364
  ),
@@ -365,7 +366,7 @@ export default class BundleGraph {
365
366
  excluded: externalSymbols.size === 0,
366
367
  }),
367
368
  },
368
- ...[...targets].map(([asset, target]) => {
369
+ ...[...targets].map(([asset, target]: [any, any]) => {
369
370
  let newNodeId = hashString(
370
371
  node.id + [...target.keys()].join(','),
371
372
  );
@@ -392,17 +393,28 @@ export default class BundleGraph {
392
393
  local,
393
394
  loc: reexportAllLoc,
394
395
  });
396
+
395
397
  if (node.value.sourceAssetId != null) {
396
- let sourceAssetId = nullthrows(
397
- assetGraphNodeIdToBundleGraphNodeId.get(
398
- assetGraph.getNodeIdByContentKey(
399
- node.value.sourceAssetId,
398
+ let sourceAssetId: NodeId;
399
+
400
+ if (getFeatureFlag('sourceAssetIdBundleGraphFix')) {
401
+ [sourceAssetId] =
402
+ assetGraph.getNodeIdsConnectedTo(nodeId);
403
+ } else {
404
+ sourceAssetId = assetGraph.getNodeIdByContentKey(
405
+ node.value.sourceAssetId,
406
+ );
407
+ }
408
+
409
+ let sourceAsset = nullthrows(
410
+ graph.getNode(
411
+ nullthrows(
412
+ assetGraphNodeIdToBundleGraphNodeId.get(
413
+ sourceAssetId,
414
+ ),
400
415
  ),
401
416
  ),
402
417
  );
403
- let sourceAsset = nullthrows(
404
- graph.getNode(sourceAssetId),
405
- );
406
418
  invariant(sourceAsset.type === 'asset');
407
419
  let sourceAssetSymbols = sourceAsset.value.symbols;
408
420
  if (sourceAssetSymbols) {
@@ -421,8 +433,9 @@ export default class BundleGraph {
421
433
  }
422
434
  let usedSymbolsUp = new Map(
423
435
  [...node.usedSymbolsUp]
424
- .filter(([k]) => target.has(k) || k === '*')
425
- .map(([k, v]) => [target.get(k) ?? k, v]),
436
+ // @ts-expect-error TS2769
437
+ .filter(([k]: [any]) => target.has(k) || k === '*')
438
+ .map(([k, v]: [any, any]) => [target.get(k) ?? k, v]),
426
439
  );
427
440
  return {
428
441
  asset,
@@ -478,6 +491,7 @@ export default class BundleGraph {
478
491
  }
479
492
  walk(nullthrows(assetGraph.rootNodeId));
480
493
 
494
+ // @ts-expect-error TS2488
481
495
  for (let edge of assetGraph.getAllEdges()) {
482
496
  if (assetGroupIds.has(edge.from)) {
483
497
  continue;
@@ -502,10 +516,22 @@ export default class BundleGraph {
502
516
  continue;
503
517
  }
504
518
 
505
- let to: Array<NodeId> = dependencies.get(edge.to)?.map((v) => v.dep) ??
519
+ let to: Array<NodeId> = dependencies.get(edge.to)?.map(
520
+ (
521
+ v:
522
+ | {
523
+ asset: null;
524
+ dep: NodeId;
525
+ }
526
+ | {
527
+ asset: ContentKey;
528
+ dep: NodeId;
529
+ },
530
+ ) => v.dep,
531
+ ) ??
506
532
  assetGroupIds
507
533
  .get(edge.to)
508
- ?.map((id) =>
534
+ ?.map((id: NodeId) =>
509
535
  nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(id)),
510
536
  ) ?? [nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(edge.to))];
511
537
 
@@ -547,31 +573,189 @@ export default class BundleGraph {
547
573
  });
548
574
  }
549
575
 
576
+ /**
577
+ * Serialize the bundle graph for efficient transfer to native Rust code.
578
+ * Returns a JSON string of nodes, an array of edges, and a map of asset IDs to public IDs.
579
+ */
580
+ serializeForNative(): {
581
+ nodesJson: string;
582
+ edges: [number, number, BundleGraphEdgeType][];
583
+ publicIdByAssetId: Record<string, string>;
584
+ environmentsJson: string;
585
+ } {
586
+ const start = performance.now();
587
+
588
+ const nodes = this._graph.nodes as BundleGraphNode[];
589
+ const edges: [number, number, BundleGraphEdgeType][] = [];
590
+
591
+ const edgeIterator = this._graph.getAllEdges();
592
+ let next = edgeIterator.next();
593
+ while (!next.done) {
594
+ const edge = next.value;
595
+ edges.push([edge.from, edge.to, edge.type]);
596
+ next = edgeIterator.next();
597
+ }
598
+
599
+ // Extract and deduplicate environments
600
+ const environmentMap = new Map<string, Environment>();
601
+ const extractEnvironment = (envRef: EnvironmentRef): string => {
602
+ const env = fromEnvironmentId(envRef);
603
+ const envId = env.id;
604
+ if (!environmentMap.has(envId)) {
605
+ environmentMap.set(envId, env);
606
+ }
607
+ return envId;
608
+ };
609
+
610
+ // Replace env objects with env IDs in nodes
611
+ const processedNodes = nodes.map((node) => {
612
+ const processedNode = {...node};
613
+ if (node.type === 'asset' && node.value?.env) {
614
+ processedNode.value = {
615
+ ...node.value,
616
+ env: extractEnvironment(node.value.env),
617
+ };
618
+ } else if (node.type === 'dependency' && node.value?.env) {
619
+ processedNode.value = {
620
+ ...node.value,
621
+ env: extractEnvironment(node.value.env),
622
+ };
623
+ } else if (node.type === 'bundle' && node.value?.env) {
624
+ processedNode.value = {
625
+ ...node.value,
626
+ env: extractEnvironment(node.value.env),
627
+ };
628
+ }
629
+ return processedNode;
630
+ });
631
+
632
+ // Optimize nodes by omitting null/undefined values to reduce JSON size
633
+ const optimizedNodes = processedNodes.map((node) => this._omitNulls(node));
634
+ const nodesJson = JSON.stringify(optimizedNodes);
635
+
636
+ // Serialize environments as array
637
+ const environments = Array.from(environmentMap.values());
638
+ const environmentsJson = JSON.stringify(environments);
639
+
640
+ // Convert Map to plain object for serialization
641
+ const publicIdByAssetId: Record<string, string> = {};
642
+ for (const [assetId, publicId] of this._publicIdByAssetId) {
643
+ publicIdByAssetId[assetId] = publicId;
644
+ }
645
+
646
+ const duration = performance.now() - start;
647
+ const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
648
+ const envsSizeMB = (environmentsJson.length / (1024 * 1024)).toFixed(2);
649
+ logger.verbose({
650
+ origin: '@atlaspack/core',
651
+ message: `serializeForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${envsSizeMB}MB envs (${environmentMap.size} unique), ${nodes.length} nodes, ${edges.length} edges`,
652
+ });
653
+
654
+ return {nodesJson, edges, publicIdByAssetId, environmentsJson};
655
+ }
656
+
657
+ /**
658
+ * Serialize only the given asset nodes for native incremental update.
659
+ * Same node shape and env/omit logic as serializeForNative.
660
+ */
661
+ serializeAssetNodesForNative(assetIds: Array<string>): string {
662
+ const start = performance.now();
663
+
664
+ if (assetIds.length === 0) {
665
+ return '[]';
666
+ }
667
+
668
+ const nodes: Array<BundleGraphNode> = [];
669
+ for (const assetId of assetIds) {
670
+ const node = this._graph.getNodeByContentKey(assetId);
671
+ if (node?.type !== 'asset') {
672
+ continue;
673
+ }
674
+ const processedNode = {...node};
675
+ if (node.value?.env) {
676
+ processedNode.value = {
677
+ ...node.value,
678
+ env: fromEnvironmentId(node.value.env).id,
679
+ };
680
+ }
681
+ nodes.push(processedNode);
682
+ }
683
+ const optimizedNodes = nodes.map((node) => this._omitNulls(node));
684
+ const nodesJson = JSON.stringify(optimizedNodes);
685
+
686
+ const duration = performance.now() - start;
687
+ const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
688
+
689
+ logger.verbose({
690
+ origin: '@atlaspack/core',
691
+ message: `serializeAssetNodesForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${nodes.length} nodes`,
692
+ });
693
+ return nodesJson;
694
+ }
695
+
696
+ /**
697
+ * Remove null and undefined values from an object to reduce JSON size.
698
+ * Preserves false, 0, empty strings, and arrays.
699
+ */
700
+ private _omitNulls(obj: unknown): unknown {
701
+ if (obj === null || obj === undefined) return obj;
702
+ if (typeof obj !== 'object') return obj;
703
+ if (Array.isArray(obj)) {
704
+ return obj.map((item) => this._omitNulls(item));
705
+ }
706
+
707
+ const result: Record<string, unknown> = {};
708
+ for (const [key, value] of Object.entries(obj as Record<string, unknown>)) {
709
+ if (value === null || value === undefined) {
710
+ continue;
711
+ }
712
+ if (
713
+ typeof value === 'object' &&
714
+ !Array.isArray(value) &&
715
+ Object.keys(value as object).length === 0
716
+ ) {
717
+ continue;
718
+ }
719
+ if (typeof value === 'object') {
720
+ const processed = this._omitNulls(value);
721
+ if (processed !== undefined) {
722
+ result[key] = processed;
723
+ }
724
+ } else {
725
+ result[key] = value;
726
+ }
727
+ }
728
+ return result;
729
+ }
730
+
550
731
  createBundle(
551
732
  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
- |},
733
+ | {
734
+ readonly entryAsset: Asset;
735
+ readonly bundleRoots?: Array<Asset>;
736
+ readonly target: Target;
737
+ readonly needsStableName?: boolean | null | undefined;
738
+ readonly bundleBehavior?: IBundleBehavior | null | undefined;
739
+ readonly shouldContentHash: boolean;
740
+ readonly env: EnvironmentRef;
741
+ }
742
+ | {
743
+ readonly type: string;
744
+ readonly env: EnvironmentRef;
745
+ readonly uniqueKey: string;
746
+ readonly target: Target;
747
+ readonly needsStableName?: boolean | null | undefined;
748
+ readonly bundleBehavior?: IBundleBehavior | null | undefined;
749
+ readonly isSplittable?: boolean | null | undefined;
750
+ readonly pipeline?: string | null | undefined;
751
+ readonly shouldContentHash: boolean;
752
+ },
571
753
  ): Bundle {
754
+ // @ts-expect-error TS2339
572
755
  let {entryAsset, target} = opts;
573
756
  let bundleId = hashString(
574
757
  'bundle:' +
758
+ // @ts-expect-error TS2339
575
759
  (opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) +
576
760
  fromProjectPathRelative(target.distDir) +
577
761
  (opts.bundleBehavior ?? ''),
@@ -603,19 +787,24 @@ export default class BundleGraph {
603
787
  hashReference: opts.shouldContentHash
604
788
  ? HASH_REF_PREFIX + bundleId
605
789
  : bundleId.slice(-8),
790
+ // @ts-expect-error TS2339
606
791
  type: opts.entryAsset ? opts.entryAsset.type : opts.type,
607
792
  env: opts.env,
608
793
  entryAssetIds: entryAsset ? [entryAsset.id] : [],
609
794
  mainEntryId: entryAsset?.id,
795
+ // @ts-expect-error TS2339
610
796
  pipeline: opts.entryAsset ? opts.entryAsset.pipeline : opts.pipeline,
611
797
  needsStableName: opts.needsStableName,
612
798
  bundleBehavior:
613
799
  opts.bundleBehavior != null
614
800
  ? BundleBehavior[opts.bundleBehavior]
615
801
  : null,
802
+ // @ts-expect-error TS2339
616
803
  isSplittable: opts.entryAsset
617
- ? opts.entryAsset.isBundleSplittable
618
- : opts.isSplittable,
804
+ ? // @ts-expect-error TS2339
805
+ opts.entryAsset.isBundleSplittable
806
+ : // @ts-expect-error TS2339
807
+ opts.isSplittable,
619
808
  isPlaceholder,
620
809
  target,
621
810
  name: null,
@@ -626,9 +815,11 @@ export default class BundleGraph {
626
815
 
627
816
  let bundleNodeId = this._graph.addNodeByContentKey(bundleId, bundleNode);
628
817
 
818
+ // @ts-expect-error TS2339
629
819
  if (opts.entryAsset) {
630
820
  this._graph.addEdge(
631
821
  bundleNodeId,
822
+ // @ts-expect-error TS2339
632
823
  this._graph.getNodeIdByContentKey(opts.entryAsset.id),
633
824
  );
634
825
  }
@@ -661,10 +852,13 @@ export default class BundleGraph {
661
852
  for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
662
853
  .getNodeIdsConnectedFrom(dependencyNodeId)
663
854
  .map((id) => [id, nullthrows(this._graph.getNode(id))])
664
- .filter(([, node]) => node.type === 'bundle_group')) {
855
+ // @ts-expect-error TS2769
856
+ .filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
857
+ // @ts-expect-error TS2339
665
858
  invariant(bundleGroupNode.type === 'bundle_group');
666
859
  this._graph.addEdge(
667
860
  bundleNodeId,
861
+ // @ts-expect-error TS2345
668
862
  bundleGroupNodeId,
669
863
  bundleGraphEdgeTypes.bundle,
670
864
  );
@@ -693,7 +887,7 @@ export default class BundleGraph {
693
887
  addAssetGraphToBundle(
694
888
  asset: Asset,
695
889
  bundle: Bundle,
696
- shouldSkipDependency: (Dependency) => boolean = (d) =>
890
+ shouldSkipDependency: (arg1: Dependency) => boolean = (d: Dependency) =>
697
891
  this.isDependencySkipped(d),
698
892
  ) {
699
893
  let assetNodeId = this._graph.getNodeIdByContentKey(asset.id);
@@ -726,10 +920,13 @@ export default class BundleGraph {
726
920
  for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
727
921
  .getNodeIdsConnectedFrom(nodeId)
728
922
  .map((id) => [id, nullthrows(this._graph.getNode(id))])
729
- .filter(([, node]) => node.type === 'bundle_group')) {
923
+ // @ts-expect-error TS2769
924
+ .filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
925
+ // @ts-expect-error TS2339
730
926
  invariant(bundleGroupNode.type === 'bundle_group');
731
927
  this._graph.addEdge(
732
928
  bundleNodeId,
929
+ // @ts-expect-error TS2345
733
930
  bundleGroupNodeId,
734
931
  bundleGraphEdgeTypes.bundle,
735
932
  );
@@ -769,7 +966,7 @@ export default class BundleGraph {
769
966
  addEntryToBundle(
770
967
  asset: Asset,
771
968
  bundle: Bundle,
772
- shouldSkipDependency?: (Dependency) => boolean,
969
+ shouldSkipDependency?: (arg1: Dependency) => boolean,
773
970
  ) {
774
971
  this.addAssetGraphToBundle(asset, bundle, shouldSkipDependency);
775
972
  if (!bundle.entryAssetIds.includes(asset.id)) {
@@ -836,11 +1033,18 @@ export default class BundleGraph {
836
1033
 
837
1034
  resolveAsyncDependency(
838
1035
  dependency: Dependency,
839
- bundle: ?Bundle,
840
- ): ?(
841
- | {|type: 'bundle_group', value: BundleGroup|}
842
- | {|type: 'asset', value: Asset|}
843
- ) {
1036
+ bundle?: Bundle | null,
1037
+ ):
1038
+ | {
1039
+ type: 'bundle_group';
1040
+ value: BundleGroup;
1041
+ }
1042
+ | {
1043
+ type: 'asset';
1044
+ value: Asset;
1045
+ }
1046
+ | null
1047
+ | undefined {
844
1048
  let depNodeId = this._graph.getNodeIdByContentKey(dependency.id);
845
1049
  let bundleNodeId =
846
1050
  bundle != null ? this._graph.getNodeIdByContentKey(bundle.id) : null;
@@ -899,7 +1103,10 @@ export default class BundleGraph {
899
1103
  }
900
1104
 
901
1105
  // eslint-disable-next-line no-unused-vars
902
- getReferencedBundle(dependency: Dependency, fromBundle: Bundle): ?Bundle {
1106
+ getReferencedBundle(
1107
+ dependency: Dependency,
1108
+ fromBundle: Bundle,
1109
+ ): Bundle | null | undefined {
903
1110
  let dependencyNodeId = this._graph.getNodeIdByContentKey(dependency.id);
904
1111
 
905
1112
  // Find an attached bundle via a reference edge (e.g. from createAssetReference).
@@ -931,8 +1138,12 @@ export default class BundleGraph {
931
1138
  return this.getBundlesInBundleGroup(node.value, {
932
1139
  includeInline: true,
933
1140
  }).find((b) => {
934
- let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
935
- return mainEntryId != null && node.value.entryAssetId === mainEntryId;
1141
+ if (getFeatureFlag('supportWebpackChunkName')) {
1142
+ return b.entryAssetIds.some((id) => id === node.value.entryAssetId);
1143
+ } else {
1144
+ let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
1145
+ return mainEntryId != null && node.value.entryAssetId === mainEntryId;
1146
+ }
936
1147
  });
937
1148
  }
938
1149
  }
@@ -1226,7 +1437,10 @@ export default class BundleGraph {
1226
1437
  });
1227
1438
  }
1228
1439
 
1229
- getResolvedAsset(dep: Dependency, bundle: ?Bundle): ?Asset {
1440
+ getResolvedAsset(
1441
+ dep: Dependency,
1442
+ bundle?: Bundle | null,
1443
+ ): Asset | null | undefined {
1230
1444
  let assets = this.getDependencyAssets(dep);
1231
1445
  let firstAsset = assets[0];
1232
1446
  let resolved =
@@ -1240,7 +1454,7 @@ export default class BundleGraph {
1240
1454
 
1241
1455
  // If a resolution still hasn't been found, return the first referenced asset.
1242
1456
  if (resolved == null) {
1243
- let potential = [];
1457
+ let potential: Array<Asset> = [];
1244
1458
  this._graph.traverse(
1245
1459
  (nodeId, _, traversal) => {
1246
1460
  let node = nullthrows(this._graph.getNode(nodeId));
@@ -1255,6 +1469,7 @@ export default class BundleGraph {
1255
1469
  );
1256
1470
 
1257
1471
  if (bundle) {
1472
+ // @ts-expect-error TS2322
1258
1473
  resolved = potential.find((a) => a.type === bundle.type);
1259
1474
  }
1260
1475
  resolved ||= potential[0];
@@ -1276,7 +1491,7 @@ export default class BundleGraph {
1276
1491
  bundle: Bundle,
1277
1492
  visit: GraphVisitor<Asset, TContext>,
1278
1493
  startAsset?: Asset,
1279
- ): ?TContext {
1494
+ ): TContext | null | undefined {
1280
1495
  return this.traverseBundle(
1281
1496
  bundle,
1282
1497
  mapVisitor((node) => (node.type === 'asset' ? node.value : null), visit),
@@ -1359,7 +1574,8 @@ export default class BundleGraph {
1359
1574
 
1360
1575
  if (
1361
1576
  descendant.type !== bundle.type ||
1362
- descendant.env.context !== bundle.env.context
1577
+ fromEnvironmentId(descendant.env).context !==
1578
+ fromEnvironmentId(bundle.env).context
1363
1579
  ) {
1364
1580
  actions.skipChildren();
1365
1581
  return;
@@ -1376,6 +1592,158 @@ export default class BundleGraph {
1376
1592
  });
1377
1593
  }
1378
1594
 
1595
+ // New method: Fast checks only (no caching of results)
1596
+ isAssetReferencedFastCheck(bundle: Bundle, asset: Asset): boolean | null {
1597
+ // Fast Check #1: If asset is in multiple bundles in same target, it's referenced
1598
+ let bundlesWithAsset = this.getBundlesWithAsset(asset).filter(
1599
+ (b) =>
1600
+ b.target.name === bundle.target.name &&
1601
+ b.target.distDir === bundle.target.distDir,
1602
+ );
1603
+
1604
+ if (bundlesWithAsset.length > 1) {
1605
+ return true;
1606
+ }
1607
+
1608
+ // Fast Check #2: If asset is referenced by any async/conditional dependency, it's referenced
1609
+ let assetNodeId = nullthrows(this._graph.getNodeIdByContentKey(asset.id));
1610
+
1611
+ if (
1612
+ this._graph
1613
+ .getNodeIdsConnectedTo(assetNodeId, bundleGraphEdgeTypes.references)
1614
+ .map((id) => this._graph.getNode(id))
1615
+ .some(
1616
+ (node) =>
1617
+ node?.type === 'dependency' &&
1618
+ (node.value.priority === Priority.lazy ||
1619
+ node.value.priority === Priority.conditional) &&
1620
+ node.value.specifierType !== SpecifierType.url,
1621
+ )
1622
+ ) {
1623
+ return true;
1624
+ }
1625
+
1626
+ // Fast checks failed - return null to indicate expensive computation needed
1627
+ return null;
1628
+ }
1629
+
1630
+ getReferencedAssets(bundle: Bundle): Set<Asset> {
1631
+ let referencedAssets = new Set<Asset>();
1632
+
1633
+ // Build a map of all assets in this bundle with their dependencies
1634
+ // This allows us to check all assets in a single traversal
1635
+ let assetDependenciesMap = new Map<Asset, Array<Dependency>>();
1636
+
1637
+ this.traverseAssets(bundle, (asset) => {
1638
+ // Always do fast checks (no caching)
1639
+ let fastCheckResult = this.isAssetReferencedFastCheck(bundle, asset);
1640
+
1641
+ if (fastCheckResult === true) {
1642
+ referencedAssets.add(asset);
1643
+ return;
1644
+ }
1645
+
1646
+ // Fast checks failed (fastCheckResult === null), need expensive computation
1647
+ // Check if it's actually referenced via traversal
1648
+
1649
+ // Store dependencies for later batch checking
1650
+ let dependencies = this._graph
1651
+ .getNodeIdsConnectedTo(
1652
+ nullthrows(this._graph.getNodeIdByContentKey(asset.id)),
1653
+ )
1654
+ .map((id) => nullthrows(this._graph.getNode(id)))
1655
+ .filter((node) => node.type === 'dependency')
1656
+ .map((node) => {
1657
+ invariant(node.type === 'dependency');
1658
+ return node.value;
1659
+ });
1660
+
1661
+ if (dependencies.length > 0) {
1662
+ assetDependenciesMap.set(asset, dependencies);
1663
+ }
1664
+ });
1665
+
1666
+ // If no assets need the expensive check, return early
1667
+ if (assetDependenciesMap.size === 0) {
1668
+ return referencedAssets;
1669
+ }
1670
+
1671
+ // Get the assets we need to check once
1672
+ let assetsToCheck = Array.from(assetDependenciesMap.keys());
1673
+
1674
+ // Helper function to check if all assets from assetDependenciesMap are in referencedAssets
1675
+ const allAssetsReferenced = (): boolean =>
1676
+ assetsToCheck.length <= referencedAssets.size &&
1677
+ assetsToCheck.every((asset) => referencedAssets.has(asset));
1678
+
1679
+ // Do ONE traversal to check all remaining assets
1680
+ // We can share visitedBundles across all assets because we check every asset
1681
+ // against every visited bundle, which matches the original per-asset behavior
1682
+ let siblingBundles = new Set(
1683
+ this.getBundleGroupsContainingBundle(bundle).flatMap((bundleGroup) =>
1684
+ this.getBundlesInBundleGroup(bundleGroup, {includeInline: true}),
1685
+ ),
1686
+ );
1687
+
1688
+ let visitedBundles: Set<Bundle> = new Set();
1689
+
1690
+ // Single traversal from all referencers
1691
+ for (let referencer of siblingBundles) {
1692
+ this.traverseBundles((descendant, _, actions) => {
1693
+ if (descendant.id === bundle.id) {
1694
+ return;
1695
+ }
1696
+
1697
+ if (visitedBundles.has(descendant)) {
1698
+ actions.skipChildren();
1699
+ return;
1700
+ }
1701
+
1702
+ visitedBundles.add(descendant);
1703
+
1704
+ if (
1705
+ descendant.type !== bundle.type ||
1706
+ fromEnvironmentId(descendant.env).context !==
1707
+ fromEnvironmentId(bundle.env).context
1708
+ ) {
1709
+ // Don't skip children - they might be the right type!
1710
+ return;
1711
+ }
1712
+
1713
+ // Check ALL assets at once in this descendant bundle
1714
+ for (let [asset, dependencies] of assetDependenciesMap) {
1715
+ // Skip if already marked as referenced
1716
+ if (referencedAssets.has(asset)) {
1717
+ continue;
1718
+ }
1719
+
1720
+ // Check if this descendant bundle references the asset
1721
+ if (
1722
+ !this.bundleHasAsset(descendant, asset) &&
1723
+ dependencies.some((dependency) =>
1724
+ this.bundleHasDependency(descendant, dependency),
1725
+ )
1726
+ ) {
1727
+ referencedAssets.add(asset);
1728
+ }
1729
+ }
1730
+
1731
+ // If all assets from assetDependenciesMap are now marked as referenced, we can stop early
1732
+ if (allAssetsReferenced()) {
1733
+ actions.stop();
1734
+ return;
1735
+ }
1736
+ }, referencer);
1737
+
1738
+ // If all assets from assetDependenciesMap are referenced, no need to check more sibling bundles
1739
+ if (allAssetsReferenced()) {
1740
+ break;
1741
+ }
1742
+ }
1743
+
1744
+ return referencedAssets;
1745
+ }
1746
+
1379
1747
  hasParentBundleOfType(bundle: Bundle, type: string): boolean {
1380
1748
  let parents = this.getParentBundles(bundle);
1381
1749
  return (
@@ -1400,10 +1768,11 @@ export default class BundleGraph {
1400
1768
  // If a bundle's environment is isolated, it can't access assets present
1401
1769
  // in any ancestor bundles. Don't consider any assets reachable.
1402
1770
  if (
1403
- ISOLATED_ENVS.has(bundle.env.context) ||
1771
+ ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
1404
1772
  !bundle.isSplittable ||
1405
1773
  bundle.bundleBehavior === BundleBehavior.isolated ||
1406
- bundle.bundleBehavior === BundleBehavior.inline
1774
+ bundle.bundleBehavior === BundleBehavior.inline ||
1775
+ bundle.bundleBehavior === BundleBehavior.inlineIsolated
1407
1776
  ) {
1408
1777
  return false;
1409
1778
  }
@@ -1420,6 +1789,7 @@ export default class BundleGraph {
1420
1789
  b.id !== bundle.id &&
1421
1790
  b.bundleBehavior !== BundleBehavior.isolated &&
1422
1791
  b.bundleBehavior !== BundleBehavior.inline &&
1792
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1423
1793
  this.bundleHasAsset(b, asset),
1424
1794
  )
1425
1795
  ) {
@@ -1438,7 +1808,8 @@ export default class BundleGraph {
1438
1808
  if (
1439
1809
  bundleNode.type !== 'bundle' ||
1440
1810
  bundleNode.value.bundleBehavior === BundleBehavior.isolated ||
1441
- bundleNode.value.bundleBehavior === BundleBehavior.inline
1811
+ bundleNode.value.bundleBehavior === BundleBehavior.inline ||
1812
+ bundleNode.value.bundleBehavior === BundleBehavior.inlineIsolated
1442
1813
  ) {
1443
1814
  return false;
1444
1815
  }
@@ -1454,7 +1825,8 @@ export default class BundleGraph {
1454
1825
  node.type === 'root' ||
1455
1826
  (node.type === 'bundle' &&
1456
1827
  (node.value.id === bundle.id ||
1457
- node.value.env.context !== bundle.env.context))
1828
+ fromEnvironmentId(node.value.env).context !==
1829
+ fromEnvironmentId(bundle.env).context))
1458
1830
  ) {
1459
1831
  isReachable = false;
1460
1832
  actions.stop();
@@ -1469,6 +1841,7 @@ export default class BundleGraph {
1469
1841
  b.id !== bundle.id &&
1470
1842
  b.bundleBehavior !== BundleBehavior.isolated &&
1471
1843
  b.bundleBehavior !== BundleBehavior.inline &&
1844
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1472
1845
  this.bundleHasAsset(b, asset),
1473
1846
  )
1474
1847
  ) {
@@ -1486,14 +1859,42 @@ export default class BundleGraph {
1486
1859
  }
1487
1860
 
1488
1861
  /**
1489
- * TODO: Document why this works like this & why visitor order matters
1490
- * on these use-cases.
1862
+ * Performs a depth-first traversal of all assets and dependencies contained
1863
+ * within a bundle. Only visits nodes that are directly contained in the bundle
1864
+ * (connected via a `contains` edge).
1865
+ *
1866
+ * Entry Asset Ordering:
1867
+ * The traversal guarantees that entry assets are visited in the exact order they
1868
+ * appear in `bundle.entryAssetIds`. This ordering is critical for several reasons:
1869
+ *
1870
+ * 1. **Code Execution Order in Packagers**: Packagers (ScopeHoistingPackager,
1871
+ * DevPackager) use this traversal to concatenate assets into the final bundle.
1872
+ * The traversal order determines the execution order of code in the output.
1873
+ * Entry assets must be processed in their defined order to ensure correct
1874
+ * initialization sequences.
1875
+ *
1876
+ * 2. **Runtime Injection**: Runtime assets (HMR, bundle manifests) are prepended
1877
+ * to `entryAssetIds` via `unshift()` in `applyRuntimes.ts`. By honoring the
1878
+ * array order, runtimes are guaranteed to be visited (and thus output) before
1879
+ * application entry points, ensuring the runtime infrastructure is available
1880
+ * when application code executes.
1881
+ *
1882
+ * 3. **Deterministic Builds**: Consistent traversal order ensures reproducible
1883
+ * bundle output, which is essential for caching and build verification.
1884
+ *
1885
+ * The sorting only applies at the first traversal level (direct children of the
1886
+ * start node). Subsequent levels follow standard DFS order based on the graph's
1887
+ * edge structure.
1888
+ *
1889
+ * @param bundle - The bundle to traverse
1890
+ * @param visit - Visitor callback receiving asset or dependency nodes
1891
+ * @param startAsset - Optional asset to start traversal from (defaults to bundle root)
1491
1892
  */
1492
1893
  traverseBundle<TContext>(
1493
1894
  bundle: Bundle,
1494
1895
  visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
1495
1896
  startAsset?: Asset,
1496
- ): ?TContext {
1897
+ ): TContext | null | undefined {
1497
1898
  let entries = !startAsset;
1498
1899
  let bundleNodeId = this._graph.getNodeIdByContentKey(bundle.id);
1499
1900
 
@@ -1531,7 +1932,8 @@ export default class BundleGraph {
1531
1932
 
1532
1933
  let sorted =
1533
1934
  entries && bundle.entryAssetIds.length > 0
1534
- ? children.sort(([, a], [, b]) => {
1935
+ ? // @ts-expect-error TS2345
1936
+ children.sort(([, a]: [any, any], [, b]: [any, any]) => {
1535
1937
  let aIndex = bundle.entryAssetIds.indexOf(a.id);
1536
1938
  let bIndex = bundle.entryAssetIds.indexOf(b.id);
1537
1939
 
@@ -1550,7 +1952,8 @@ export default class BundleGraph {
1550
1952
  : children;
1551
1953
 
1552
1954
  entries = false;
1553
- return sorted.map(([id]) => id);
1955
+ // @ts-expect-error TS2345
1956
+ return sorted.map(([id]: [any]) => id);
1554
1957
  },
1555
1958
  });
1556
1959
  }
@@ -1558,7 +1961,7 @@ export default class BundleGraph {
1558
1961
  traverse<TContext>(
1559
1962
  visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
1560
1963
  start?: Asset,
1561
- ): ?TContext {
1964
+ ): TContext | null | undefined {
1562
1965
  return this._graph.filteredTraverse(
1563
1966
  (nodeId) => {
1564
1967
  let node = nullthrows(this._graph.getNode(nodeId));
@@ -1574,7 +1977,7 @@ export default class BundleGraph {
1574
1977
 
1575
1978
  getChildBundles(bundle: Bundle): Array<Bundle> {
1576
1979
  let siblings = new Set(this.getReferencedBundles(bundle));
1577
- let bundles = [];
1980
+ let bundles: Array<Bundle> = [];
1578
1981
  this.traverseBundles((b, _, actions) => {
1579
1982
  if (bundle.id === b.id) {
1580
1983
  return;
@@ -1591,8 +1994,8 @@ export default class BundleGraph {
1591
1994
 
1592
1995
  traverseBundles<TContext>(
1593
1996
  visit: GraphVisitor<Bundle, TContext>,
1594
- startBundle: ?Bundle,
1595
- ): ?TContext {
1997
+ startBundle?: Bundle | null,
1998
+ ): TContext | null | undefined {
1596
1999
  return this._graph.filteredTraverse(
1597
2000
  (nodeId) => {
1598
2001
  let node = nullthrows(this._graph.getNode(nodeId));
@@ -1604,12 +2007,13 @@ export default class BundleGraph {
1604
2007
  );
1605
2008
  }
1606
2009
 
1607
- getBundles(opts?: {|includeInline: boolean|}): Array<Bundle> {
1608
- let bundles = [];
2010
+ getBundles(opts?: {includeInline: boolean}): Array<Bundle> {
2011
+ let bundles: Array<Bundle> = [];
1609
2012
  this.traverseBundles((bundle) => {
1610
2013
  if (
1611
2014
  opts?.includeInline ||
1612
- bundle.bundleBehavior !== BundleBehavior.inline
2015
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
2016
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1613
2017
  ) {
1614
2018
  bundles.push(bundle);
1615
2019
  }
@@ -1679,7 +2083,9 @@ export default class BundleGraph {
1679
2083
 
1680
2084
  getBundlesInBundleGroup(
1681
2085
  bundleGroup: BundleGroup,
1682
- opts?: {|includeInline: boolean|},
2086
+ opts?: {
2087
+ includeInline: boolean;
2088
+ },
1683
2089
  ): Array<Bundle> {
1684
2090
  let bundles: Set<Bundle> = new Set();
1685
2091
  for (let bundleNodeId of this._graph.getNodeIdsConnectedFrom(
@@ -1691,7 +2097,8 @@ export default class BundleGraph {
1691
2097
  let bundle = bundleNode.value;
1692
2098
  if (
1693
2099
  opts?.includeInline ||
1694
- bundle.bundleBehavior !== BundleBehavior.inline
2100
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
2101
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1695
2102
  ) {
1696
2103
  bundles.add(bundle);
1697
2104
  }
@@ -1708,7 +2115,10 @@ export default class BundleGraph {
1708
2115
 
1709
2116
  getReferencedBundles(
1710
2117
  bundle: Bundle,
1711
- opts?: {|recursive?: boolean, includeInline?: boolean|},
2118
+ opts?: {
2119
+ recursive?: boolean;
2120
+ includeInline?: boolean;
2121
+ },
1712
2122
  ): Array<Bundle> {
1713
2123
  let recursive = opts?.recursive ?? true;
1714
2124
  let includeInline = opts?.includeInline ?? false;
@@ -1726,7 +2136,8 @@ export default class BundleGraph {
1726
2136
 
1727
2137
  if (
1728
2138
  includeInline ||
1729
- node.value.bundleBehavior !== BundleBehavior.inline
2139
+ (node.value.bundleBehavior !== BundleBehavior.inline &&
2140
+ node.value.bundleBehavior !== BundleBehavior.inlineIsolated)
1730
2141
  ) {
1731
2142
  referencedBundles.add(node.value);
1732
2143
  }
@@ -1746,6 +2157,7 @@ export default class BundleGraph {
1746
2157
  ),
1747
2158
  });
1748
2159
 
2160
+ // @ts-expect-error TS2322
1749
2161
  return [...referencedBundles];
1750
2162
  }
1751
2163
 
@@ -1768,7 +2180,7 @@ export default class BundleGraph {
1768
2180
  });
1769
2181
  }
1770
2182
 
1771
- getAssetWithDependency(dep: Dependency): ?Asset {
2183
+ getAssetWithDependency(dep: Dependency): Asset | null | undefined {
1772
2184
  if (!this._graph.hasContentKey(dep.id)) {
1773
2185
  return null;
1774
2186
  }
@@ -1777,6 +2189,7 @@ export default class BundleGraph {
1777
2189
  let count = 0;
1778
2190
  this._graph.forEachNodeIdConnectedTo(
1779
2191
  this._graph.getNodeIdByContentKey(dep.id),
2192
+ // @ts-expect-error TS2345
1780
2193
  (node) => {
1781
2194
  res = node;
1782
2195
  count += 1;
@@ -1817,16 +2230,16 @@ export default class BundleGraph {
1817
2230
 
1818
2231
  filteredTraverse<TValue, TContext>(
1819
2232
  bundleNodeId: NodeId,
1820
- filter: (NodeId, TraversalActions) => ?TValue,
2233
+ filter: (arg1: NodeId, arg2: TraversalActions) => TValue | null | undefined,
1821
2234
  visit: GraphVisitor<TValue, TContext>,
1822
- ): ?TContext {
2235
+ ): TContext | null | undefined {
1823
2236
  return this._graph.filteredTraverse(filter, visit, bundleNodeId);
1824
2237
  }
1825
2238
 
1826
2239
  getSymbolResolution(
1827
2240
  asset: Asset,
1828
2241
  symbol: Symbol,
1829
- boundary: ?Bundle,
2242
+ boundary?: Bundle | null,
1830
2243
  ): InternalSymbolResolution {
1831
2244
  let assetOutside = boundary && !this.bundleHasAsset(boundary, asset);
1832
2245
 
@@ -1853,7 +2266,7 @@ export default class BundleGraph {
1853
2266
  }
1854
2267
  // If this is a re-export, find the original module.
1855
2268
  let symbolLookup = new Map(
1856
- [...depSymbols].map(([key, val]) => [val.local, key]),
2269
+ [...depSymbols].map(([key, val]: [any, any]) => [val.local, key]),
1857
2270
  );
1858
2271
  let depSymbol = symbolLookup.get(identifier);
1859
2272
  if (depSymbol != null) {
@@ -1971,17 +2384,20 @@ export default class BundleGraph {
1971
2384
  let result = identifier;
1972
2385
  if (skipped) {
1973
2386
  // ... and it was excluded (by symbol propagation) or deferred.
2387
+ // @ts-expect-error TS2322
1974
2388
  result = false;
1975
2389
  } else {
1976
2390
  // ... and there is no single reexport, but it might still be exported:
1977
2391
  if (found) {
1978
2392
  // Fallback to namespace access, because of a bundle boundary.
2393
+ // @ts-expect-error TS2322
1979
2394
  result = null;
1980
2395
  } else if (result === undefined) {
1981
2396
  // If not exported explicitly by the asset (= would have to be in * or a reexport-all) ...
1982
2397
  if (nonStaticDependency || asset.symbols?.has('*')) {
1983
2398
  // ... and if there are non-statically analyzable dependencies or it's a CJS asset,
1984
2399
  // fallback to namespace access.
2400
+ // @ts-expect-error TS2322
1985
2401
  result = null;
1986
2402
  }
1987
2403
  // (It shouldn't be possible for the symbol to be in a reexport-all and to end up here).
@@ -2019,13 +2435,13 @@ export default class BundleGraph {
2019
2435
 
2020
2436
  getExportedSymbols(
2021
2437
  asset: Asset,
2022
- boundary: ?Bundle,
2438
+ boundary?: Bundle | null,
2023
2439
  ): Array<InternalExportSymbolResolution> {
2024
2440
  if (!asset.symbols) {
2025
2441
  return [];
2026
2442
  }
2027
2443
 
2028
- let symbols = [];
2444
+ let symbols: Array<InternalExportSymbolResolution> = [];
2029
2445
 
2030
2446
  for (let symbol of asset.symbols.keys()) {
2031
2447
  symbols.push({
@@ -2076,9 +2492,9 @@ export default class BundleGraph {
2076
2492
  }
2077
2493
 
2078
2494
  getInlineBundles(bundle: Bundle): Array<Bundle> {
2079
- let bundles = [];
2495
+ let bundles: Array<Bundle> = [];
2080
2496
  let seen = new Set();
2081
- let addReferencedBundles = (bundle) => {
2497
+ let addReferencedBundles = (bundle: Bundle) => {
2082
2498
  if (seen.has(bundle.id)) {
2083
2499
  return;
2084
2500
  }
@@ -2089,7 +2505,10 @@ export default class BundleGraph {
2089
2505
  includeInline: true,
2090
2506
  });
2091
2507
  for (let referenced of referencedBundles) {
2092
- if (referenced.bundleBehavior === BundleBehavior.inline) {
2508
+ if (
2509
+ referenced.bundleBehavior === BundleBehavior.inline ||
2510
+ referenced.bundleBehavior === BundleBehavior.inlineIsolated
2511
+ ) {
2093
2512
  bundles.push(referenced);
2094
2513
  addReferencedBundles(referenced);
2095
2514
  }
@@ -2099,7 +2518,10 @@ export default class BundleGraph {
2099
2518
  addReferencedBundles(bundle);
2100
2519
 
2101
2520
  this.traverseBundles((childBundle, _, traversal) => {
2102
- if (childBundle.bundleBehavior === BundleBehavior.inline) {
2521
+ if (
2522
+ childBundle.bundleBehavior === BundleBehavior.inline ||
2523
+ childBundle.bundleBehavior === BundleBehavior.inlineIsolated
2524
+ ) {
2103
2525
  bundles.push(childBundle);
2104
2526
  } else if (childBundle.id !== bundle.id) {
2105
2527
  traversal.skipChildren();
@@ -2128,7 +2550,9 @@ export default class BundleGraph {
2128
2550
  hash.writeString(referencedBundle.id);
2129
2551
  }
2130
2552
 
2131
- hash.writeString(JSON.stringify(objectSortedEntriesDeep(bundle.env)));
2553
+ hash.writeString(
2554
+ JSON.stringify(objectSortedEntriesDeep(fromEnvironmentId(bundle.env))),
2555
+ );
2132
2556
  return hash.finish();
2133
2557
  }
2134
2558
 
@@ -2172,7 +2596,7 @@ export default class BundleGraph {
2172
2596
  }
2173
2597
  }
2174
2598
 
2175
- getUsedSymbolsAsset(asset: Asset): ?$ReadOnlySet<Symbol> {
2599
+ getUsedSymbolsAsset(asset: Asset): ReadonlySet<Symbol> | null | undefined {
2176
2600
  let node = this._graph.getNodeByContentKey(asset.id);
2177
2601
  invariant(node && node.type === 'asset');
2178
2602
  return node.value.symbols
@@ -2180,7 +2604,9 @@ export default class BundleGraph {
2180
2604
  : null;
2181
2605
  }
2182
2606
 
2183
- getUsedSymbolsDependency(dep: Dependency): ?$ReadOnlySet<Symbol> {
2607
+ getUsedSymbolsDependency(
2608
+ dep: Dependency,
2609
+ ): ReadonlySet<Symbol> | null | undefined {
2184
2610
  let node = this._graph.getNodeByContentKey(dep.id);
2185
2611
  invariant(node && node.type === 'dependency');
2186
2612
  return node.value.symbols
@@ -2228,6 +2654,7 @@ export default class BundleGraph {
2228
2654
  }
2229
2655
  }
2230
2656
 
2657
+ // @ts-expect-error TS2488
2231
2658
  for (let edge of other._graph.getAllEdges()) {
2232
2659
  this._graph.addEdge(
2233
2660
  nullthrows(otherGraphIdToThisNodeId.get(edge.from)),
@@ -2272,7 +2699,7 @@ export default class BundleGraph {
2272
2699
  bundleGraphEdgeTypes.bundle,
2273
2700
  );
2274
2701
 
2275
- let entries = [];
2702
+ let entries: Array<FilePath> = [];
2276
2703
  for (let bundleGroupId of entryBundleGroupIds) {
2277
2704
  let bundleGroupNode = this._graph.getNode(bundleGroupId);
2278
2705
  invariant(bundleGroupNode?.type === 'bundle_group');
@@ -2312,6 +2739,7 @@ export default class BundleGraph {
2312
2739
  ),
2313
2740
  });
2314
2741
 
2742
+ // @ts-expect-error TS2322
2315
2743
  return [...referencedBundles];
2316
2744
  }
2317
2745
  }