@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
@@ -51,7 +51,15 @@ function _featureFlags() {
51
51
  };
52
52
  return data;
53
53
  }
54
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
54
+ function _logger() {
55
+ const data = _interopRequireDefault(require("@atlaspack/logger"));
56
+ _logger = function () {
57
+ return data;
58
+ };
59
+ return data;
60
+ }
61
+ var _EnvironmentManager = require("./EnvironmentManager");
62
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
55
63
  const bundleGraphEdgeTypes = exports.bundleGraphEdgeTypes = {
56
64
  // A lack of an edge type indicates to follow the edge while traversing
57
65
  // the bundle's contents, e.g. `bundle.traverse()` during packaging.
@@ -77,7 +85,7 @@ const bundleGraphEdgeTypes = exports.bundleGraphEdgeTypes = {
77
85
  internal_async: 5,
78
86
  // This type is used to mark an edge between a bundle and a conditional bundle.
79
87
  // This allows efficient discovery of conditional bundles in packaging
80
- conditional: 5
88
+ conditional: 6
81
89
  };
82
90
  function makeReadOnlySet(set) {
83
91
  return new Proxy(set, {
@@ -85,7 +93,7 @@ function makeReadOnlySet(set) {
85
93
  if (property === 'delete' || property === 'add' || property === 'clear') {
86
94
  return undefined;
87
95
  } else {
88
- // $FlowFixMe[incompatible-type]
96
+ // @ts-expect-error TS7053
89
97
  let value = target[property];
90
98
  return typeof value === 'function' ? value.bind(target) : value;
91
99
  }
@@ -167,7 +175,7 @@ class BundleGraph {
167
175
  // code need to be mapped to the "real" dependencies, so we need access to a map of placeholders
168
176
  // to dependencies
169
177
  const dep = node.value;
170
- // $FlowFixMe[incompatible-type] Meta is untyped
178
+ // @ts-expect-error TS2322
171
179
  const placeholder = (_dep$meta = dep.meta) === null || _dep$meta === void 0 ? void 0 : _dep$meta.placeholder;
172
180
  if (placeholder != null) {
173
181
  placeholderToDependency.set(placeholder, dep);
@@ -182,7 +190,6 @@ class BundleGraph {
182
190
  if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && node.type === 'asset') {
183
191
  const asset = node.value;
184
192
  if (Array.isArray(asset.meta.conditions)) {
185
- // $FlowFixMe
186
193
  for (const condition of asset.meta.conditions) {
187
194
  // Resolve the placeholders that were attached to the asset in JSTransformer to dependencies,
188
195
  // as well as create a public id for the condition.
@@ -207,7 +214,7 @@ class BundleGraph {
207
214
  }
208
215
  }
209
216
  }
210
- if (node.type === 'dependency' && node.value.symbols != null && node.value.env.shouldScopeHoist &&
217
+ if (node.type === 'dependency' && node.value.symbols != null && (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).shouldScopeHoist &&
211
218
  // Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
212
219
  isProduction) {
213
220
  let nodeValueSymbols = node.value.symbols;
@@ -250,8 +257,8 @@ class BundleGraph {
250
257
  // Don't retarget because this cannot be resolved without also changing the asset symbols
251
258
  // (and the asset content itself).
252
259
  [...targets].every(([, t]) => new Set([...t.values()]).size === t.size)) {
253
- var _nodeValueSymbols$get;
254
- let isReexportAll = ((_nodeValueSymbols$get = nodeValueSymbols.get('*')) === null || _nodeValueSymbols$get === void 0 ? void 0 : _nodeValueSymbols$get.local) === '*';
260
+ var _nodeValueSymbols$get, _node$value$meta;
261
+ let isReexportAll = ((_nodeValueSymbols$get = nodeValueSymbols.get('*')) === null || _nodeValueSymbols$get === void 0 ? void 0 : _nodeValueSymbols$get.local) === '*' || ((_node$value$meta = node.value.meta) === null || _node$value$meta === void 0 ? void 0 : _node$value$meta.hasExportStar);
255
262
  let reexportAllLoc = isReexportAll ? (0, _nullthrows().default)(nodeValueSymbols.get('*')).loc : undefined;
256
263
 
257
264
  // TODO adjust sourceAssetIdNode.value.dependencies ?
@@ -263,9 +270,13 @@ class BundleGraph {
263
270
  ...node,
264
271
  value: {
265
272
  ...node.value,
266
- symbols: new Map([...nodeValueSymbols].filter(([k]) => externalSymbols.has(k)))
273
+ symbols: new Map(
274
+ // @ts-expect-error TS2769
275
+ [...nodeValueSymbols].filter(([k]) => externalSymbols.has(k)))
267
276
  },
268
- usedSymbolsUp: new Map([...node.usedSymbolsUp].filter(([k]) => externalSymbols.has(k))),
277
+ usedSymbolsUp: new Map(
278
+ // @ts-expect-error TS2769
279
+ [...node.usedSymbolsUp].filter(([k]) => externalSymbols.has(k))),
269
280
  usedSymbolsDown: new Set(),
270
281
  excluded: externalSymbols.size === 0
271
282
  })
@@ -294,8 +305,13 @@ class BundleGraph {
294
305
  loc: reexportAllLoc
295
306
  });
296
307
  if (node.value.sourceAssetId != null) {
297
- let sourceAssetId = (0, _nullthrows().default)(assetGraphNodeIdToBundleGraphNodeId.get(assetGraph.getNodeIdByContentKey(node.value.sourceAssetId)));
298
- let sourceAsset = (0, _nullthrows().default)(graph.getNode(sourceAssetId));
308
+ let sourceAssetId;
309
+ if ((0, _featureFlags().getFeatureFlag)('sourceAssetIdBundleGraphFix')) {
310
+ [sourceAssetId] = assetGraph.getNodeIdsConnectedTo(nodeId);
311
+ } else {
312
+ sourceAssetId = assetGraph.getNodeIdByContentKey(node.value.sourceAssetId);
313
+ }
314
+ let sourceAsset = (0, _nullthrows().default)(graph.getNode((0, _nullthrows().default)(assetGraphNodeIdToBundleGraphNodeId.get(sourceAssetId))));
299
315
  (0, _assert().default)(sourceAsset.type === 'asset');
300
316
  let sourceAssetSymbols = sourceAsset.value.symbols;
301
317
  if (sourceAssetSymbols) {
@@ -312,7 +328,9 @@ class BundleGraph {
312
328
  }
313
329
  }
314
330
  }
315
- let usedSymbolsUp = new Map([...node.usedSymbolsUp].filter(([k]) => target.has(k) || k === '*').map(([k, v]) => [target.get(k) ?? k, v]));
331
+ let usedSymbolsUp = new Map([...node.usedSymbolsUp]
332
+ // @ts-expect-error TS2769
333
+ .filter(([k]) => target.has(k) || k === '*').map(([k, v]) => [target.get(k) ?? k, v]));
316
334
  return {
317
335
  asset,
318
336
  dep: graph.addNodeByContentKey(newNodeId, {
@@ -363,6 +381,8 @@ class BundleGraph {
363
381
  }
364
382
  }
365
383
  walk((0, _nullthrows().default)(assetGraph.rootNodeId));
384
+
385
+ // @ts-expect-error TS2488
366
386
  for (let edge of assetGraph.getAllEdges()) {
367
387
  var _dependencies$get, _assetGroupIds$get;
368
388
  if (assetGroupIds.has(edge.from)) {
@@ -415,12 +435,163 @@ class BundleGraph {
415
435
  conditions: serialized.conditions
416
436
  });
417
437
  }
438
+
439
+ /**
440
+ * Serialize the bundle graph for efficient transfer to native Rust code.
441
+ * Returns a JSON string of nodes, an array of edges, and a map of asset IDs to public IDs.
442
+ */
443
+ serializeForNative() {
444
+ const start = performance.now();
445
+ const nodes = this._graph.nodes;
446
+ const edges = [];
447
+ const edgeIterator = this._graph.getAllEdges();
448
+ let next = edgeIterator.next();
449
+ while (!next.done) {
450
+ const edge = next.value;
451
+ edges.push([edge.from, edge.to, edge.type]);
452
+ next = edgeIterator.next();
453
+ }
454
+
455
+ // Extract and deduplicate environments
456
+ const environmentMap = new Map();
457
+ const extractEnvironment = envRef => {
458
+ const env = (0, _EnvironmentManager.fromEnvironmentId)(envRef);
459
+ const envId = env.id;
460
+ if (!environmentMap.has(envId)) {
461
+ environmentMap.set(envId, env);
462
+ }
463
+ return envId;
464
+ };
465
+
466
+ // Replace env objects with env IDs in nodes
467
+ const processedNodes = nodes.map(node => {
468
+ var _node$value, _node$value2, _node$value3;
469
+ const processedNode = {
470
+ ...node
471
+ };
472
+ if (node.type === 'asset' && (_node$value = node.value) !== null && _node$value !== void 0 && _node$value.env) {
473
+ processedNode.value = {
474
+ ...node.value,
475
+ env: extractEnvironment(node.value.env)
476
+ };
477
+ } else if (node.type === 'dependency' && (_node$value2 = node.value) !== null && _node$value2 !== void 0 && _node$value2.env) {
478
+ processedNode.value = {
479
+ ...node.value,
480
+ env: extractEnvironment(node.value.env)
481
+ };
482
+ } else if (node.type === 'bundle' && (_node$value3 = node.value) !== null && _node$value3 !== void 0 && _node$value3.env) {
483
+ processedNode.value = {
484
+ ...node.value,
485
+ env: extractEnvironment(node.value.env)
486
+ };
487
+ }
488
+ return processedNode;
489
+ });
490
+
491
+ // Optimize nodes by omitting null/undefined values to reduce JSON size
492
+ const optimizedNodes = processedNodes.map(node => this._omitNulls(node));
493
+ const nodesJson = JSON.stringify(optimizedNodes);
494
+
495
+ // Serialize environments as array
496
+ const environments = Array.from(environmentMap.values());
497
+ const environmentsJson = JSON.stringify(environments);
498
+
499
+ // Convert Map to plain object for serialization
500
+ const publicIdByAssetId = {};
501
+ for (const [assetId, publicId] of this._publicIdByAssetId) {
502
+ publicIdByAssetId[assetId] = publicId;
503
+ }
504
+ const duration = performance.now() - start;
505
+ const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
506
+ const envsSizeMB = (environmentsJson.length / (1024 * 1024)).toFixed(2);
507
+ _logger().default.verbose({
508
+ origin: '@atlaspack/core',
509
+ message: `serializeForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${envsSizeMB}MB envs (${environmentMap.size} unique), ${nodes.length} nodes, ${edges.length} edges`
510
+ });
511
+ return {
512
+ nodesJson,
513
+ edges,
514
+ publicIdByAssetId,
515
+ environmentsJson
516
+ };
517
+ }
518
+
519
+ /**
520
+ * Serialize only the given asset nodes for native incremental update.
521
+ * Same node shape and env/omit logic as serializeForNative.
522
+ */
523
+ serializeAssetNodesForNative(assetIds) {
524
+ const start = performance.now();
525
+ if (assetIds.length === 0) {
526
+ return '[]';
527
+ }
528
+ const nodes = [];
529
+ for (const assetId of assetIds) {
530
+ var _node$value4;
531
+ const node = this._graph.getNodeByContentKey(assetId);
532
+ if ((node === null || node === void 0 ? void 0 : node.type) !== 'asset') {
533
+ continue;
534
+ }
535
+ const processedNode = {
536
+ ...node
537
+ };
538
+ if ((_node$value4 = node.value) !== null && _node$value4 !== void 0 && _node$value4.env) {
539
+ processedNode.value = {
540
+ ...node.value,
541
+ env: (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).id
542
+ };
543
+ }
544
+ nodes.push(processedNode);
545
+ }
546
+ const optimizedNodes = nodes.map(node => this._omitNulls(node));
547
+ const nodesJson = JSON.stringify(optimizedNodes);
548
+ const duration = performance.now() - start;
549
+ const nodesSizeMB = (nodesJson.length / (1024 * 1024)).toFixed(2);
550
+ _logger().default.verbose({
551
+ origin: '@atlaspack/core',
552
+ message: `serializeAssetNodesForNative: ${duration.toFixed(1)}ms, ${nodesSizeMB}MB nodes, ${nodes.length} nodes`
553
+ });
554
+ return nodesJson;
555
+ }
556
+
557
+ /**
558
+ * Remove null and undefined values from an object to reduce JSON size.
559
+ * Preserves false, 0, empty strings, and arrays.
560
+ */
561
+ _omitNulls(obj) {
562
+ if (obj === null || obj === undefined) return obj;
563
+ if (typeof obj !== 'object') return obj;
564
+ if (Array.isArray(obj)) {
565
+ return obj.map(item => this._omitNulls(item));
566
+ }
567
+ const result = {};
568
+ for (const [key, value] of Object.entries(obj)) {
569
+ if (value === null || value === undefined) {
570
+ continue;
571
+ }
572
+ if (typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 0) {
573
+ continue;
574
+ }
575
+ if (typeof value === 'object') {
576
+ const processed = this._omitNulls(value);
577
+ if (processed !== undefined) {
578
+ result[key] = processed;
579
+ }
580
+ } else {
581
+ result[key] = value;
582
+ }
583
+ }
584
+ return result;
585
+ }
418
586
  createBundle(opts) {
587
+ // @ts-expect-error TS2339
419
588
  let {
420
589
  entryAsset,
421
590
  target
422
591
  } = opts;
423
- let bundleId = (0, _rust().hashString)('bundle:' + (opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) + (0, _projectPath.fromProjectPathRelative)(target.distDir) + (opts.bundleBehavior ?? ''));
592
+ let bundleId = (0, _rust().hashString)('bundle:' + (
593
+ // @ts-expect-error TS2339
594
+ opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) + (0, _projectPath.fromProjectPathRelative)(target.distDir) + (opts.bundleBehavior ?? ''));
424
595
  let existing = this._graph.getNodeByContentKey(bundleId);
425
596
  if (existing != null) {
426
597
  (0, _assert().default)(existing.type === 'bundle');
@@ -440,14 +611,21 @@ class BundleGraph {
440
611
  value: {
441
612
  id: bundleId,
442
613
  hashReference: opts.shouldContentHash ? _constants.HASH_REF_PREFIX + bundleId : bundleId.slice(-8),
614
+ // @ts-expect-error TS2339
443
615
  type: opts.entryAsset ? opts.entryAsset.type : opts.type,
444
616
  env: opts.env,
445
617
  entryAssetIds: entryAsset ? [entryAsset.id] : [],
446
618
  mainEntryId: entryAsset === null || entryAsset === void 0 ? void 0 : entryAsset.id,
619
+ // @ts-expect-error TS2339
447
620
  pipeline: opts.entryAsset ? opts.entryAsset.pipeline : opts.pipeline,
448
621
  needsStableName: opts.needsStableName,
449
622
  bundleBehavior: opts.bundleBehavior != null ? _types.BundleBehavior[opts.bundleBehavior] : null,
450
- isSplittable: opts.entryAsset ? opts.entryAsset.isBundleSplittable : opts.isSplittable,
623
+ // @ts-expect-error TS2339
624
+ isSplittable: opts.entryAsset ?
625
+ // @ts-expect-error TS2339
626
+ opts.entryAsset.isBundleSplittable :
627
+ // @ts-expect-error TS2339
628
+ opts.isSplittable,
451
629
  isPlaceholder,
452
630
  target,
453
631
  name: null,
@@ -456,8 +634,12 @@ class BundleGraph {
456
634
  }
457
635
  };
458
636
  let bundleNodeId = this._graph.addNodeByContentKey(bundleId, bundleNode);
637
+
638
+ // @ts-expect-error TS2339
459
639
  if (opts.entryAsset) {
460
- this._graph.addEdge(bundleNodeId, this._graph.getNodeIdByContentKey(opts.entryAsset.id));
640
+ this._graph.addEdge(bundleNodeId,
641
+ // @ts-expect-error TS2339
642
+ this._graph.getNodeIdByContentKey(opts.entryAsset.id));
461
643
  }
462
644
  _assert().default;
463
645
  return bundleNode.value;
@@ -470,9 +652,14 @@ class BundleGraph {
470
652
  for (let dependency of dependencies) {
471
653
  let dependencyNodeId = this._graph.getNodeIdByContentKey(dependency.id);
472
654
  this._graph.addEdge(bundleNodeId, dependencyNodeId, bundleGraphEdgeTypes.contains);
473
- for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(dependencyNodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))]).filter(([, node]) => node.type === 'bundle_group')) {
655
+ for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(dependencyNodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))])
656
+ // @ts-expect-error TS2769
657
+ .filter(([, node]) => node.type === 'bundle_group')) {
658
+ // @ts-expect-error TS2339
474
659
  (0, _assert().default)(bundleGroupNode.type === 'bundle_group');
475
- this._graph.addEdge(bundleNodeId, bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
660
+ this._graph.addEdge(bundleNodeId,
661
+ // @ts-expect-error TS2345
662
+ bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
476
663
  }
477
664
  // If the dependency references a target bundle, add a reference edge from
478
665
  // the source bundle to the dependency for easy traversal.
@@ -503,9 +690,14 @@ class BundleGraph {
503
690
  this._graph.addEdge(bundleNodeId, nodeId, bundleGraphEdgeTypes.contains);
504
691
  }
505
692
  if (node.type === 'dependency') {
506
- for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(nodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))]).filter(([, node]) => node.type === 'bundle_group')) {
693
+ for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(nodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))])
694
+ // @ts-expect-error TS2769
695
+ .filter(([, node]) => node.type === 'bundle_group')) {
696
+ // @ts-expect-error TS2339
507
697
  (0, _assert().default)(bundleGroupNode.type === 'bundle_group');
508
- this._graph.addEdge(bundleNodeId, bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
698
+ this._graph.addEdge(bundleNodeId,
699
+ // @ts-expect-error TS2345
700
+ bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
509
701
  }
510
702
 
511
703
  // If the dependency references a target bundle, add a reference edge from
@@ -616,8 +808,12 @@ class BundleGraph {
616
808
  return this.getBundlesInBundleGroup(node.value, {
617
809
  includeInline: true
618
810
  }).find(b => {
619
- let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
620
- return mainEntryId != null && node.value.entryAssetId === mainEntryId;
811
+ if ((0, _featureFlags().getFeatureFlag)('supportWebpackChunkName')) {
812
+ return b.entryAssetIds.some(id => id === node.value.entryAssetId);
813
+ } else {
814
+ let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
815
+ return mainEntryId != null && node.value.entryAssetId === mainEntryId;
816
+ }
621
817
  });
622
818
  }
623
819
  }
@@ -805,6 +1001,7 @@ class BundleGraph {
805
1001
  }
806
1002
  }, this._graph.getNodeIdByContentKey(dep.id), bundleGraphEdgeTypes.references);
807
1003
  if (bundle) {
1004
+ // @ts-expect-error TS2322
808
1005
  resolved = potential.find(a => a.type === bundle.type);
809
1006
  }
810
1007
  resolved ||= potential[0];
@@ -859,18 +1056,126 @@ class BundleGraph {
859
1056
  return;
860
1057
  }
861
1058
  visitedBundles.add(descendant);
862
- if (descendant.type !== bundle.type || descendant.env.context !== bundle.env.context) {
1059
+ if (descendant.type !== bundle.type || (0, _EnvironmentManager.fromEnvironmentId)(descendant.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) {
863
1060
  actions.skipChildren();
864
1061
  return;
865
1062
  }
866
1063
  if (bundleHasReference(descendant)) {
867
1064
  isReferenced = true;
868
1065
  actions.stop();
1066
+ return;
869
1067
  }
870
1068
  }, referencer);
871
1069
  return isReferenced;
872
1070
  });
873
1071
  }
1072
+
1073
+ // New method: Fast checks only (no caching of results)
1074
+ isAssetReferencedFastCheck(bundle, asset) {
1075
+ // Fast Check #1: If asset is in multiple bundles in same target, it's referenced
1076
+ let bundlesWithAsset = this.getBundlesWithAsset(asset).filter(b => b.target.name === bundle.target.name && b.target.distDir === bundle.target.distDir);
1077
+ if (bundlesWithAsset.length > 1) {
1078
+ return true;
1079
+ }
1080
+
1081
+ // Fast Check #2: If asset is referenced by any async/conditional dependency, it's referenced
1082
+ let assetNodeId = (0, _nullthrows().default)(this._graph.getNodeIdByContentKey(asset.id));
1083
+ if (this._graph.getNodeIdsConnectedTo(assetNodeId, bundleGraphEdgeTypes.references).map(id => this._graph.getNode(id)).some(node => (node === null || node === void 0 ? void 0 : node.type) === 'dependency' && (node.value.priority === _types.Priority.lazy || node.value.priority === _types.Priority.conditional) && node.value.specifierType !== _types.SpecifierType.url)) {
1084
+ return true;
1085
+ }
1086
+
1087
+ // Fast checks failed - return null to indicate expensive computation needed
1088
+ return null;
1089
+ }
1090
+ getReferencedAssets(bundle) {
1091
+ let referencedAssets = new Set();
1092
+
1093
+ // Build a map of all assets in this bundle with their dependencies
1094
+ // This allows us to check all assets in a single traversal
1095
+ let assetDependenciesMap = new Map();
1096
+ this.traverseAssets(bundle, asset => {
1097
+ // Always do fast checks (no caching)
1098
+ let fastCheckResult = this.isAssetReferencedFastCheck(bundle, asset);
1099
+ if (fastCheckResult === true) {
1100
+ referencedAssets.add(asset);
1101
+ return;
1102
+ }
1103
+
1104
+ // Fast checks failed (fastCheckResult === null), need expensive computation
1105
+ // Check if it's actually referenced via traversal
1106
+
1107
+ // Store dependencies for later batch checking
1108
+ let dependencies = this._graph.getNodeIdsConnectedTo((0, _nullthrows().default)(this._graph.getNodeIdByContentKey(asset.id))).map(id => (0, _nullthrows().default)(this._graph.getNode(id))).filter(node => node.type === 'dependency').map(node => {
1109
+ (0, _assert().default)(node.type === 'dependency');
1110
+ return node.value;
1111
+ });
1112
+ if (dependencies.length > 0) {
1113
+ assetDependenciesMap.set(asset, dependencies);
1114
+ }
1115
+ });
1116
+
1117
+ // If no assets need the expensive check, return early
1118
+ if (assetDependenciesMap.size === 0) {
1119
+ return referencedAssets;
1120
+ }
1121
+
1122
+ // Get the assets we need to check once
1123
+ let assetsToCheck = Array.from(assetDependenciesMap.keys());
1124
+
1125
+ // Helper function to check if all assets from assetDependenciesMap are in referencedAssets
1126
+ const allAssetsReferenced = () => assetsToCheck.length <= referencedAssets.size && assetsToCheck.every(asset => referencedAssets.has(asset));
1127
+
1128
+ // Do ONE traversal to check all remaining assets
1129
+ // We can share visitedBundles across all assets because we check every asset
1130
+ // against every visited bundle, which matches the original per-asset behavior
1131
+ let siblingBundles = new Set(this.getBundleGroupsContainingBundle(bundle).flatMap(bundleGroup => this.getBundlesInBundleGroup(bundleGroup, {
1132
+ includeInline: true
1133
+ })));
1134
+ let visitedBundles = new Set();
1135
+
1136
+ // Single traversal from all referencers
1137
+ for (let referencer of siblingBundles) {
1138
+ this.traverseBundles((descendant, _, actions) => {
1139
+ if (descendant.id === bundle.id) {
1140
+ return;
1141
+ }
1142
+ if (visitedBundles.has(descendant)) {
1143
+ actions.skipChildren();
1144
+ return;
1145
+ }
1146
+ visitedBundles.add(descendant);
1147
+ if (descendant.type !== bundle.type || (0, _EnvironmentManager.fromEnvironmentId)(descendant.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) {
1148
+ // Don't skip children - they might be the right type!
1149
+ return;
1150
+ }
1151
+
1152
+ // Check ALL assets at once in this descendant bundle
1153
+ for (let [asset, dependencies] of assetDependenciesMap) {
1154
+ // Skip if already marked as referenced
1155
+ if (referencedAssets.has(asset)) {
1156
+ continue;
1157
+ }
1158
+
1159
+ // Check if this descendant bundle references the asset
1160
+ if (!this.bundleHasAsset(descendant, asset) && dependencies.some(dependency => this.bundleHasDependency(descendant, dependency))) {
1161
+ referencedAssets.add(asset);
1162
+ }
1163
+ }
1164
+
1165
+ // If all assets from assetDependenciesMap are now marked as referenced, we can stop early
1166
+ if (allAssetsReferenced()) {
1167
+ actions.stop();
1168
+ return;
1169
+ }
1170
+ }, referencer);
1171
+
1172
+ // If all assets from assetDependenciesMap are referenced, no need to check more sibling bundles
1173
+ if (allAssetsReferenced()) {
1174
+ break;
1175
+ }
1176
+ }
1177
+ return referencedAssets;
1178
+ }
874
1179
  hasParentBundleOfType(bundle, type) {
875
1180
  let parents = this.getParentBundles(bundle);
876
1181
  return parents.length > 0 && parents.every(parent => parent.type === type);
@@ -887,7 +1192,7 @@ class BundleGraph {
887
1192
  isAssetReachableFromBundle(asset, bundle) {
888
1193
  // If a bundle's environment is isolated, it can't access assets present
889
1194
  // in any ancestor bundles. Don't consider any assets reachable.
890
- if (_Environment.ISOLATED_ENVS.has(bundle.env.context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline) {
1195
+ if (_Environment.ISOLATED_ENVS.has((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline || bundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
891
1196
  return false;
892
1197
  }
893
1198
 
@@ -897,7 +1202,7 @@ class BundleGraph {
897
1202
  return bundleGroups.every(bundleGroup => {
898
1203
  // If the asset is in any sibling bundles of the original bundle, it is reachable.
899
1204
  let bundles = this.getBundlesInBundleGroup(bundleGroup);
900
- if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
1205
+ if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
901
1206
  return true;
902
1207
  }
903
1208
 
@@ -907,7 +1212,7 @@ class BundleGraph {
907
1212
  // Check that every parent bundle has a bundle group in its ancestry that contains the asset.
908
1213
  return parentBundleNodes.every(bundleNodeId => {
909
1214
  let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
910
- if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline) {
1215
+ if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline || bundleNode.value.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
911
1216
  return false;
912
1217
  }
913
1218
  let isReachable = true;
@@ -915,15 +1220,16 @@ class BundleGraph {
915
1220
  let node = (0, _nullthrows().default)(this._graph.getNode(nodeId));
916
1221
  // If we've reached the root or a context change without
917
1222
  // finding this asset in the ancestry, it is not reachable.
918
- if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || node.value.env.context !== bundle.env.context)) {
1223
+ if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context)) {
919
1224
  isReachable = false;
920
1225
  actions.stop();
921
1226
  return;
922
1227
  }
923
1228
  if (node.type === 'bundle_group') {
924
1229
  let childBundles = this.getBundlesInBundleGroup(node.value);
925
- if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
1230
+ if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
926
1231
  actions.skipChildren();
1232
+ return;
927
1233
  }
928
1234
  }
929
1235
  }, [bundleGraphEdgeTypes.references, bundleGraphEdgeTypes.bundle]);
@@ -933,8 +1239,36 @@ class BundleGraph {
933
1239
  }
934
1240
 
935
1241
  /**
936
- * TODO: Document why this works like this & why visitor order matters
937
- * on these use-cases.
1242
+ * Performs a depth-first traversal of all assets and dependencies contained
1243
+ * within a bundle. Only visits nodes that are directly contained in the bundle
1244
+ * (connected via a `contains` edge).
1245
+ *
1246
+ * Entry Asset Ordering:
1247
+ * The traversal guarantees that entry assets are visited in the exact order they
1248
+ * appear in `bundle.entryAssetIds`. This ordering is critical for several reasons:
1249
+ *
1250
+ * 1. **Code Execution Order in Packagers**: Packagers (ScopeHoistingPackager,
1251
+ * DevPackager) use this traversal to concatenate assets into the final bundle.
1252
+ * The traversal order determines the execution order of code in the output.
1253
+ * Entry assets must be processed in their defined order to ensure correct
1254
+ * initialization sequences.
1255
+ *
1256
+ * 2. **Runtime Injection**: Runtime assets (HMR, bundle manifests) are prepended
1257
+ * to `entryAssetIds` via `unshift()` in `applyRuntimes.ts`. By honoring the
1258
+ * array order, runtimes are guaranteed to be visited (and thus output) before
1259
+ * application entry points, ensuring the runtime infrastructure is available
1260
+ * when application code executes.
1261
+ *
1262
+ * 3. **Deterministic Builds**: Consistent traversal order ensures reproducible
1263
+ * bundle output, which is essential for caching and build verification.
1264
+ *
1265
+ * The sorting only applies at the first traversal level (direct children of the
1266
+ * start node). Subsequent levels follow standard DFS order based on the graph's
1267
+ * edge structure.
1268
+ *
1269
+ * @param bundle - The bundle to traverse
1270
+ * @param visit - Visitor callback receiving asset or dependency nodes
1271
+ * @param startAsset - Optional asset to start traversal from (defaults to bundle root)
938
1272
  */
939
1273
  traverseBundle(bundle, visit, startAsset) {
940
1274
  let entries = !startAsset;
@@ -958,7 +1292,9 @@ class BundleGraph {
958
1292
  startNodeId: startAsset ? this._graph.getNodeIdByContentKey(startAsset.id) : bundleNodeId,
959
1293
  getChildren: nodeId => {
960
1294
  let children = this._graph.getNodeIdsConnectedFrom(nodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))]);
961
- let sorted = entries && bundle.entryAssetIds.length > 0 ? children.sort(([, a], [, b]) => {
1295
+ let sorted = entries && bundle.entryAssetIds.length > 0 ?
1296
+ // @ts-expect-error TS2345
1297
+ children.sort(([, a], [, b]) => {
962
1298
  let aIndex = bundle.entryAssetIds.indexOf(a.id);
963
1299
  let bIndex = bundle.entryAssetIds.indexOf(b.id);
964
1300
  if (aIndex === bIndex) {
@@ -973,6 +1309,7 @@ class BundleGraph {
973
1309
  return aIndex - bIndex;
974
1310
  }) : children;
975
1311
  entries = false;
1312
+ // @ts-expect-error TS2345
976
1313
  return sorted.map(([id]) => id);
977
1314
  }
978
1315
  });
@@ -1010,7 +1347,7 @@ class BundleGraph {
1010
1347
  getBundles(opts) {
1011
1348
  let bundles = [];
1012
1349
  this.traverseBundles(bundle => {
1013
- if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
1350
+ if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1014
1351
  bundles.push(bundle);
1015
1352
  }
1016
1353
  });
@@ -1061,7 +1398,7 @@ class BundleGraph {
1061
1398
  let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
1062
1399
  (0, _assert().default)(bundleNode.type === 'bundle');
1063
1400
  let bundle = bundleNode.value;
1064
- if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
1401
+ if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1065
1402
  bundles.add(bundle);
1066
1403
  }
1067
1404
  for (let referencedBundle of this.getReferencedBundles(bundle, {
@@ -1085,7 +1422,7 @@ class BundleGraph {
1085
1422
  if (node.value.id === bundle.id) {
1086
1423
  return;
1087
1424
  }
1088
- if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline) {
1425
+ if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline && node.value.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1089
1426
  referencedBundles.add(node.value);
1090
1427
  }
1091
1428
  if (!recursive) {
@@ -1099,6 +1436,8 @@ class BundleGraph {
1099
1436
  // TODO: Should this be the case?
1100
1437
  this._graph.getNodeIdsConnectedFrom(nodeId, bundleGraphEdgeTypes.references)
1101
1438
  });
1439
+
1440
+ // @ts-expect-error TS2322
1102
1441
  return [...referencedBundles];
1103
1442
  }
1104
1443
  getIncomingDependencies(asset) {
@@ -1118,7 +1457,9 @@ class BundleGraph {
1118
1457
  }
1119
1458
  let res = null;
1120
1459
  let count = 0;
1121
- this._graph.forEachNodeIdConnectedTo(this._graph.getNodeIdByContentKey(dep.id), node => {
1460
+ this._graph.forEachNodeIdConnectedTo(this._graph.getNodeIdByContentKey(dep.id),
1461
+ // @ts-expect-error TS2345
1462
+ node => {
1122
1463
  res = node;
1123
1464
  count += 1;
1124
1465
  if (count > 1) {
@@ -1162,7 +1503,7 @@ class BundleGraph {
1162
1503
  let deps = this.getDependencies(asset).reverse();
1163
1504
  let potentialResults = [];
1164
1505
  for (let dep of deps) {
1165
- var _depSymbols$get;
1506
+ var _depSymbols$get, _dep$meta2;
1166
1507
  let depSymbols = dep.symbols;
1167
1508
  if (!depSymbols) {
1168
1509
  nonStaticDependency = true;
@@ -1214,7 +1555,7 @@ class BundleGraph {
1214
1555
  // If this module exports wildcards, resolve the original module.
1215
1556
  // Default exports are excluded from wildcard exports.
1216
1557
  // Wildcard reexports are never listed in the reexporting asset's symbols.
1217
- if (identifier == null && ((_depSymbols$get = depSymbols.get('*')) === null || _depSymbols$get === void 0 ? void 0 : _depSymbols$get.local) === '*' && symbol !== 'default') {
1558
+ if (identifier == null && (((_depSymbols$get = depSymbols.get('*')) === null || _depSymbols$get === void 0 ? void 0 : _depSymbols$get.local) === '*' || (_dep$meta2 = dep.meta) !== null && _dep$meta2 !== void 0 && _dep$meta2.hasExportStar) && symbol !== 'default') {
1218
1559
  let resolved = this.getResolvedAsset(dep, boundary);
1219
1560
  if (!resolved) {
1220
1561
  continue;
@@ -1282,11 +1623,13 @@ class BundleGraph {
1282
1623
  let result = identifier;
1283
1624
  if (skipped) {
1284
1625
  // ... and it was excluded (by symbol propagation) or deferred.
1626
+ // @ts-expect-error TS2322
1285
1627
  result = false;
1286
1628
  } else {
1287
1629
  // ... and there is no single reexport, but it might still be exported:
1288
1630
  if (found) {
1289
1631
  // Fallback to namespace access, because of a bundle boundary.
1632
+ // @ts-expect-error TS2322
1290
1633
  result = null;
1291
1634
  } else if (result === undefined) {
1292
1635
  var _asset$symbols5;
@@ -1294,13 +1637,13 @@ class BundleGraph {
1294
1637
  if (nonStaticDependency || (_asset$symbols5 = asset.symbols) !== null && _asset$symbols5 !== void 0 && _asset$symbols5.has('*')) {
1295
1638
  // ... and if there are non-statically analyzable dependencies or it's a CJS asset,
1296
1639
  // fallback to namespace access.
1640
+ // @ts-expect-error TS2322
1297
1641
  result = null;
1298
1642
  }
1299
1643
  // (It shouldn't be possible for the symbol to be in a reexport-all and to end up here).
1300
1644
  // Otherwise return undefined to report that the symbol wasn't found.
1301
1645
  }
1302
1646
  }
1303
-
1304
1647
  return {
1305
1648
  asset,
1306
1649
  exportSymbol: symbol,
@@ -1338,10 +1681,10 @@ class BundleGraph {
1338
1681
  }
1339
1682
  let deps = this.getDependencies(asset);
1340
1683
  for (let dep of deps) {
1341
- var _depSymbols$get2;
1684
+ var _depSymbols$get2, _dep$meta3;
1342
1685
  let depSymbols = dep.symbols;
1343
1686
  if (!depSymbols) continue;
1344
- if (((_depSymbols$get2 = depSymbols.get('*')) === null || _depSymbols$get2 === void 0 ? void 0 : _depSymbols$get2.local) === '*') {
1687
+ if (((_depSymbols$get2 = depSymbols.get('*')) === null || _depSymbols$get2 === void 0 ? void 0 : _depSymbols$get2.local) === '*' || (_dep$meta3 = dep.meta) !== null && _dep$meta3 !== void 0 && _dep$meta3.hasExportStar) {
1345
1688
  let resolved = this.getResolvedAsset(dep, boundary);
1346
1689
  if (!resolved) continue;
1347
1690
  let exported = this.getExportedSymbols(resolved, boundary).filter(s => s.exportSymbol !== 'default').map(s => s.exportSymbol !== '*' ? {
@@ -1381,7 +1724,7 @@ class BundleGraph {
1381
1724
  includeInline: true
1382
1725
  });
1383
1726
  for (let referenced of referencedBundles) {
1384
- if (referenced.bundleBehavior === _types.BundleBehavior.inline) {
1727
+ if (referenced.bundleBehavior === _types.BundleBehavior.inline || referenced.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
1385
1728
  bundles.push(referenced);
1386
1729
  addReferencedBundles(referenced);
1387
1730
  }
@@ -1389,7 +1732,7 @@ class BundleGraph {
1389
1732
  };
1390
1733
  addReferencedBundles(bundle);
1391
1734
  this.traverseBundles((childBundle, _, traversal) => {
1392
- if (childBundle.bundleBehavior === _types.BundleBehavior.inline) {
1735
+ if (childBundle.bundleBehavior === _types.BundleBehavior.inline || childBundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
1393
1736
  bundles.push(childBundle);
1394
1737
  } else if (childBundle.id !== bundle.id) {
1395
1738
  traversal.skipChildren();
@@ -1410,7 +1753,7 @@ class BundleGraph {
1410
1753
  for (let referencedBundle of this.getReferencedBundles(bundle)) {
1411
1754
  hash.writeString(referencedBundle.id);
1412
1755
  }
1413
- hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)(bundle.env)));
1756
+ hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)((0, _EnvironmentManager.fromEnvironmentId)(bundle.env))));
1414
1757
  return hash.finish();
1415
1758
  }
1416
1759
  getBundleGraphHash() {
@@ -1469,6 +1812,8 @@ class BundleGraph {
1469
1812
  otherGraphIdToThisNodeId.set(otherNodeId, updateNodeId);
1470
1813
  }
1471
1814
  }
1815
+
1816
+ // @ts-expect-error TS2488
1472
1817
  for (let edge of other._graph.getAllEdges()) {
1473
1818
  this._graph.addEdge((0, _nullthrows().default)(otherGraphIdToThisNodeId.get(edge.from)), (0, _nullthrows().default)(otherGraphIdToThisNodeId.get(edge.to)), edge.type);
1474
1819
  }
@@ -1521,6 +1866,8 @@ class BundleGraph {
1521
1866
  startNodeId: this._graph.getNodeIdByContentKey(bundle.id),
1522
1867
  getChildren: nodeId => this._graph.getNodeIdsConnectedFrom(nodeId, bundleGraphEdgeTypes.conditional)
1523
1868
  });
1869
+
1870
+ // @ts-expect-error TS2322
1524
1871
  return [...referencedBundles];
1525
1872
  }
1526
1873
  }