@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
@@ -20,47 +20,62 @@ function _diagnostic() {
20
20
  return data;
21
21
  }
22
22
  function _logger() {
23
- const data = require("@atlaspack/logger");
23
+ const data = _interopRequireWildcard(require("@atlaspack/logger"));
24
24
  _logger = function () {
25
25
  return data;
26
26
  };
27
27
  return data;
28
28
  }
29
- var _AssetGraph = _interopRequireWildcard(require("../AssetGraph"));
29
+ function _featureFlags() {
30
+ const data = require("@atlaspack/feature-flags");
31
+ _featureFlags = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
36
+ var _AssetGraph = _interopRequireDefault(require("../AssetGraph"));
37
+ var _ReporterRunner = require("../ReporterRunner");
30
38
  var _RequestTracker = require("../RequestTracker");
31
39
  var _SymbolPropagation = require("../SymbolPropagation");
32
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
33
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
34
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
40
+ var _EnvironmentManager = require("../EnvironmentManager");
41
+ var _Environment = require("../Environment");
42
+ var _dumpGraphToGraphViz = _interopRequireDefault(require("../dumpGraphToGraphViz"));
43
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
44
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
35
45
  function createAssetGraphRequestRust(rustAtlaspack) {
36
46
  return input => ({
37
47
  type: _RequestTracker.requestTypes.asset_graph_request,
38
48
  id: input.name,
39
- run: async input => {
40
- let options = input.options;
41
- let serializedAssetGraph = await rustAtlaspack.buildAssetGraph();
42
- serializedAssetGraph.nodes = serializedAssetGraph.nodes.map(node => JSON.parse(node));
49
+ run: async runInput => {
50
+ let options = runInput.options;
43
51
  let {
44
- assetGraph,
45
- changedAssets
46
- } = (0, _logger().instrument)('atlaspack_v3_getAssetGraph', () => getAssetGraph(serializedAssetGraph));
47
- let changedAssetsPropagation = new Set(changedAssets.keys());
48
- let errors = (0, _SymbolPropagation.propagateSymbols)({
49
- options,
50
- assetGraph,
51
- changedAssetsPropagation,
52
- assetGroupsWithRemovedParents: new Set(),
53
- previousErrors: new Map() //this.previousSymbolPropagationErrors,
52
+ assetGraphPromise,
53
+ commitPromise
54
+ } = await rustAtlaspack.buildAssetGraph(eventJson => {
55
+ let event = JSON.parse(eventJson);
56
+ (0, _ReporterRunner.report)(event);
54
57
  });
55
-
56
- if (errors.size > 0) {
57
- // Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
58
- // determining which failing export is the root cause is nontrivial (because of circular dependencies).
58
+ let [serializedAssetGraph, assetGraphError] = await assetGraphPromise;
59
+ if (assetGraphError) {
59
60
  throw new (_diagnostic().default)({
60
- diagnostic: [...errors.values()][0]
61
+ diagnostic: assetGraphError
61
62
  });
62
63
  }
63
- return {
64
+
65
+ // Don't reuse a previous asset graph result if Rust didn't have one too
66
+ let prevResult = null;
67
+ if (serializedAssetGraph.hadPreviousGraph) {
68
+ prevResult = await runInput.api.getPreviousResult();
69
+ }
70
+ let {
71
+ assetGraph,
72
+ changedAssets
73
+ } = (0, _logger().instrument)('atlaspack_v3_getAssetGraph', () => {
74
+ var _prevResult;
75
+ return getAssetGraph(serializedAssetGraph, (_prevResult = prevResult) === null || _prevResult === void 0 ? void 0 : _prevResult.assetGraph);
76
+ });
77
+ let changedAssetsPropagation = new Set(changedAssets.keys());
78
+ let result = {
64
79
  assetGraph,
65
80
  assetRequests: [],
66
81
  assetGroupsWithRemovedParents: new Set(),
@@ -68,19 +83,126 @@ function createAssetGraphRequestRust(rustAtlaspack) {
68
83
  changedAssetsPropagation,
69
84
  previousSymbolPropagationErrors: undefined
70
85
  };
86
+
87
+ // When v3AssetGraphSyncImprovements is enabled, wrap downstream steps
88
+ // in try/catch and store the result even on error. This prevents Rust/JS
89
+ // divergence when symbol propagation or commit_assets fails.
90
+ let storeResultOnError = (0, _featureFlags().getFeatureFlag)('v3AssetGraphSyncImprovements');
91
+ try {
92
+ // Skip symbol propagation for runtime assets - they have pre-computed symbol data
93
+ if (input.skipSymbolProp) {
94
+ _logger().default.verbose({
95
+ origin: '@atlaspack/core',
96
+ message: 'Skipping symbol propagation for runtime asset graph'
97
+ });
98
+ } else {
99
+ let errors = (0, _SymbolPropagation.propagateSymbols)({
100
+ options,
101
+ assetGraph,
102
+ changedAssetsPropagation,
103
+ assetGroupsWithRemovedParents: new Set(),
104
+ previousErrors: new Map() //this.previousSymbolPropagationErrors,
105
+ });
106
+ if (errors.size > 0) {
107
+ // Just throw the first error. Since errors can bubble (e.g. reexporting a reexported symbol also fails),
108
+ // determining which failing export is the root cause is nontrivial (because of circular dependencies).
109
+ throw new (_diagnostic().default)({
110
+ diagnostic: [...errors.values()][0]
111
+ });
112
+ }
113
+ }
114
+ await (0, _dumpGraphToGraphViz.default)(assetGraph, 'AssetGraphV3');
115
+ let [_commitResult, commitError] = await commitPromise;
116
+ if (commitError) {
117
+ throw new (_diagnostic().default)({
118
+ diagnostic: {
119
+ message: 'Error committing asset graph in Rust: ' + commitError.message
120
+ }
121
+ });
122
+ }
123
+ await runInput.api.storeResult(result);
124
+ runInput.api.invalidateOnBuild();
125
+ } catch (e) {
126
+ if (storeResultOnError) {
127
+ // Store the graph even on error to prevent Rust/JS divergence.
128
+ // The graph from getAssetGraph is structurally correct — only
129
+ // downstream processing (symbols, commit) failed.
130
+ await runInput.api.storeResult(result);
131
+ runInput.api.invalidateOnBuild();
132
+ }
133
+ throw e;
134
+ }
135
+ return result;
71
136
  },
72
137
  input
73
138
  });
74
139
  }
140
+ function getAssetGraph(serializedGraph, prevAssetGraph) {
141
+ let graph;
142
+ let reuseEdges = false;
143
+ let clonePrevGraph = (0, _featureFlags().getFeatureFlag)('v3AssetGraphSyncImprovements');
144
+ if (prevAssetGraph && serializedGraph.safeToSkipBundling) {
145
+ if (clonePrevGraph) {
146
+ graph = new _AssetGraph.default({
147
+ _contentKeyToNodeId: new Map(prevAssetGraph._contentKeyToNodeId),
148
+ _nodeIdToContentKey: new Map(prevAssetGraph._nodeIdToContentKey),
149
+ nodes: [...prevAssetGraph.nodes],
150
+ rootNodeId: prevAssetGraph.rootNodeId,
151
+ adjacencyList: prevAssetGraph.adjacencyList
152
+ });
153
+ } else {
154
+ graph = new _AssetGraph.default({
155
+ _contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
156
+ _nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
157
+ nodes: prevAssetGraph.nodes,
158
+ rootNodeId: prevAssetGraph.rootNodeId,
159
+ adjacencyList: prevAssetGraph.adjacencyList
160
+ });
161
+ }
162
+ reuseEdges = true;
163
+ } else if (prevAssetGraph && (serializedGraph.updates.length > 0 || serializedGraph.nodes.length > 0)) {
164
+ if (clonePrevGraph) {
165
+ graph = new _AssetGraph.default({
166
+ _contentKeyToNodeId: new Map(prevAssetGraph._contentKeyToNodeId),
167
+ _nodeIdToContentKey: new Map(prevAssetGraph._nodeIdToContentKey),
168
+ nodes: [...prevAssetGraph.nodes],
169
+ initialCapacity: serializedGraph.edges.length,
170
+ // Accomodate the root node
171
+ initialNodeCapacity: prevAssetGraph.nodes.length + 1,
172
+ rootNodeId: prevAssetGraph.rootNodeId
173
+ });
174
+ } else {
175
+ graph = new _AssetGraph.default({
176
+ _contentKeyToNodeId: prevAssetGraph._contentKeyToNodeId,
177
+ _nodeIdToContentKey: prevAssetGraph._nodeIdToContentKey,
178
+ nodes: prevAssetGraph.nodes,
179
+ initialCapacity: serializedGraph.edges.length,
180
+ // Accomodate the root node
181
+ initialNodeCapacity: prevAssetGraph.nodes.length + 1,
182
+ rootNodeId: prevAssetGraph.rootNodeId
183
+ });
184
+ }
185
+ graph.safeToIncrementallyBundle = false;
186
+ } else {
187
+ graph = new _AssetGraph.default({
188
+ _contentKeyToNodeId: new Map(),
189
+ _nodeIdToContentKey: new Map(),
190
+ initialCapacity: serializedGraph.edges.length,
191
+ // Accomodate the root node
192
+ initialNodeCapacity: serializedGraph.nodes.length + 1
193
+ });
194
+ let rootNodeId = graph.addNodeByContentKey('@@root', {
195
+ id: '@@root',
196
+ type: 'root',
197
+ value: null
198
+ });
199
+ graph.setRootNodeId(rootNodeId);
200
+ graph.safeToIncrementallyBundle = false;
201
+ }
202
+ (0, _assert().default)(graph, 'Asset graph not initialized');
203
+ (0, _assert().default)(graph.rootNodeId != null, 'Asset graph has no root node');
75
204
 
76
- // $FlowFixMe
77
- function getAssetGraph(serializedGraph) {
78
- let graph = new _AssetGraph.default({
79
- _contentKeyToNodeId: new Map(),
80
- _nodeIdToContentKey: new Map(),
81
- initialCapacity: serializedGraph.edges.length
82
- });
83
- graph.safeToIncrementallyBundle = false;
205
+ // @ts-expect-error TS7031
84
206
  function mapSymbols({
85
207
  exported,
86
208
  ...symbol
@@ -88,19 +210,16 @@ function getAssetGraph(serializedGraph) {
88
210
  let jsSymbol = {
89
211
  local: symbol.local ?? undefined,
90
212
  loc: symbol.loc ?? undefined,
91
- meta: undefined,
92
- isWeak: symbol.isWeak
213
+ isWeak: symbol.isWeak,
214
+ meta: {
215
+ isEsm: symbol.isEsmExport,
216
+ isStaticBindingSafe: symbol.isStaticBindingSafe
217
+ }
93
218
  };
94
219
  if (symbol.exported) {
95
- // $FlowFixMe
220
+ // @ts-expect-error TS2339
96
221
  jsSymbol.exported = symbol.exported;
97
222
  }
98
- if (symbol.isEsmExport) {
99
- // $FlowFixMe
100
- jsSymbol.meta = {
101
- isEsm: true
102
- };
103
- }
104
223
  return [exported, jsSymbol];
105
224
  }
106
225
 
@@ -112,20 +231,121 @@ function getAssetGraph(serializedGraph) {
112
231
  let envKey = [env.context, env.engines.atlaspack, env.engines.browsers, env.engines.electron, env.engines.node, env.includeNodeModules, env.isLibrary, env.outputFormat, env.shouldScopeHoist, env.shouldOptimize, env.sourceType].join(':');
113
232
  let envId = envs.get(envKey);
114
233
  if (envId == null) {
115
- envId = envs.size;
234
+ envId = (0, _Environment.getEnvironmentHash)(env);
116
235
  envs.set(envKey, envId);
117
236
  }
118
237
  return envId;
119
238
  };
120
- for (let node of serializedGraph.nodes) {
121
- if (node.type === 'root') {
122
- let index = graph.addNodeByContentKey('@@root', {
123
- id: '@@root',
124
- type: 'root',
125
- value: null
126
- });
127
- graph.setRootNodeId(index);
128
- } else if (node.type === 'entry') {
239
+ function describeNode(node) {
240
+ const base = {
241
+ type: node.type,
242
+ id: node.id
243
+ };
244
+ if (node.type === 'asset') {
245
+ return {
246
+ ...base,
247
+ filePath: node.value.filePath,
248
+ fileType: node.value.type,
249
+ pipeline: node.value.pipeline
250
+ };
251
+ } else if (node.type === 'dependency') {
252
+ return {
253
+ ...base,
254
+ specifier: node.value.specifier,
255
+ specifierType: node.value.specifierType,
256
+ sourceAssetId: node.value.sourceAssetId,
257
+ sourcePath: node.value.sourcePath
258
+ };
259
+ }
260
+ return base;
261
+ }
262
+ function buildDivergenceDiagnostics(divergenceType, newNode, existingNode, index) {
263
+ return {
264
+ contentKey: newNode.id,
265
+ divergenceType,
266
+ newNode: describeNode(newNode),
267
+ existingNode: existingNode ? describeNode(existingNode) : null,
268
+ iterationIndex: index,
269
+ totalSerializedNodes: nodesCount,
270
+ newNodesCount: serializedGraph.nodes.length,
271
+ updatesCount: serializedGraph.updates.length,
272
+ edgesCount: serializedGraph.edges.length,
273
+ hadPreviousGraph: !!prevAssetGraph,
274
+ safeToSkipBundling: serializedGraph.safeToSkipBundling,
275
+ graphNodeCount: graph._contentKeyToNodeId.size
276
+ };
277
+ }
278
+ function updateNode(newNode, isUpdateNode, index) {
279
+ let healDivergence = (0, _featureFlags().getFeatureFlag)('v3AssetGraphSyncImprovements');
280
+ if (isUpdateNode) {
281
+ let existingNode = graph.getNodeByContentKey(newNode.id);
282
+ if (healDivergence) {
283
+ if (existingNode) {
284
+ (0, _assert().default)(existingNode.type === newNode.type);
285
+ Object.assign(existingNode, newNode);
286
+ } else {
287
+ // Rust sent an update for a node JS doesn't have.
288
+ // This means JS's graph is stale. Add the node as new instead.
289
+ // This handles the "undefined == true" error class.
290
+ let diagnostics = buildDivergenceDiagnostics('update_node_not_found', newNode, existingNode, index);
291
+ _logger().default.warn({
292
+ origin: '@atlaspack/core',
293
+ message: `Rust/JS asset graph divergence healed: update node not found, ` + `adding as new. contentKey=${newNode.id} type=${newNode.type} iterationIndex=${index}`,
294
+ meta: {
295
+ trackableEvent: 'asset_graph_divergence_healed',
296
+ ...diagnostics
297
+ }
298
+ });
299
+ graph.addNodeByContentKey(newNode.id, newNode);
300
+ }
301
+ } else {
302
+ (0, _assert().default)(existingNode && existingNode.type === newNode.type);
303
+ Object.assign(existingNode, newNode);
304
+ }
305
+ } else {
306
+ if (healDivergence) {
307
+ if (graph.hasContentKey(newNode.id)) {
308
+ // Rust sent a "new" node that JS already has.
309
+ // This means JS's graph has nodes that Rust considers new.
310
+ // Treat as an update instead of throwing.
311
+ // This handles the "Graph already has content key" error class.
312
+ let existingNode = graph.getNodeByContentKey(newNode.id);
313
+ let diagnostics = buildDivergenceDiagnostics('new_node_already_exists', newNode, existingNode, index);
314
+ _logger().default.warn({
315
+ origin: '@atlaspack/core',
316
+ message: `Rust/JS asset graph divergence healed: new node already exists, ` + `treating as update. contentKey=${newNode.id} type=${newNode.type} iterationIndex=${index}`,
317
+ meta: {
318
+ trackableEvent: 'asset_graph_divergence_healed',
319
+ ...diagnostics
320
+ }
321
+ });
322
+ if (existingNode) {
323
+ Object.assign(existingNode, newNode);
324
+ }
325
+ } else {
326
+ graph.addNodeByContentKey(newNode.id, newNode);
327
+ }
328
+ } else {
329
+ try {
330
+ graph.addNodeByContentKey(newNode.id, newNode);
331
+ } catch (e) {
332
+ if (e instanceof Error && e.message.includes('already has content key')) {
333
+ let existingNode = graph.getNodeByContentKey(newNode.id);
334
+ let diagnostics = buildDivergenceDiagnostics('new_node_already_exists', newNode, existingNode, index);
335
+ throw new Error(`Graph already has content key '${newNode.id}'. Diagnostics: ${JSON.stringify(diagnostics, null, 2)}`);
336
+ }
337
+ throw e;
338
+ }
339
+ }
340
+ }
341
+ }
342
+ let nodeTypeSwitchoverIndex = serializedGraph.nodes.length;
343
+ let nodesCount = serializedGraph.nodes.length + serializedGraph.updates.length;
344
+ for (let index = 0; index < nodesCount; index++) {
345
+ let isUpdateNode = index >= nodeTypeSwitchoverIndex;
346
+ let node = isUpdateNode ? serializedGraph.updates[index - nodeTypeSwitchoverIndex] : serializedGraph.nodes[index];
347
+ node = JSON.parse(node);
348
+ if (node.type === 'entry') {
129
349
  let id = 'entry:' + ++entry;
130
350
  graph.addNodeByContentKey(id, {
131
351
  id: id,
@@ -137,8 +357,11 @@ function getAssetGraph(serializedGraph) {
137
357
  let id = asset.id;
138
358
  asset.committed = true;
139
359
  asset.contentKey = id;
140
- asset.env.id = getEnvId(asset.env);
360
+ asset.env.id = (0, _featureFlags().getFeatureFlag)('environmentDeduplication') ?
361
+ // TODO: Rust can do this and avoid copying a significant amount of data over
362
+ (0, _Environment.getEnvironmentHash)(asset.env) : getEnvId(asset.env);
141
363
  asset.mapKey = `map:${asset.id}`;
364
+ asset.env = (0, _EnvironmentManager.toEnvironmentRef)(asset.env);
142
365
 
143
366
  // This is populated later when we map the edges between assets and dependencies
144
367
  asset.dependencies = new Map();
@@ -150,66 +373,75 @@ function getAssetGraph(serializedGraph) {
150
373
  asset.symbols = new Map(asset.symbols.map(mapSymbols));
151
374
  }
152
375
  changedAssets.set(id, asset);
153
- graph.addNodeByContentKey(id, {
376
+ let assetNode = {
154
377
  id,
155
378
  type: 'asset',
156
379
  usedSymbols: new Set(),
157
380
  usedSymbolsDownDirty: true,
158
381
  usedSymbolsUpDirty: true,
159
382
  value: asset
160
- });
383
+ };
384
+ updateNode(assetNode, isUpdateNode, index);
161
385
  } else if (node.type === 'dependency') {
162
- let id = node.value.id;
163
- let dependency = node.value.dependency;
386
+ let {
387
+ dependency,
388
+ id
389
+ } = node.value;
164
390
  dependency.id = id;
165
- dependency.env.id = getEnvId(dependency.env);
391
+ dependency.env.id = (0, _featureFlags().getFeatureFlag)('environmentDeduplication') ?
392
+ // TODO: Rust can do this and avoid copying a significant amount of data over
393
+ (0, _Environment.getEnvironmentHash)(dependency.env) : getEnvId(dependency.env);
394
+ dependency.env = (0, _EnvironmentManager.toEnvironmentRef)(dependency.env);
166
395
  if (dependency.symbols != null) {
167
396
  var _dependency$symbols;
168
397
  dependency.symbols = new Map((_dependency$symbols = dependency.symbols) === null || _dependency$symbols === void 0 ? void 0 : _dependency$symbols.map(mapSymbols));
169
398
  }
170
399
  let usedSymbolsDown = new Set();
171
400
  let usedSymbolsUp = new Map();
401
+ if (node.used_symbols_up) {
402
+ for (let usedSymbol of node.used_symbols_up) {
403
+ // Transform Rust UsedSymbol { symbol: Symbol, asset: string, resolved_symbol: string }
404
+ // to JS format { symbol: string, asset: string } where symbol is the resolved name
405
+ const exportedName = usedSymbol.symbol.exported;
406
+ usedSymbolsUp.set(exportedName, {
407
+ asset: usedSymbol.asset,
408
+ symbol: usedSymbol.resolved_symbol ?? exportedName
409
+ });
410
+ }
411
+ }
172
412
  if (dependency.isEntry && dependency.isLibrary) {
173
413
  usedSymbolsDown.add('*');
174
414
  usedSymbolsUp.set('*', undefined);
175
415
  }
176
- graph.addNodeByContentKey(id, {
416
+ let depNode = {
177
417
  id,
178
418
  type: 'dependency',
179
419
  deferred: false,
180
420
  excluded: false,
181
421
  hasDeferred: node.has_deferred,
422
+ // @ts-expect-error TS2322
182
423
  usedSymbolsDown,
183
424
  usedSymbolsDownDirty: true,
184
425
  usedSymbolsUp,
185
426
  usedSymbolsUpDirtyDown: true,
186
427
  usedSymbolsUpDirtyUp: true,
187
428
  value: dependency
188
- });
429
+ };
430
+ updateNode(depNode, isUpdateNode, index);
189
431
  }
190
432
  }
191
- for (let i = 0; i < serializedGraph.edges.length; i += 2) {
192
- let from = serializedGraph.edges[i];
193
- let to = serializedGraph.edges[i + 1];
194
- let fromNode = graph.getNode(from);
195
- let toNode = graph.getNode(to);
196
- if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type) === 'dependency') {
197
- (0, _assert().default)((toNode === null || toNode === void 0 ? void 0 : toNode.type) === 'asset');
198
-
199
- // For backwards compatibility, create asset group node if needed.
200
- let assetGroupNode = (0, _AssetGraph.nodeFromAssetGroup)({
201
- filePath: toNode.value.filePath,
202
- env: fromNode.value.env,
203
- pipeline: toNode.value.pipeline,
204
- sideEffects: Boolean(toNode.value.sideEffects)
205
- });
206
- let index = graph.addNodeByContentKeyIfNeeded(assetGroupNode.id, assetGroupNode);
207
- graph.addEdge(from, index);
208
- graph.addEdge(index, to);
209
- } else if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type) === 'asset' && (toNode === null || toNode === void 0 ? void 0 : toNode.type) === 'dependency') {
210
- fromNode.value.dependencies.set(toNode.value.id, toNode.value);
211
- graph.addEdge(from, to);
212
- } else {
433
+ if (!reuseEdges) {
434
+ for (let i = 0; i < serializedGraph.edges.length; i += 2) {
435
+ let from = serializedGraph.edges[i];
436
+ let to = serializedGraph.edges[i + 1];
437
+ let fromNode = graph.getNode(from);
438
+ let toNode = graph.getNode(to);
439
+ if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type) === 'dependency') {
440
+ (0, _assert().default)((toNode === null || toNode === void 0 ? void 0 : toNode.type) === 'asset');
441
+ }
442
+ if ((fromNode === null || fromNode === void 0 ? void 0 : fromNode.type) === 'asset' && (toNode === null || toNode === void 0 ? void 0 : toNode.type) === 'dependency') {
443
+ fromNode.value.dependencies.set(toNode.value.id, toNode.value);
444
+ }
213
445
  graph.addEdge(from, to);
214
446
  }
215
447
  }
@@ -31,7 +31,8 @@ var _ConfigRequest = require("./ConfigRequest");
31
31
  var _projectPath = require("../projectPath");
32
32
  var _ReporterRunner = require("../ReporterRunner");
33
33
  var _RequestTracker = require("../RequestTracker");
34
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
+ var _EnvironmentManager = require("../EnvironmentManager");
35
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
35
36
  function createAssetRequest(input) {
36
37
  return {
37
38
  type: _RequestTracker.requestTypes.asset_request,
@@ -42,8 +43,10 @@ function createAssetRequest(input) {
42
43
  }
43
44
  const type = 'asset_request';
44
45
  function getId(input) {
45
- return (0, _rust().hashString)(type + (0, _projectPath.fromProjectPathRelative)(input.filePath) + input.env.id + String(input.isSource) + String(input.sideEffects) + (input.code ?? '') + ':' + (input.pipeline ?? '') + ':' + (input.query ?? ''));
46
+ return (0, _rust().hashString)(type + (0, _projectPath.fromProjectPathRelative)(input.filePath) + (0, _EnvironmentManager.toEnvironmentId)(input.env) + String(input.isSource) + String(input.sideEffects) + (input.code ?? '') + ':' + (input.pipeline ?? '') + ':' + (input.query ?? ''));
46
47
  }
48
+
49
+ // @ts-expect-error TS7031
47
50
  async function run({
48
51
  input,
49
52
  api,
@@ -64,17 +67,31 @@ async function run({
64
67
  } = input;
65
68
  let {
66
69
  cachePath
67
- } = (0, _nullthrows().default)(await api.runRequest((0, _AtlaspackConfigRequest.default)()));
68
- let previousDevDepRequests = new Map(await Promise.all(api.getSubRequests().filter(req => req.requestType === _RequestTracker.requestTypes.dev_dep_request).map(async req => [req.id, (0, _nullthrows().default)(await api.getRequestResult(req.id))])));
70
+ } = (0, _nullthrows().default)(
71
+ // @ts-expect-error TS2347
72
+ await api.runRequest((0, _AtlaspackConfigRequest.default)()));
73
+ let previousDevDepRequests = new Map(await Promise.all(api.getSubRequests()
74
+ // @ts-expect-error TS7006
75
+ .filter(req => req.requestType === _RequestTracker.requestTypes.dev_dep_request)
76
+ // @ts-expect-error TS7006
77
+ .map(async req => [req.id,
78
+ // @ts-expect-error TS2347
79
+ (0, _nullthrows().default)(await api.getRequestResult(req.id))])));
69
80
  let request = {
70
81
  ...rest,
71
82
  invalidateReason,
72
- devDeps: new Map([...previousDevDepRequests.entries()].filter(([id]) => api.canSkipSubrequest(id)).map(([, req]) => [`${req.specifier}:${(0, _projectPath.fromProjectPathRelative)(req.resolveFrom)}`, req.hash])),
73
- invalidDevDeps: await Promise.all([...previousDevDepRequests.entries()].filter(([id]) => !api.canSkipSubrequest(id)).flatMap(([, req]) => {
83
+ devDeps: new Map([...previousDevDepRequests.entries()]
84
+ // @ts-expect-error TS2769
85
+ .filter(([id]) => api.canSkipSubrequest(id)).map(([, req]) => [`${req.specifier}:${(0, _projectPath.fromProjectPathRelative)(req.resolveFrom)}`, req.hash])),
86
+ invalidDevDeps: await Promise.all([...previousDevDepRequests.entries()]
87
+ // @ts-expect-error TS2769
88
+ .filter(([id]) => !api.canSkipSubrequest(id)).flatMap(([, req]) => {
74
89
  return [{
75
90
  specifier: req.specifier,
76
91
  resolveFrom: req.resolveFrom
77
- }, ...(req.additionalInvalidations ?? []).map(i => ({
92
+ },
93
+ // @ts-expect-error TS7006
94
+ ...(req.additionalInvalidations ?? []).map(i => ({
78
95
  specifier: i.specifier,
79
96
  resolveFrom: i.resolveFrom
80
97
  }))];
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = createAtlaspackBuildRequest;
7
7
  var _BundleGraphRequest = _interopRequireDefault(require("./BundleGraphRequest"));
8
+ var _BundleGraphRequestRust = _interopRequireDefault(require("./BundleGraphRequestRust"));
8
9
  var _WriteBundlesRequest = _interopRequireDefault(require("./WriteBundlesRequest"));
9
10
  var _utils = require("../utils");
10
11
  var _dumpGraphToGraphViz = _interopRequireDefault(require("../dumpGraphToGraphViz"));
@@ -21,7 +22,22 @@ function _profiler() {
21
22
  return data;
22
23
  }
23
24
  var _RequestTracker = require("../RequestTracker");
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
+ function _featureFlags() {
26
+ const data = require("@atlaspack/feature-flags");
27
+ _featureFlags = function () {
28
+ return data;
29
+ };
30
+ return data;
31
+ }
32
+ var _EnvironmentManager = require("../EnvironmentManager");
33
+ function _logger() {
34
+ const data = require("@atlaspack/logger");
35
+ _logger = function () {
36
+ return data;
37
+ };
38
+ return data;
39
+ }
40
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
25
41
  function createAtlaspackBuildRequest(input) {
26
42
  return {
27
43
  type: _RequestTracker.requestTypes.atlaspack_build_request,
@@ -41,7 +57,11 @@ async function run({
41
57
  requestedAssetIds,
42
58
  signal
43
59
  } = input;
44
- let bundleGraphRequest = (0, _BundleGraphRequest.default)({
60
+ let bundleGraphRequest = (0, _featureFlags().getFeatureFlag)('nativeBundling') && rustAtlaspack ? (0, _BundleGraphRequestRust.default)({
61
+ optionsRef,
62
+ requestedAssetIds,
63
+ signal
64
+ }) : (0, _BundleGraphRequest.default)({
45
65
  optionsRef,
46
66
  requestedAssetIds,
47
67
  signal
@@ -49,31 +69,57 @@ async function run({
49
69
  let {
50
70
  bundleGraph,
51
71
  changedAssets,
52
- assetRequests
72
+ assetRequests,
73
+ didIncrementallyBundle
53
74
  } = await api.runRequest(bundleGraphRequest, {
54
75
  force: Boolean(rustAtlaspack) || options.shouldBuildLazily && requestedAssetIds.size > 0
55
76
  });
77
+ if ((0, _featureFlags().getFeatureFlag)('nativePackager') && (0, _featureFlags().getFeatureFlag)('nativePackagerSSRDev') && rustAtlaspack) {
78
+ let hasSupportedTarget = false;
79
+ bundleGraph.traverseBundles((bundle, ctx, actions) => {
80
+ if ((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context === 'tesseract' && bundle.type === 'js') {
81
+ hasSupportedTarget = true;
82
+ actions.stop();
83
+ }
84
+ });
85
+ if (hasSupportedTarget) {
86
+ if (didIncrementallyBundle) {
87
+ const changedAssetIds = Array.from(changedAssets.keys());
88
+ await rustAtlaspack.updateBundleGraph(bundleGraph, changedAssetIds);
89
+ } else {
90
+ await rustAtlaspack.loadBundleGraph(bundleGraph);
91
+ }
92
+ }
93
+ }
56
94
 
57
- // $FlowFixMe Added in Flow 0.121.0 upgrade in #4381 (Windows only)
95
+ // @ts-expect-error TS2345
58
96
  (0, _dumpGraphToGraphViz.default)(bundleGraph._graph, 'BundleGraph', _BundleGraph.bundleGraphEdgeTypes);
59
97
  await (0, _ReporterRunner.report)({
60
98
  type: 'buildProgress',
61
99
  phase: 'bundled',
62
- bundleGraph: new _BundleGraph2.default(bundleGraph, (bundle, bundleGraph, options) => _Bundle.NamedBundle.get(bundle, bundleGraph, options), options),
100
+ bundleGraph: new _BundleGraph2.default(bundleGraph,
101
+ // @ts-expect-error TS2304
102
+ (bundle, bundleGraph, options) => _Bundle.NamedBundle.get(bundle, bundleGraph, options), options),
63
103
  changedAssets: new Map(Array.from(changedAssets).map(([id, asset]) => [id, (0, _Asset.assetFromValue)(asset, options)]))
64
104
  });
65
105
  let packagingMeasurement = _profiler().tracer.createMeasurement('packaging');
106
+ const span = _logger().tracer.enter('writeBundles');
66
107
  let writeBundlesRequest = (0, _WriteBundlesRequest.default)({
67
108
  bundleGraph,
68
109
  optionsRef
69
110
  });
70
- let bundleInfo = await api.runRequest(writeBundlesRequest);
111
+ let {
112
+ bundleInfo,
113
+ scopeHoistingStats
114
+ } = await api.runRequest(writeBundlesRequest);
71
115
  packagingMeasurement && packagingMeasurement.end();
116
+ _logger().tracer.exit(span);
72
117
  (0, _utils.assertSignalNotAborted)(signal);
73
118
  return {
74
119
  bundleGraph,
75
120
  bundleInfo,
76
121
  changedAssets,
77
- assetRequests
122
+ assetRequests,
123
+ scopeHoistingStats
78
124
  };
79
125
  }