@atlaspack/core 2.16.2-canary.37 → 2.16.2-canary.371

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 (367) hide show
  1. package/CHANGELOG.md +941 -0
  2. package/dist/AssetGraph.js +591 -0
  3. package/dist/Atlaspack.js +666 -0
  4. package/dist/AtlaspackConfig.js +324 -0
  5. package/dist/AtlaspackConfig.schema.js +117 -0
  6. package/dist/BundleGraph.js +1740 -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 +545 -0
  14. package/dist/ReporterRunner.js +151 -0
  15. package/dist/RequestTracker.js +1360 -0
  16. package/dist/SymbolPropagation.js +620 -0
  17. package/dist/TargetDescriptor.schema.js +143 -0
  18. package/dist/Transformation.js +514 -0
  19. package/dist/UncommittedAsset.js +315 -0
  20. package/dist/Validation.js +196 -0
  21. package/dist/applyRuntimes.js +383 -0
  22. package/dist/assetUtils.js +169 -0
  23. package/dist/atlaspack-v3/AtlaspackV3.js +74 -0
  24. package/dist/atlaspack-v3/NapiWorkerPool.js +81 -0
  25. package/dist/atlaspack-v3/fs.js +52 -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 +25 -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-logger.js +26 -0
  36. package/dist/atlaspack-v3/worker/compat/plugin-options.js +137 -0
  37. package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
  38. package/dist/atlaspack-v3/worker/compat/target.js +14 -0
  39. package/dist/atlaspack-v3/worker/side-effect-detector.js +243 -0
  40. package/dist/atlaspack-v3/worker/worker.js +381 -0
  41. package/dist/constants.js +17 -0
  42. package/dist/dumpGraphToGraphViz.js +281 -0
  43. package/dist/index.js +62 -0
  44. package/dist/loadAtlaspackPlugin.js +128 -0
  45. package/dist/loadDotEnv.js +41 -0
  46. package/dist/projectPath.js +83 -0
  47. package/dist/public/Asset.js +279 -0
  48. package/dist/public/Bundle.js +224 -0
  49. package/dist/public/BundleGraph.js +371 -0
  50. package/dist/public/BundleGroup.js +53 -0
  51. package/dist/public/Config.js +286 -0
  52. package/dist/public/Dependency.js +138 -0
  53. package/dist/public/Environment.js +278 -0
  54. package/dist/public/MutableBundleGraph.js +277 -0
  55. package/dist/public/PluginOptions.js +80 -0
  56. package/dist/public/Symbols.js +248 -0
  57. package/dist/public/Target.js +69 -0
  58. package/dist/registerCoreWithSerializer.js +38 -0
  59. package/dist/requests/AssetGraphRequest.js +439 -0
  60. package/dist/requests/AssetGraphRequestRust.js +273 -0
  61. package/dist/requests/AssetRequest.js +130 -0
  62. package/dist/requests/AtlaspackBuildRequest.js +92 -0
  63. package/dist/requests/AtlaspackConfigRequest.js +493 -0
  64. package/dist/requests/BundleGraphRequest.js +447 -0
  65. package/dist/requests/ConfigRequest.js +246 -0
  66. package/dist/requests/DevDepRequest.js +204 -0
  67. package/dist/requests/EntryRequest.js +314 -0
  68. package/dist/requests/PackageRequest.js +72 -0
  69. package/dist/requests/PathRequest.js +349 -0
  70. package/dist/requests/TargetRequest.js +1311 -0
  71. package/dist/requests/ValidationRequest.js +49 -0
  72. package/dist/requests/WriteBundleRequest.js +254 -0
  73. package/dist/requests/WriteBundlesRequest.js +184 -0
  74. package/dist/requests/asset-graph-diff.js +128 -0
  75. package/dist/requests/asset-graph-dot.js +131 -0
  76. package/dist/resolveOptions.js +269 -0
  77. package/dist/rustWorkerThreadDylibHack.js +19 -0
  78. package/dist/serializerCore.browser.js +43 -0
  79. package/dist/summarizeRequest.js +39 -0
  80. package/dist/types.js +31 -0
  81. package/dist/utils.js +172 -0
  82. package/dist/worker.js +123 -0
  83. package/lib/AssetGraph.js +111 -14
  84. package/lib/Atlaspack.js +94 -41
  85. package/lib/AtlaspackConfig.js +15 -3
  86. package/lib/AtlaspackConfig.schema.js +16 -5
  87. package/lib/BundleGraph.js +197 -32
  88. package/lib/CommittedAsset.js +7 -1
  89. package/lib/Dependency.js +8 -2
  90. package/lib/Environment.js +15 -8
  91. package/lib/EnvironmentManager.js +143 -0
  92. package/lib/IdentifierRegistry.js +1 -3
  93. package/lib/InternalConfig.js +3 -2
  94. package/lib/PackagerRunner.js +90 -27
  95. package/lib/ReporterRunner.js +6 -9
  96. package/lib/RequestTracker.js +266 -156
  97. package/lib/SymbolPropagation.js +42 -18
  98. package/lib/TargetDescriptor.schema.js +7 -1
  99. package/lib/Transformation.js +66 -15
  100. package/lib/UncommittedAsset.js +33 -12
  101. package/lib/Validation.js +18 -2
  102. package/lib/applyRuntimes.js +96 -4
  103. package/lib/assetUtils.js +15 -5
  104. package/lib/atlaspack-v3/AtlaspackV3.js +52 -14
  105. package/lib/atlaspack-v3/NapiWorkerPool.js +28 -1
  106. package/lib/atlaspack-v3/fs.js +3 -1
  107. package/lib/atlaspack-v3/index.js +28 -1
  108. package/lib/atlaspack-v3/jsCallable.js +0 -2
  109. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +7 -4
  110. package/lib/atlaspack-v3/worker/compat/bitflags.js +31 -25
  111. package/lib/atlaspack-v3/worker/compat/dependency.js +4 -1
  112. package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
  113. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +15 -10
  114. package/lib/atlaspack-v3/worker/compat/plugin-config.js +13 -34
  115. package/lib/atlaspack-v3/worker/compat/plugin-options.js +16 -0
  116. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
  117. package/lib/atlaspack-v3/worker/compat/target.js +2 -0
  118. package/lib/atlaspack-v3/worker/index.js +3 -0
  119. package/lib/atlaspack-v3/worker/side-effect-detector.js +215 -0
  120. package/lib/atlaspack-v3/worker/worker.js +199 -71
  121. package/lib/constants.js +0 -1
  122. package/lib/dumpGraphToGraphViz.js +71 -16
  123. package/lib/index.js +45 -1
  124. package/lib/loadDotEnv.js +4 -1
  125. package/lib/projectPath.js +5 -0
  126. package/lib/public/Asset.js +21 -11
  127. package/lib/public/Bundle.js +15 -16
  128. package/lib/public/BundleGraph.js +25 -22
  129. package/lib/public/BundleGroup.js +4 -5
  130. package/lib/public/Config.js +118 -17
  131. package/lib/public/Dependency.js +8 -6
  132. package/lib/public/Environment.js +12 -7
  133. package/lib/public/MutableBundleGraph.js +54 -12
  134. package/lib/public/PluginOptions.js +2 -2
  135. package/lib/public/Symbols.js +11 -11
  136. package/lib/public/Target.js +7 -6
  137. package/lib/registerCoreWithSerializer.js +5 -3
  138. package/lib/requests/AssetGraphRequest.js +74 -27
  139. package/lib/requests/AssetGraphRequestRust.js +140 -64
  140. package/lib/requests/AssetRequest.js +23 -6
  141. package/lib/requests/AtlaspackBuildRequest.js +43 -4
  142. package/lib/requests/AtlaspackConfigRequest.js +27 -16
  143. package/lib/requests/BundleGraphRequest.js +41 -24
  144. package/lib/requests/ConfigRequest.js +53 -4
  145. package/lib/requests/DevDepRequest.js +31 -5
  146. package/lib/requests/EntryRequest.js +2 -0
  147. package/lib/requests/PackageRequest.js +16 -2
  148. package/lib/requests/PathRequest.js +24 -3
  149. package/lib/requests/TargetRequest.js +122 -57
  150. package/lib/requests/ValidationRequest.js +5 -1
  151. package/lib/requests/WriteBundleRequest.js +39 -11
  152. package/lib/requests/WriteBundlesRequest.js +51 -4
  153. package/lib/requests/asset-graph-diff.js +12 -7
  154. package/lib/requests/asset-graph-dot.js +1 -7
  155. package/lib/resolveOptions.js +38 -11
  156. package/lib/rustWorkerThreadDylibHack.js +0 -1
  157. package/lib/types/AssetGraph.d.ts +80 -0
  158. package/lib/types/Atlaspack.d.ts +52 -0
  159. package/lib/types/AtlaspackConfig.d.ts +65 -0
  160. package/lib/types/AtlaspackConfig.schema.d.ts +53 -0
  161. package/lib/types/BundleGraph.d.ts +184 -0
  162. package/lib/types/CommittedAsset.d.ts +23 -0
  163. package/lib/types/Dependency.d.ts +44 -0
  164. package/lib/types/Environment.d.ts +11 -0
  165. package/lib/types/EnvironmentManager.d.ts +37 -0
  166. package/lib/types/IdentifierRegistry.d.ts +6 -0
  167. package/lib/types/InternalConfig.d.ts +23 -0
  168. package/lib/types/PackagerRunner.d.ts +85 -0
  169. package/lib/types/ReporterRunner.d.ts +25 -0
  170. package/lib/types/RequestTracker.d.ts +385 -0
  171. package/lib/types/SymbolPropagation.d.ts +11 -0
  172. package/lib/types/TargetDescriptor.schema.d.ts +5 -0
  173. package/lib/types/Transformation.d.ts +72 -0
  174. package/lib/types/UncommittedAsset.d.ts +61 -0
  175. package/lib/types/Validation.d.ts +37 -0
  176. package/lib/types/applyRuntimes.d.ts +25 -0
  177. package/lib/types/assetUtils.d.ts +42 -0
  178. package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +34 -0
  179. package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +13 -0
  180. package/lib/types/atlaspack-v3/fs.d.ts +12 -0
  181. package/lib/types/atlaspack-v3/index.d.ts +6 -0
  182. package/lib/types/atlaspack-v3/jsCallable.d.ts +1 -0
  183. package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
  184. package/lib/types/atlaspack-v3/worker/compat/bitflags.d.ts +14 -0
  185. package/lib/types/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
  186. package/lib/types/atlaspack-v3/worker/compat/environment.d.ts +27 -0
  187. package/{src/atlaspack-v3/worker/compat/index.js → lib/types/atlaspack-v3/worker/compat/index.d.ts} +0 -1
  188. package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
  189. package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +29 -0
  190. package/lib/types/atlaspack-v3/worker/compat/plugin-logger.d.ts +9 -0
  191. package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +23 -0
  192. package/lib/types/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
  193. package/lib/types/atlaspack-v3/worker/compat/target.d.ts +11 -0
  194. package/lib/types/atlaspack-v3/worker/side-effect-detector.d.ts +76 -0
  195. package/lib/types/atlaspack-v3/worker/worker.d.ts +80 -0
  196. package/lib/types/constants.d.ts +13 -0
  197. package/lib/types/dumpGraphToGraphViz.d.ts +10 -0
  198. package/lib/types/index.d.ts +8 -0
  199. package/lib/types/loadAtlaspackPlugin.d.ts +8 -0
  200. package/lib/types/loadDotEnv.d.ts +3 -0
  201. package/lib/types/projectPath.d.ts +19 -0
  202. package/lib/types/public/Asset.d.ts +74 -0
  203. package/lib/types/public/Bundle.d.ts +45 -0
  204. package/lib/types/public/BundleGraph.d.ts +72 -0
  205. package/lib/types/public/BundleGroup.d.ts +12 -0
  206. package/lib/types/public/Config.d.ts +75 -0
  207. package/lib/types/public/Dependency.d.ts +32 -0
  208. package/lib/types/public/Environment.d.ts +34 -0
  209. package/lib/types/public/MutableBundleGraph.d.ts +26 -0
  210. package/lib/types/public/PluginOptions.d.ts +25 -0
  211. package/lib/types/public/Symbols.d.ts +81 -0
  212. package/lib/types/public/Target.d.ts +16 -0
  213. package/lib/types/registerCoreWithSerializer.d.ts +2 -0
  214. package/lib/types/requests/AssetGraphRequest.d.ts +76 -0
  215. package/lib/types/requests/AssetGraphRequestRust.d.ts +21 -0
  216. package/lib/types/requests/AssetRequest.d.ts +16 -0
  217. package/lib/types/requests/AtlaspackBuildRequest.d.ts +33 -0
  218. package/lib/types/requests/AtlaspackConfigRequest.d.ts +45 -0
  219. package/lib/types/requests/BundleGraphRequest.d.ts +28 -0
  220. package/lib/types/requests/ConfigRequest.d.ts +67 -0
  221. package/lib/types/requests/DevDepRequest.d.ts +30 -0
  222. package/lib/types/requests/EntryRequest.d.ts +36 -0
  223. package/lib/types/requests/PackageRequest.d.ts +27 -0
  224. package/lib/types/requests/PathRequest.d.ts +48 -0
  225. package/lib/types/requests/TargetRequest.d.ts +48 -0
  226. package/lib/types/requests/ValidationRequest.d.ts +20 -0
  227. package/lib/types/requests/WriteBundleRequest.d.ts +28 -0
  228. package/lib/types/requests/WriteBundlesRequest.d.ts +32 -0
  229. package/lib/types/requests/asset-graph-diff.d.ts +1 -0
  230. package/lib/types/requests/asset-graph-dot.d.ts +9 -0
  231. package/lib/types/resolveOptions.d.ts +3 -0
  232. package/lib/types/rustWorkerThreadDylibHack.d.ts +9 -0
  233. package/lib/types/serializerCore.browser.d.ts +3 -0
  234. package/lib/types/summarizeRequest.d.ts +10 -0
  235. package/lib/types/types.d.ts +495 -0
  236. package/lib/types/utils.d.ts +23 -0
  237. package/lib/types/worker.d.ts +44 -0
  238. package/lib/types.js +8 -1
  239. package/lib/utils.js +17 -2
  240. package/lib/worker.js +30 -14
  241. package/package.json +25 -35
  242. package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
  243. package/src/{Atlaspack.js → Atlaspack.ts} +134 -67
  244. package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +25 -19
  245. package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
  246. package/src/{BundleGraph.js → BundleGraph.ts} +383 -140
  247. package/src/{CommittedAsset.js → CommittedAsset.ts} +15 -13
  248. package/src/{Dependency.js → Dependency.ts} +59 -42
  249. package/src/{Environment.js → Environment.ts} +24 -15
  250. package/src/EnvironmentManager.ts +154 -0
  251. package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
  252. package/src/{InternalConfig.js → InternalConfig.ts} +22 -23
  253. package/src/{PackagerRunner.js → PackagerRunner.ts} +179 -87
  254. package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
  255. package/src/{RequestTracker.js → RequestTracker.ts} +572 -357
  256. package/src/{SymbolPropagation.js → SymbolPropagation.ts} +165 -57
  257. package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
  258. package/src/{Transformation.js → Transformation.ts} +110 -65
  259. package/src/{UncommittedAsset.js → UncommittedAsset.ts} +60 -39
  260. package/src/{Validation.js → Validation.ts} +32 -17
  261. package/src/{applyRuntimes.js → applyRuntimes.ts} +133 -26
  262. package/src/{assetUtils.js → assetUtils.ts} +49 -36
  263. package/src/atlaspack-v3/AtlaspackV3.ts +143 -0
  264. package/src/atlaspack-v3/NapiWorkerPool.ts +91 -0
  265. package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
  266. package/src/atlaspack-v3/{index.js → index.ts} +3 -4
  267. package/src/atlaspack-v3/jsCallable.ts +14 -0
  268. package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +40 -30
  269. package/src/atlaspack-v3/worker/compat/bitflags.ts +102 -0
  270. package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +13 -13
  271. package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
  272. package/src/atlaspack-v3/worker/compat/index.ts +9 -0
  273. package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +21 -20
  274. package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +25 -56
  275. package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
  276. package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +19 -5
  277. package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
  278. package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
  279. package/src/atlaspack-v3/worker/index.js +2 -1
  280. package/src/atlaspack-v3/worker/side-effect-detector.ts +298 -0
  281. package/src/atlaspack-v3/worker/worker.ts +531 -0
  282. package/src/{constants.js → constants.ts} +0 -3
  283. package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
  284. package/src/index.ts +18 -0
  285. package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +8 -9
  286. package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
  287. package/src/{projectPath.js → projectPath.ts} +20 -9
  288. package/src/public/{Asset.js → Asset.ts} +41 -28
  289. package/src/public/{Bundle.js → Bundle.ts} +28 -29
  290. package/src/public/{BundleGraph.js → BundleGraph.ts} +103 -68
  291. package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
  292. package/src/public/{Config.js → Config.ts} +171 -33
  293. package/src/public/{Dependency.js → Dependency.ts} +20 -17
  294. package/src/public/{Environment.js → Environment.ts} +28 -17
  295. package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
  296. package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
  297. package/src/public/{Symbols.js → Symbols.ts} +75 -36
  298. package/src/public/{Target.js → Target.ts} +10 -8
  299. package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
  300. package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +129 -80
  301. package/src/requests/AssetGraphRequestRust.ts +364 -0
  302. package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
  303. package/src/requests/AtlaspackBuildRequest.ts +163 -0
  304. package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
  305. package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +97 -79
  306. package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +110 -50
  307. package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +60 -35
  308. package/src/requests/{EntryRequest.js → EntryRequest.ts} +36 -31
  309. package/src/requests/{PackageRequest.js → PackageRequest.ts} +34 -22
  310. package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
  311. package/src/requests/{TargetRequest.js → TargetRequest.ts} +260 -179
  312. package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
  313. package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +77 -49
  314. package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +109 -37
  315. package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +25 -21
  316. package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
  317. package/src/{resolveOptions.js → resolveOptions.ts} +59 -25
  318. package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
  319. package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
  320. package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
  321. package/src/types.ts +650 -0
  322. package/src/{utils.js → utils.ts} +52 -21
  323. package/src/{worker.js → worker.ts} +50 -42
  324. package/test/{AssetGraph.test.js → AssetGraph.test.ts} +37 -8
  325. package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
  326. package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
  327. package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +76 -16
  328. package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
  329. package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
  330. package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
  331. package/test/Environment.test.ts +153 -0
  332. package/test/EnvironmentManager.test.ts +188 -0
  333. package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
  334. package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
  335. package/test/PackagerRunner.test.ts +0 -0
  336. package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
  337. package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
  338. package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
  339. package/test/PublicEnvironment.test.ts +49 -0
  340. package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
  341. package/test/{RequestTracker.test.js → RequestTracker.test.ts} +314 -59
  342. package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
  343. package/test/{TargetRequest.test.js → TargetRequest.test.ts} +66 -92
  344. package/test/fixtures/config-with-reporters/.parcelrc +7 -0
  345. package/test/fixtures/custom-targets/package.json +6 -0
  346. package/test/public/Config.test.ts +104 -0
  347. package/test/requests/AssetGraphRequestRust.test.ts +443 -0
  348. package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
  349. package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
  350. package/test/{test-utils.js → test-utils.ts} +4 -11
  351. package/test/{utils.test.js → utils.test.ts} +1 -3
  352. package/tsconfig.json +60 -0
  353. package/tsconfig.tsbuildinfo +1 -0
  354. package/index.d.ts +0 -30
  355. package/src/atlaspack-v3/AtlaspackV3.js +0 -87
  356. package/src/atlaspack-v3/NapiWorkerPool.js +0 -53
  357. package/src/atlaspack-v3/jsCallable.js +0 -18
  358. package/src/atlaspack-v3/worker/compat/bitflags.js +0 -100
  359. package/src/atlaspack-v3/worker/worker.js +0 -362
  360. package/src/index.js +0 -13
  361. package/src/requests/AssetGraphRequestRust.js +0 -263
  362. package/src/requests/AtlaspackBuildRequest.js +0 -111
  363. package/src/types.js +0 -600
  364. package/test/Environment.test.js +0 -119
  365. package/test/PackagerRunner.test.js +0 -27
  366. package/test/PublicEnvironment.test.js +0 -27
  367. package/test/requests/AssetGraphRequestRust.test.js +0 -411
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import type {
3
2
  Async,
4
3
  Config as IConfig,
@@ -7,6 +6,7 @@ import type {
7
6
  PluginTracer as IPluginTracer,
8
7
  NamedBundle as INamedBundle,
9
8
  BundleGraph as IBundleGraph,
9
+ TransformerSetup,
10
10
  } from '@atlaspack/types';
11
11
  import {readConfig, hashObject} from '@atlaspack/utils';
12
12
  import type {
@@ -30,52 +30,56 @@ import {PluginTracer} from '@atlaspack/profiler';
30
30
  import {requestTypes} from '../RequestTracker';
31
31
  import {fromProjectPath, fromProjectPathRelative} from '../projectPath';
32
32
 
33
+ type Setup<T> = (arg1: {
34
+ config: IConfig;
35
+ options: IPluginOptions;
36
+ logger: IPluginLogger;
37
+ tracer: IPluginTracer;
38
+ }) => Async<TransformerSetup<T>>;
39
+
33
40
  export type PluginWithLoadConfig = {
34
- loadConfig?: ({|
35
- config: IConfig,
36
- options: IPluginOptions,
37
- logger: IPluginLogger,
38
- tracer: IPluginTracer,
39
- |}) => Async<mixed>,
40
- ...
41
+ loadConfig?: (arg1: {
42
+ config: IConfig;
43
+ options: IPluginOptions;
44
+ logger: IPluginLogger;
45
+ tracer: IPluginTracer;
46
+ }) => Async<unknown>;
41
47
  };
42
48
 
43
49
  export type PluginWithBundleConfig = {
44
- loadConfig?: ({|
45
- config: IConfig,
46
- options: IPluginOptions,
47
- logger: IPluginLogger,
48
- tracer: IPluginTracer,
49
- |}) => Async<mixed>,
50
- loadBundleConfig?: ({|
51
- bundle: INamedBundle,
52
- bundleGraph: IBundleGraph<INamedBundle>,
53
- config: IConfig,
54
- options: IPluginOptions,
55
- logger: IPluginLogger,
56
- tracer: IPluginTracer,
57
- |}) => Async<mixed>,
58
- ...
50
+ loadConfig?: (arg1: {
51
+ config: IConfig;
52
+ options: IPluginOptions;
53
+ logger: IPluginLogger;
54
+ tracer: IPluginTracer;
55
+ }) => Async<unknown>;
56
+ loadBundleConfig?: (arg1: {
57
+ bundle: INamedBundle;
58
+ bundleGraph: IBundleGraph<INamedBundle>;
59
+ config: IConfig;
60
+ options: IPluginOptions;
61
+ logger: IPluginLogger;
62
+ tracer: IPluginTracer;
63
+ }) => Async<unknown>;
59
64
  };
60
65
 
61
66
  export type ConfigRequest = {
62
- id: string,
63
- invalidateOnFileChange: Set<ProjectPath>,
64
- invalidateOnConfigKeyChange: Array<{|
65
- filePath: ProjectPath,
66
- configKey: string,
67
- |}>,
68
- invalidateOnFileCreate: Array<InternalFileCreateInvalidation>,
69
- invalidateOnEnvChange: Set<string>,
70
- invalidateOnOptionChange: Set<string>,
71
- invalidateOnStartup: boolean,
72
- invalidateOnBuild: boolean,
73
- ...
67
+ id: string;
68
+ invalidateOnFileChange: Set<ProjectPath>;
69
+ invalidateOnConfigKeyChange: Array<{
70
+ filePath: ProjectPath;
71
+ configKey: string[];
72
+ }>;
73
+ invalidateOnFileCreate: Array<InternalFileCreateInvalidation>;
74
+ invalidateOnEnvChange: Set<string>;
75
+ invalidateOnOptionChange: Set<string>;
76
+ invalidateOnStartup: boolean;
77
+ invalidateOnBuild: boolean;
74
78
  };
75
79
 
76
- export type ConfigRequestResult = void;
80
+ export type ConfigRequestResult = undefined;
77
81
 
78
- export async function loadPluginConfig<T: PluginWithLoadConfig>(
82
+ export async function loadPluginConfig<T extends PluginWithLoadConfig>(
79
83
  loadedPlugin: LoadedPlugin<T>,
80
84
  config: Config,
81
85
  options: AtlaspackOptions,
@@ -99,7 +103,7 @@ export async function loadPluginConfig<T: PluginWithLoadConfig>(
99
103
  category: 'loadConfig',
100
104
  }),
101
105
  });
102
- } catch (e) {
106
+ } catch (e: any) {
103
107
  throw new ThrowableDiagnostic({
104
108
  diagnostic: errorToDiagnostic(e, {
105
109
  origin: loadedPlugin.name,
@@ -108,41 +112,97 @@ export async function loadPluginConfig<T: PluginWithLoadConfig>(
108
112
  }
109
113
  }
110
114
 
115
+ export async function loadPluginSetup<T>(
116
+ pluginName: string,
117
+ setup: Setup<T>,
118
+ config: Config,
119
+ options: AtlaspackOptions,
120
+ ): Promise<void> {
121
+ try {
122
+ let result = await setup({
123
+ config: new PublicConfig(config, options),
124
+ options: new PluginOptions(
125
+ optionsProxy(options, (option) => {
126
+ config.invalidateOnOptionChange.add(option);
127
+ }),
128
+ ),
129
+ logger: new PluginLogger({origin: pluginName}),
130
+ tracer: new PluginTracer({
131
+ origin: pluginName,
132
+ category: 'setup',
133
+ }),
134
+ });
135
+
136
+ config.result = result.config;
137
+ } catch (e: any) {
138
+ throw new ThrowableDiagnostic({
139
+ diagnostic: errorToDiagnostic(e, {
140
+ origin: pluginName,
141
+ }),
142
+ });
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Return value at a given key path within an object.
148
+ *
149
+ * @example
150
+ * const obj = { a: { b: { c: 'd' } } };
151
+ * getValueAtPath(obj, ['a', 'b', 'c']); // 'd'
152
+ * getValueAtPath(obj, ['a', 'b', 'd']); // undefined
153
+ * getValueAtPath(obj, ['a', 'b']); // { c: 'd' }
154
+ * getValueAtPath(obj, ['a', 'b', 'c', 'd']); // undefined
155
+ */
156
+ export function getValueAtPath(obj: any, key: string[]): any {
157
+ let current = obj;
158
+ for (let part of key) {
159
+ if (current == null) {
160
+ return undefined;
161
+ }
162
+ current = current[part];
163
+ }
164
+ return current;
165
+ }
166
+
111
167
  const configKeyCache = createBuildCache();
112
168
 
113
169
  export async function getConfigKeyContentHash(
114
170
  filePath: ProjectPath,
115
- configKey: string,
171
+ configKey: string[],
116
172
  options: AtlaspackOptions,
117
- ): Async<string> {
118
- let cacheKey = `${fromProjectPathRelative(filePath)}:${configKey}`;
173
+ ): Promise<Async<string>> {
174
+ let cacheKey = `${fromProjectPathRelative(filePath)}:${JSON.stringify(
175
+ configKey,
176
+ )}`;
119
177
  let cachedValue = configKeyCache.get(cacheKey);
120
178
 
121
179
  if (cachedValue) {
180
+ // @ts-expect-error TS2322
122
181
  return cachedValue;
123
182
  }
124
183
 
125
- let conf = await readConfig(
184
+ const conf = await readConfig(
126
185
  options.inputFS,
127
186
  fromProjectPath(options.projectRoot, filePath),
128
187
  );
129
188
 
130
- if (conf == null || conf.config[configKey] == null) {
189
+ const value = getValueAtPath(conf?.config, configKey);
190
+ if (conf == null || value == null) {
131
191
  // This can occur when a config key has been removed entirely during `respondToFSEvents`
132
192
  return '';
133
193
  }
134
194
 
135
- let contentHash =
136
- typeof conf.config[configKey] === 'object'
137
- ? hashObject(conf.config[configKey])
138
- : hashString(JSON.stringify(conf.config[configKey]));
195
+ const contentHash =
196
+ typeof value === 'object'
197
+ ? hashObject(value)
198
+ : hashString(JSON.stringify(value));
139
199
 
140
200
  configKeyCache.set(cacheKey, contentHash);
141
201
 
142
202
  return contentHash;
143
203
  }
144
204
 
145
- export async function runConfigRequest<TResult: RequestResult>(
205
+ export async function runConfigRequest<TResult extends RequestResult>(
146
206
  api: RunAPI<TResult>,
147
207
  configRequest: ConfigRequest,
148
208
  ) {
@@ -169,7 +229,7 @@ export async function runConfigRequest<TResult: RequestResult>(
169
229
  return;
170
230
  }
171
231
 
172
- await api.runRequest<null, void>({
232
+ await api.runRequest<null, undefined>({
173
233
  id: 'config_request:' + configRequest.id,
174
234
  type: requestTypes.config_request,
175
235
  run: async ({api, options}) => {
@@ -240,7 +300,7 @@ export async function getConfigHash(
240
300
  } else if (config.result != null) {
241
301
  try {
242
302
  hash.writeBuffer(serializeRaw(config.result));
243
- } catch (err) {
303
+ } catch (err: any) {
244
304
  throw new ThrowableDiagnostic({
245
305
  diagnostic: {
246
306
  message:
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import type {
3
2
  DependencySpecifier,
4
3
  SemverRange,
@@ -57,7 +56,7 @@ export async function createDevDependency(
57
56
  // Ensure that the package manager has an entry for this resolution.
58
57
  try {
59
58
  await options.packageManager.resolve(specifier, resolveFromAbsolute);
60
- } catch (err) {
59
+ } catch (err: any) {
61
60
  // ignore
62
61
  }
63
62
 
@@ -103,49 +102,68 @@ export async function createDevDependency(
103
102
  return devDepRequest;
104
103
  }
105
104
 
106
- export type DevDepSpecifier = {|
107
- specifier: DependencySpecifier,
108
- resolveFrom: ProjectPath,
109
- |};
105
+ export type DevDepSpecifier = {
106
+ specifier: DependencySpecifier;
107
+ resolveFrom: ProjectPath;
108
+ };
110
109
 
111
- type DevDepRequests = {|
112
- devDeps: Map<string, string>,
113
- invalidDevDeps: Array<DevDepSpecifier>,
114
- |};
110
+ type DevDepRequests = {
111
+ devDeps: Map<string, string>;
112
+ invalidDevDeps: Array<DevDepSpecifier>;
113
+ };
115
114
 
116
- export async function getDevDepRequests<TResult: RequestResult>(
115
+ export async function getDevDepRequests<TResult extends RequestResult>(
117
116
  api: RunAPI<TResult>,
118
117
  ): Promise<DevDepRequests> {
119
- let previousDevDepRequests: Map<string, DevDepRequestResult> = new Map(
120
- await Promise.all(
118
+ async function getPreviousDevDepRequests() {
119
+ const allDevDepRequests = await Promise.all(
121
120
  api
122
121
  .getSubRequests()
123
122
  .filter((req) => req.requestType === requestTypes.dev_dep_request)
124
- .map(async (req) => [
125
- req.id,
126
- nullthrows(await api.getRequestResult<DevDepRequestResult>(req.id)),
127
- ]),
128
- ),
129
- );
123
+ .map(
124
+ async (
125
+ req,
126
+ ): Promise<[string, DevDepRequestResult | null | undefined]> => [
127
+ req.id,
128
+ await api.getRequestResult<DevDepRequestResult>(req.id),
129
+ ],
130
+ ),
131
+ );
132
+ const nonNullDevDepRequests: Array<Array<string | DevDepRequestResult>> =
133
+ [];
134
+ for (const [id, result] of allDevDepRequests) {
135
+ if (result != null) {
136
+ nonNullDevDepRequests.push([id, result]);
137
+ }
138
+ }
139
+
140
+ // @ts-expect-error TS2769
141
+ return new Map(nonNullDevDepRequests);
142
+ }
143
+
144
+ const previousDevDepRequests = await getPreviousDevDepRequests();
130
145
 
131
146
  return {
132
147
  devDeps: new Map(
133
148
  [...previousDevDepRequests.entries()]
134
- .filter(([id]) => api.canSkipSubrequest(id))
135
- .map(([, req]: [string, DevDepRequestResult]) => [
149
+ // @ts-expect-error TS2769
150
+ .filter(([id]: [any]) => api.canSkipSubrequest(id))
151
+ .map(([, req]: [any, any]) => [
136
152
  `${req.specifier}:${fromProjectPathRelative(req.resolveFrom)}`,
137
153
  req.hash,
138
154
  ]),
139
155
  ),
140
156
  invalidDevDeps: await Promise.all(
141
157
  [...previousDevDepRequests.entries()]
142
- .filter(([id]) => !api.canSkipSubrequest(id))
143
- .flatMap(([, req]: [string, DevDepRequestResult]) => {
158
+ // @ts-expect-error TS2769
159
+ .filter(([id]: [any]) => !api.canSkipSubrequest(id))
160
+ .flatMap(([, req]: [any, any]) => {
144
161
  return [
145
162
  {
146
163
  specifier: req.specifier,
147
164
  resolveFrom: req.resolveFrom,
148
165
  },
166
+ // @ts-expect-error TS7006
149
167
  ...(req.additionalInvalidations ?? []).map((i) => ({
150
168
  specifier: i.specifier,
151
169
  resolveFrom: i.resolveFrom,
@@ -178,22 +196,25 @@ export function invalidateDevDeps(
178
196
  }
179
197
  }
180
198
 
181
- export type DevDepRequestResult = {|
182
- specifier: DependencySpecifier,
183
- resolveFrom: ProjectPath,
184
- hash: string,
185
- additionalInvalidations: void | Array<{|
186
- range?: ?SemverRange,
187
- resolveFrom: ProjectPath,
188
- specifier: DependencySpecifier,
189
- |}>,
190
- |};
199
+ export type DevDepRequestResult = {
200
+ specifier: DependencySpecifier;
201
+ resolveFrom: ProjectPath;
202
+ hash: string;
203
+ additionalInvalidations:
204
+ | undefined
205
+ | Array<{
206
+ range?: SemverRange | null | undefined;
207
+ resolveFrom: ProjectPath;
208
+ specifier: DependencySpecifier;
209
+ }>;
210
+ };
191
211
 
192
212
  const devDepRequests: Map<string, DevDepRequest> = createBuildCache();
193
213
  export function resolveDevDepRequestRef(
194
214
  devDepRequestRef: DevDepRequest | DevDepRequestRef,
195
215
  ): DevDepRequest {
196
216
  const devDepRequest =
217
+ // @ts-expect-error TS2339
197
218
  devDepRequestRef.type === 'ref'
198
219
  ? devDepRequests.get(devDepRequestRef.hash)
199
220
  : devDepRequestRef;
@@ -213,24 +234,28 @@ This is a bug in Atlaspack.`,
213
234
  );
214
235
  }
215
236
 
237
+ // @ts-expect-error TS2339
216
238
  if (devDepRequestRef.type !== 'ref') {
239
+ // @ts-expect-error TS2345
217
240
  devDepRequests.set(devDepRequest.hash, devDepRequest);
218
241
  }
219
242
 
243
+ // @ts-expect-error TS2322
220
244
  return devDepRequest;
221
245
  }
222
246
 
223
- export async function runDevDepRequest<TResult: RequestResult>(
247
+ export async function runDevDepRequest<TResult extends RequestResult>(
224
248
  api: RunAPI<TResult>,
225
249
  devDepRequestRef: DevDepRequest | DevDepRequestRef,
226
250
  ) {
227
- await api.runRequest<null, DevDepRequestResult | void>({
251
+ await api.runRequest<null, DevDepRequestResult | undefined>({
228
252
  id:
229
253
  'dev_dep_request:' +
230
254
  devDepRequestRef.specifier +
231
255
  ':' +
232
256
  devDepRequestRef.hash,
233
257
  type: requestTypes.dev_dep_request,
258
+ // @ts-expect-error TS2322
234
259
  run: ({api}) => {
235
260
  const devDepRequest = resolveDevDepRequestRef(devDepRequestRef);
236
261
 
@@ -1,5 +1,3 @@
1
- // @flow strict-local
2
-
3
1
  import type {Async, FilePath, PackageJSON, Glob} from '@atlaspack/types';
4
2
  import type {StaticRunOpts} from '../RequestTracker';
5
3
  import type {Entry, InternalFile, AtlaspackOptions} from '../types';
@@ -17,32 +15,31 @@ import ThrowableDiagnostic, {
17
15
  getJSONSourceLocation,
18
16
  } from '@atlaspack/diagnostic';
19
17
  import path from 'path';
20
- import {parse, type Mapping} from '@mischnic/json-sourcemap';
18
+ import {parse, Mapping} from '@mischnic/json-sourcemap';
21
19
  import {requestTypes} from '../RequestTracker';
22
20
  import {
23
- type ProjectPath,
21
+ ProjectPath,
24
22
  fromProjectPath,
25
23
  fromProjectPathRelative,
26
24
  toProjectPath,
27
25
  } from '../projectPath';
28
26
 
29
- type RunOpts<TResult> = {|
30
- input: ProjectPath,
31
- ...StaticRunOpts<TResult>,
32
- |};
27
+ type RunOpts<TResult> = {
28
+ input: ProjectPath;
29
+ } & StaticRunOpts<TResult>;
33
30
 
34
- export type EntryRequest = {|
35
- id: string,
36
- +type: typeof requestTypes.entry_request,
37
- run: (RunOpts<EntryRequestResult>) => Async<EntryRequestResult>,
38
- input: ProjectPath,
39
- |};
31
+ export type EntryRequest = {
32
+ id: string;
33
+ readonly type: typeof requestTypes.entry_request;
34
+ run: (arg1: RunOpts<EntryRequestResult>) => Async<EntryRequestResult>;
35
+ input: ProjectPath;
36
+ };
40
37
 
41
- export type EntryRequestResult = {|
42
- entries: Array<Entry>,
43
- files: Array<InternalFile>,
44
- globs: Array<Glob>,
45
- |};
38
+ export type EntryRequestResult = {
39
+ entries: Array<Entry>;
40
+ files: Array<InternalFile>;
41
+ globs: Array<Glob>;
42
+ };
46
43
 
47
44
  const type = 'entry_request';
48
45
 
@@ -55,6 +52,7 @@ export default function createEntryRequest(input: ProjectPath): EntryRequest {
55
52
  };
56
53
  }
57
54
 
55
+ // @ts-expect-error TS7031
58
56
  async function run({input, api, options}): Promise<EntryRequestResult> {
59
57
  let entryResolver = new EntryResolver(options);
60
58
  let filePath = fromProjectPath(options.projectRoot, input);
@@ -97,7 +95,7 @@ async function assertFile(
97
95
  let stat;
98
96
  try {
99
97
  stat = await fs.stat(source);
100
- } catch (err) {
98
+ } catch (err: any) {
101
99
  let contents = await fs.readFile(pkgFilePath, 'utf8');
102
100
  let alternatives = await findAlternativeFiles(
103
101
  fs,
@@ -161,7 +159,7 @@ export class EntryResolver {
161
159
  let stat;
162
160
  try {
163
161
  stat = await this.options.inputFS.stat(entry);
164
- } catch (err) {
162
+ } catch (err: any) {
165
163
  if (!isGlob(entry)) {
166
164
  throw new ThrowableDiagnostic({
167
165
  diagnostic: {
@@ -191,13 +189,13 @@ export class EntryResolver {
191
189
 
192
190
  if (pkg) {
193
191
  let {filePath} = pkg;
194
- let entries = [];
192
+ let entries: Array<Entry> = [];
195
193
  let files = [
196
194
  {
197
195
  filePath: toProjectPath(this.options.projectRoot, filePath),
198
196
  },
199
197
  ];
200
- let globs = [];
198
+ let globs: Array<Glob> = [];
201
199
 
202
200
  let targetsWithSources = 0;
203
201
  if (pkg.targets) {
@@ -348,23 +346,30 @@ export class EntryResolver {
348
346
  });
349
347
  }
350
348
 
351
- async readPackage(entry: FilePath): Promise<?{
352
- ...PackageJSON,
353
- filePath: FilePath,
354
- map: {|data: mixed, pointers: {|[string]: Mapping|}|},
355
- ...
356
- }> {
349
+ async readPackage(entry: FilePath): Promise<
350
+ | (PackageJSON & {
351
+ filePath: FilePath;
352
+ map: {
353
+ data: unknown;
354
+ pointers: {
355
+ [key: string]: Mapping;
356
+ };
357
+ };
358
+ })
359
+ | null
360
+ | undefined
361
+ > {
357
362
  let content, pkg;
358
363
  let pkgFile = path.join(entry, 'package.json');
359
364
  try {
360
365
  content = await this.options.inputFS.readFile(pkgFile, 'utf8');
361
- } catch (err) {
366
+ } catch (err: any) {
362
367
  return null;
363
368
  }
364
369
 
365
370
  try {
366
371
  pkg = JSON.parse(content);
367
- } catch (err) {
372
+ } catch (err: any) {
368
373
  // TODO: code frame?
369
374
  throw new ThrowableDiagnostic({
370
375
  diagnostic: {
@@ -1,5 +1,3 @@
1
- // @flow strict-local
2
-
3
1
  import type {ContentKey} from '@atlaspack/graph';
4
2
  import type {Async} from '@atlaspack/types';
5
3
  import type {SharedReference} from '@atlaspack/workers';
@@ -15,28 +13,29 @@ import nullthrows from 'nullthrows';
15
13
  import {runConfigRequest} from './ConfigRequest';
16
14
  import {getDevDepRequests, runDevDepRequest} from './DevDepRequest';
17
15
  import createAtlaspackConfigRequest from './AtlaspackConfigRequest';
16
+ import {fromEnvironmentId} from '../EnvironmentManager';
17
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
18
18
 
19
- type PackageRequestInput = {|
20
- bundleGraph: BundleGraph,
21
- bundle: Bundle,
22
- bundleGraphReference: SharedReference,
23
- optionsRef: SharedReference,
24
- useMainThread?: boolean,
25
- |};
19
+ type PackageRequestInput = {
20
+ bundleGraph: BundleGraph;
21
+ bundle: Bundle;
22
+ bundleGraphReference: SharedReference;
23
+ optionsRef: SharedReference;
24
+ useMainThread?: boolean;
25
+ };
26
26
 
27
27
  export type PackageRequestResult = BundleInfo;
28
28
 
29
- type RunInput<TResult> = {|
30
- input: PackageRequestInput,
31
- ...StaticRunOpts<TResult>,
32
- |};
29
+ type RunInput<TResult> = {
30
+ input: PackageRequestInput;
31
+ } & StaticRunOpts<TResult>;
33
32
 
34
- export type PackageRequest = {|
35
- id: ContentKey,
36
- +type: typeof requestTypes.package_request,
37
- run: (RunInput<BundleInfo>) => Async<BundleInfo>,
38
- input: PackageRequestInput,
39
- |};
33
+ export type PackageRequest = {
34
+ id: ContentKey;
35
+ readonly type: typeof requestTypes.package_request;
36
+ run: (arg1: RunInput<BundleInfo>) => Async<BundleInfo>;
37
+ input: PackageRequestInput;
38
+ };
40
39
 
41
40
  export function createPackageRequest(
42
41
  input: PackageRequestInput,
@@ -49,8 +48,9 @@ export function createPackageRequest(
49
48
  };
50
49
  }
51
50
 
52
- async function run({input, api, farm}) {
51
+ async function run({input, api, farm, rustAtlaspack}: RunInput<BundleInfo>) {
53
52
  let {bundleGraphReference, optionsRef, bundle, useMainThread} = input;
53
+
54
54
  let runPackage = farm.createHandle('runPackage', useMainThread);
55
55
 
56
56
  let start = Date.now();
@@ -61,6 +61,17 @@ async function run({input, api, farm}) {
61
61
  ),
62
62
  );
63
63
 
64
+ if (
65
+ getFeatureFlag('nativePackager') &&
66
+ getFeatureFlag('nativePackagerSSRDev') &&
67
+ rustAtlaspack &&
68
+ fromEnvironmentId(bundle.env).context === 'tesseract' &&
69
+ bundle.type === 'js'
70
+ ) {
71
+ // Once this actually does something, the code below will be in an `else` block (i.e. we'll only run one or the other)
72
+ await rustAtlaspack.package();
73
+ }
74
+
64
75
  let {devDepRequests, configRequests, bundleInfo, invalidations} =
65
76
  (await runPackage({
66
77
  bundle,
@@ -70,7 +81,7 @@ async function run({input, api, farm}) {
70
81
  previousDevDeps: devDeps,
71
82
  invalidDevDeps,
72
83
  previousInvalidations: api.getInvalidations(),
73
- }): RunPackagerRunnerResult);
84
+ })) as RunPackagerRunnerResult;
74
85
 
75
86
  for (let devDepRequest of devDepRequests) {
76
87
  await runDevDepRequest(api, devDepRequest);
@@ -93,11 +104,12 @@ async function run({input, api, farm}) {
93
104
  api.invalidateOnOptionChange(invalidation.key);
94
105
  break;
95
106
  default:
107
+ // @ts-expect-error TS2339
96
108
  throw new Error(`Unknown invalidation type: ${invalidation.type}`);
97
109
  }
98
110
  }
99
111
 
100
- // $FlowFixMe[cannot-write] time is marked read-only, but this is the exception
112
+ // @ts-expect-error TS2540
101
113
  bundleInfo.time = Date.now() - start;
102
114
 
103
115
  api.storeResult(bundleInfo);