@atlaspack/core 2.16.2-canary.21 → 2.16.2-canary.211

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 (355) hide show
  1. package/CHANGELOG.md +561 -0
  2. package/dist/AssetGraph.js +591 -0
  3. package/dist/Atlaspack.js +656 -0
  4. package/dist/AtlaspackConfig.js +324 -0
  5. package/dist/AtlaspackConfig.schema.js +108 -0
  6. package/dist/BundleGraph.js +1628 -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 +531 -0
  14. package/dist/ReporterRunner.js +151 -0
  15. package/dist/RequestTracker.js +1368 -0
  16. package/dist/SymbolPropagation.js +617 -0
  17. package/dist/TargetDescriptor.schema.js +143 -0
  18. package/dist/Transformation.js +487 -0
  19. package/dist/UncommittedAsset.js +315 -0
  20. package/dist/Validation.js +196 -0
  21. package/dist/applyRuntimes.js +305 -0
  22. package/dist/assetUtils.js +168 -0
  23. package/dist/atlaspack-v3/AtlaspackV3.js +70 -0
  24. package/dist/atlaspack-v3/NapiWorkerPool.js +57 -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 +94 -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 +76 -0
  35. package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
  36. package/dist/atlaspack-v3/worker/compat/plugin-options.js +122 -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/worker.js +292 -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 +359 -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 +429 -0
  59. package/dist/requests/AssetGraphRequestRust.js +246 -0
  60. package/dist/requests/AssetRequest.js +130 -0
  61. package/dist/requests/AtlaspackBuildRequest.js +60 -0
  62. package/dist/requests/AtlaspackConfigRequest.js +490 -0
  63. package/dist/requests/BundleGraphRequest.js +441 -0
  64. package/dist/requests/ConfigRequest.js +222 -0
  65. package/dist/requests/DevDepRequest.js +204 -0
  66. package/dist/requests/EntryRequest.js +314 -0
  67. package/dist/requests/PackageRequest.js +65 -0
  68. package/dist/requests/PathRequest.js +349 -0
  69. package/dist/requests/TargetRequest.js +1310 -0
  70. package/dist/requests/ValidationRequest.js +49 -0
  71. package/dist/requests/WriteBundleRequest.js +254 -0
  72. package/dist/requests/WriteBundlesRequest.js +165 -0
  73. package/dist/requests/asset-graph-diff.js +126 -0
  74. package/dist/requests/asset-graph-dot.js +131 -0
  75. package/dist/resolveOptions.js +268 -0
  76. package/dist/rustWorkerThreadDylibHack.js +19 -0
  77. package/dist/serializerCore.browser.js +43 -0
  78. package/dist/summarizeRequest.js +39 -0
  79. package/dist/types.js +31 -0
  80. package/dist/utils.js +172 -0
  81. package/dist/worker.js +123 -0
  82. package/lib/AssetGraph.js +111 -14
  83. package/lib/Atlaspack.js +82 -35
  84. package/lib/AtlaspackConfig.js +15 -3
  85. package/lib/AtlaspackConfig.schema.js +7 -5
  86. package/lib/BundleGraph.js +83 -30
  87. package/lib/CommittedAsset.js +6 -0
  88. package/lib/Dependency.js +8 -2
  89. package/lib/Environment.js +15 -8
  90. package/lib/EnvironmentManager.js +143 -0
  91. package/lib/IdentifierRegistry.js +1 -3
  92. package/lib/InternalConfig.js +3 -2
  93. package/lib/PackagerRunner.js +66 -23
  94. package/lib/ReporterRunner.js +6 -9
  95. package/lib/RequestTracker.js +256 -139
  96. package/lib/SymbolPropagation.js +22 -3
  97. package/lib/TargetDescriptor.schema.js +7 -1
  98. package/lib/Transformation.js +16 -9
  99. package/lib/UncommittedAsset.js +30 -9
  100. package/lib/Validation.js +18 -2
  101. package/lib/applyRuntimes.js +9 -1
  102. package/lib/assetUtils.js +7 -4
  103. package/lib/atlaspack-v3/AtlaspackV3.js +32 -7
  104. package/lib/atlaspack-v3/NapiWorkerPool.js +3 -0
  105. package/lib/atlaspack-v3/fs.js +3 -1
  106. package/lib/atlaspack-v3/index.js +28 -1
  107. package/lib/atlaspack-v3/jsCallable.js +0 -2
  108. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +7 -4
  109. package/lib/atlaspack-v3/worker/compat/bitflags.js +7 -6
  110. package/lib/atlaspack-v3/worker/compat/dependency.js +3 -0
  111. package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
  112. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +14 -9
  113. package/lib/atlaspack-v3/worker/compat/plugin-config.js +8 -10
  114. package/lib/atlaspack-v3/worker/compat/plugin-options.js +1 -0
  115. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
  116. package/lib/atlaspack-v3/worker/compat/target.js +2 -0
  117. package/lib/atlaspack-v3/worker/index.js +3 -0
  118. package/lib/atlaspack-v3/worker/worker.js +34 -6
  119. package/lib/constants.js +0 -1
  120. package/lib/dumpGraphToGraphViz.js +71 -16
  121. package/lib/index.js +45 -1
  122. package/lib/loadDotEnv.js +4 -1
  123. package/lib/projectPath.js +5 -0
  124. package/lib/public/Asset.js +21 -11
  125. package/lib/public/Bundle.js +15 -16
  126. package/lib/public/BundleGraph.js +10 -4
  127. package/lib/public/BundleGroup.js +4 -5
  128. package/lib/public/Config.js +118 -17
  129. package/lib/public/Dependency.js +8 -6
  130. package/lib/public/Environment.js +12 -7
  131. package/lib/public/MutableBundleGraph.js +54 -12
  132. package/lib/public/PluginOptions.js +2 -2
  133. package/lib/public/Symbols.js +11 -11
  134. package/lib/public/Target.js +7 -6
  135. package/lib/registerCoreWithSerializer.js +5 -3
  136. package/lib/requests/AssetGraphRequest.js +41 -4
  137. package/lib/requests/AssetGraphRequestRust.js +29 -14
  138. package/lib/requests/AssetRequest.js +23 -6
  139. package/lib/requests/AtlaspackBuildRequest.js +6 -2
  140. package/lib/requests/AtlaspackConfigRequest.js +12 -11
  141. package/lib/requests/BundleGraphRequest.js +29 -18
  142. package/lib/requests/ConfigRequest.js +28 -4
  143. package/lib/requests/DevDepRequest.js +31 -5
  144. package/lib/requests/EntryRequest.js +2 -0
  145. package/lib/requests/PackageRequest.js +7 -2
  146. package/lib/requests/PathRequest.js +24 -3
  147. package/lib/requests/TargetRequest.js +120 -56
  148. package/lib/requests/ValidationRequest.js +5 -1
  149. package/lib/requests/WriteBundleRequest.js +39 -11
  150. package/lib/requests/WriteBundlesRequest.js +24 -2
  151. package/lib/requests/asset-graph-diff.js +8 -3
  152. package/lib/requests/asset-graph-dot.js +1 -7
  153. package/lib/resolveOptions.js +36 -10
  154. package/lib/rustWorkerThreadDylibHack.js +0 -1
  155. package/lib/types/AssetGraph.d.ts +80 -0
  156. package/lib/types/Atlaspack.d.ts +52 -0
  157. package/lib/types/AtlaspackConfig.d.ts +65 -0
  158. package/lib/types/AtlaspackConfig.schema.d.ts +46 -0
  159. package/lib/types/BundleGraph.d.ts +182 -0
  160. package/lib/types/CommittedAsset.d.ts +23 -0
  161. package/lib/types/Dependency.d.ts +44 -0
  162. package/lib/types/Environment.d.ts +11 -0
  163. package/lib/types/EnvironmentManager.d.ts +37 -0
  164. package/lib/types/IdentifierRegistry.d.ts +6 -0
  165. package/lib/types/InternalConfig.d.ts +24 -0
  166. package/lib/types/PackagerRunner.d.ts +80 -0
  167. package/lib/types/ReporterRunner.d.ts +25 -0
  168. package/lib/types/RequestTracker.d.ts +385 -0
  169. package/lib/types/SymbolPropagation.d.ts +11 -0
  170. package/lib/types/TargetDescriptor.schema.d.ts +5 -0
  171. package/lib/types/Transformation.d.ts +72 -0
  172. package/lib/types/UncommittedAsset.d.ts +61 -0
  173. package/lib/types/Validation.d.ts +37 -0
  174. package/lib/types/applyRuntimes.d.ts +25 -0
  175. package/lib/types/assetUtils.d.ts +42 -0
  176. package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +26 -0
  177. package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +12 -0
  178. package/lib/types/atlaspack-v3/fs.d.ts +12 -0
  179. package/lib/types/atlaspack-v3/index.d.ts +5 -0
  180. package/lib/types/atlaspack-v3/jsCallable.d.ts +1 -0
  181. package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
  182. package/lib/types/atlaspack-v3/worker/compat/bitflags.d.ts +15 -0
  183. package/lib/types/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
  184. package/lib/types/atlaspack-v3/worker/compat/environment.d.ts +27 -0
  185. package/{src/atlaspack-v3/worker/compat/index.js → lib/types/atlaspack-v3/worker/compat/index.d.ts} +0 -1
  186. package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
  187. package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +37 -0
  188. package/lib/types/atlaspack-v3/worker/compat/plugin-logger.d.ts +9 -0
  189. package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +22 -0
  190. package/lib/types/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
  191. package/lib/types/atlaspack-v3/worker/compat/target.d.ts +11 -0
  192. package/lib/types/atlaspack-v3/worker/worker.d.ts +58 -0
  193. package/lib/types/constants.d.ts +13 -0
  194. package/lib/types/dumpGraphToGraphViz.d.ts +10 -0
  195. package/lib/types/index.d.ts +8 -0
  196. package/lib/types/loadAtlaspackPlugin.d.ts +8 -0
  197. package/lib/types/loadDotEnv.d.ts +3 -0
  198. package/lib/types/projectPath.d.ts +19 -0
  199. package/lib/types/public/Asset.d.ts +74 -0
  200. package/lib/types/public/Bundle.d.ts +45 -0
  201. package/lib/types/public/BundleGraph.d.ts +70 -0
  202. package/lib/types/public/BundleGroup.d.ts +12 -0
  203. package/lib/types/public/Config.d.ts +75 -0
  204. package/lib/types/public/Dependency.d.ts +32 -0
  205. package/lib/types/public/Environment.d.ts +34 -0
  206. package/lib/types/public/MutableBundleGraph.d.ts +26 -0
  207. package/lib/types/public/PluginOptions.d.ts +25 -0
  208. package/lib/types/public/Symbols.d.ts +81 -0
  209. package/lib/types/public/Target.d.ts +16 -0
  210. package/lib/types/registerCoreWithSerializer.d.ts +2 -0
  211. package/lib/types/requests/AssetGraphRequest.d.ts +74 -0
  212. package/lib/types/requests/AssetGraphRequestRust.d.ts +21 -0
  213. package/lib/types/requests/AssetRequest.d.ts +16 -0
  214. package/lib/types/requests/AtlaspackBuildRequest.d.ts +29 -0
  215. package/lib/types/requests/AtlaspackConfigRequest.d.ts +45 -0
  216. package/lib/types/requests/BundleGraphRequest.d.ts +28 -0
  217. package/lib/types/requests/ConfigRequest.d.ts +59 -0
  218. package/lib/types/requests/DevDepRequest.d.ts +30 -0
  219. package/lib/types/requests/EntryRequest.d.ts +36 -0
  220. package/lib/types/requests/PackageRequest.d.ts +27 -0
  221. package/lib/types/requests/PathRequest.d.ts +48 -0
  222. package/lib/types/requests/TargetRequest.d.ts +48 -0
  223. package/lib/types/requests/ValidationRequest.d.ts +20 -0
  224. package/lib/types/requests/WriteBundleRequest.d.ts +28 -0
  225. package/lib/types/requests/WriteBundlesRequest.d.ts +26 -0
  226. package/lib/types/requests/asset-graph-diff.d.ts +1 -0
  227. package/lib/types/requests/asset-graph-dot.d.ts +9 -0
  228. package/lib/types/resolveOptions.d.ts +3 -0
  229. package/lib/types/rustWorkerThreadDylibHack.d.ts +9 -0
  230. package/lib/types/serializerCore.browser.d.ts +3 -0
  231. package/lib/types/summarizeRequest.d.ts +10 -0
  232. package/lib/types/types.d.ts +493 -0
  233. package/lib/types/utils.d.ts +23 -0
  234. package/lib/types/worker.d.ts +44 -0
  235. package/lib/types.js +8 -1
  236. package/lib/utils.js +17 -2
  237. package/lib/worker.js +29 -13
  238. package/package.json +24 -34
  239. package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
  240. package/src/{Atlaspack.js → Atlaspack.ts} +113 -60
  241. package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +16 -19
  242. package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
  243. package/src/{BundleGraph.js → BundleGraph.ts} +213 -133
  244. package/src/{CommittedAsset.js → CommittedAsset.ts} +14 -12
  245. package/src/{Dependency.js → Dependency.ts} +59 -42
  246. package/src/{Environment.js → Environment.ts} +24 -15
  247. package/src/EnvironmentManager.ts +154 -0
  248. package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
  249. package/src/{InternalConfig.js → InternalConfig.ts} +22 -23
  250. package/src/{PackagerRunner.js → PackagerRunner.ts} +149 -81
  251. package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
  252. package/src/{RequestTracker.js → RequestTracker.ts} +558 -336
  253. package/src/{SymbolPropagation.js → SymbolPropagation.ts} +137 -39
  254. package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
  255. package/src/{Transformation.js → Transformation.ts} +67 -61
  256. package/src/{UncommittedAsset.js → UncommittedAsset.ts} +57 -36
  257. package/src/{Validation.js → Validation.ts} +32 -17
  258. package/src/{applyRuntimes.js → applyRuntimes.ts} +35 -26
  259. package/src/{assetUtils.js → assetUtils.ts} +47 -35
  260. package/src/atlaspack-v3/AtlaspackV3.ts +122 -0
  261. package/src/atlaspack-v3/{NapiWorkerPool.js → NapiWorkerPool.ts} +10 -5
  262. package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
  263. package/src/atlaspack-v3/{index.js → index.ts} +2 -4
  264. package/src/atlaspack-v3/jsCallable.ts +14 -0
  265. package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +40 -30
  266. package/src/atlaspack-v3/worker/compat/{bitflags.js → bitflags.ts} +9 -10
  267. package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +12 -12
  268. package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
  269. package/src/atlaspack-v3/worker/compat/index.ts +9 -0
  270. package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +20 -19
  271. package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +27 -26
  272. package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
  273. package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +4 -5
  274. package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
  275. package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
  276. package/src/atlaspack-v3/worker/index.js +2 -1
  277. package/src/atlaspack-v3/worker/{worker.js → worker.ts} +94 -65
  278. package/src/{constants.js → constants.ts} +0 -3
  279. package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
  280. package/src/index.ts +18 -0
  281. package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +8 -9
  282. package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
  283. package/src/{projectPath.js → projectPath.ts} +20 -9
  284. package/src/public/{Asset.js → Asset.ts} +40 -27
  285. package/src/public/{Bundle.js → Bundle.ts} +28 -29
  286. package/src/public/{BundleGraph.js → BundleGraph.ts} +81 -50
  287. package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
  288. package/src/public/{Config.js → Config.ts} +171 -33
  289. package/src/public/{Dependency.js → Dependency.ts} +20 -17
  290. package/src/public/{Environment.js → Environment.ts} +28 -17
  291. package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
  292. package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
  293. package/src/public/{Symbols.js → Symbols.ts} +75 -36
  294. package/src/public/{Target.js → Target.ts} +10 -8
  295. package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
  296. package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +83 -48
  297. package/src/requests/{AssetGraphRequestRust.js → AssetGraphRequestRust.ts} +36 -29
  298. package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
  299. package/src/requests/{AtlaspackBuildRequest.js → AtlaspackBuildRequest.ts} +30 -31
  300. package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +58 -51
  301. package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +66 -57
  302. package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +71 -50
  303. package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +60 -35
  304. package/src/requests/{EntryRequest.js → EntryRequest.ts} +36 -31
  305. package/src/requests/{PackageRequest.js → PackageRequest.ts} +21 -21
  306. package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
  307. package/src/requests/{TargetRequest.js → TargetRequest.ts} +259 -179
  308. package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
  309. package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +77 -49
  310. package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +77 -34
  311. package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +14 -14
  312. package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
  313. package/src/{resolveOptions.js → resolveOptions.ts} +56 -24
  314. package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
  315. package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
  316. package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
  317. package/src/types.ts +647 -0
  318. package/src/{utils.js → utils.ts} +52 -21
  319. package/src/{worker.js → worker.ts} +49 -41
  320. package/test/{AssetGraph.test.js → AssetGraph.test.ts} +37 -8
  321. package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
  322. package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
  323. package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +3 -15
  324. package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
  325. package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
  326. package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
  327. package/test/Environment.test.ts +153 -0
  328. package/test/EnvironmentManager.test.ts +188 -0
  329. package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
  330. package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
  331. package/test/PackagerRunner.test.ts +0 -0
  332. package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
  333. package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
  334. package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
  335. package/test/PublicEnvironment.test.ts +49 -0
  336. package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
  337. package/test/{RequestTracker.test.js → RequestTracker.test.ts} +314 -59
  338. package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
  339. package/test/{TargetRequest.test.js → TargetRequest.test.ts} +54 -92
  340. package/test/public/Config.test.ts +104 -0
  341. package/test/requests/{AssetGraphRequestRust.test.js → AssetGraphRequestRust.test.ts} +163 -134
  342. package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
  343. package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
  344. package/test/{test-utils.js → test-utils.ts} +4 -11
  345. package/test/{utils.test.js → utils.test.ts} +1 -3
  346. package/tsconfig.json +57 -0
  347. package/tsconfig.tsbuildinfo +1 -0
  348. package/index.d.ts +0 -30
  349. package/src/atlaspack-v3/AtlaspackV3.js +0 -87
  350. package/src/atlaspack-v3/jsCallable.js +0 -18
  351. package/src/index.js +0 -13
  352. package/src/types.js +0 -600
  353. package/test/Environment.test.js +0 -119
  354. package/test/PackagerRunner.test.js +0 -27
  355. package/test/PublicEnvironment.test.js +0 -27
package/lib/worker.js CHANGED
@@ -77,15 +77,13 @@ require("@atlaspack/cache");
77
77
  require("@atlaspack/package-manager");
78
78
  require("@atlaspack/fs");
79
79
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
80
+ // @ts-expect-error TS2305
81
+
80
82
  // register with serializer
81
- // $FlowFixMe
82
- if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
83
- /* eslint-disable import/no-extraneous-dependencies, monorepo/no-internal-import */
84
- require('@atlaspack/repl/src/atlaspack/BrowserPackageManager.js');
85
- // $FlowFixMe
86
- require('@atlaspack/repl/src/atlaspack/ExtendedMemoryFS.js');
87
- /* eslint-enable import/no-extraneous-dependencies, monorepo/no-internal-import */
88
- }
83
+
84
+ // flow-to-ts helpers
85
+
86
+ // /flow-to-ts helpers
89
87
 
90
88
  (0, _registerCoreWithSerializer.registerCoreWithSerializer)();
91
89
 
@@ -94,11 +92,8 @@ if (process.env.ATLASPACK_BUILD_REPL && process.browser) {
94
92
  // TODO: this should eventually be replaced by an in memory cache layer
95
93
  let atlaspackConfigCache = new Map();
96
94
  function loadOptions(ref, workerApi) {
97
- return (0, _nullthrows().default)(workerApi.getSharedReference(ref
98
- // $FlowFixMe
99
- ));
95
+ return (0, _nullthrows().default)(workerApi.getSharedReference(ref));
100
96
  }
101
-
102
97
  async function loadConfig(cachePath, options) {
103
98
  let config = atlaspackConfigCache.get(cachePath);
104
99
  if (config && config.options === options) {
@@ -125,6 +120,7 @@ async function runTransform(workerApi, opts) {
125
120
  return new _Transformation.default({
126
121
  workerApi,
127
122
  options,
123
+ // @ts-expect-error TS2783
128
124
  config,
129
125
  ...rest
130
126
  }).run();
@@ -139,8 +135,10 @@ async function runValidate(workerApi, opts) {
139
135
  let config = await loadConfig(configCachePath, options);
140
136
  return new _Validation.default({
141
137
  workerApi,
138
+ // @ts-expect-error TS2783
142
139
  report: _ReporterRunner.reportWorker.bind(null, workerApi),
143
140
  options,
141
+ // @ts-expect-error TS2783
144
142
  config,
145
143
  ...rest
146
144
  }).run();
@@ -161,6 +159,7 @@ async function runPackage(workerApi, {
161
159
  let runner = new _PackagerRunner.default({
162
160
  config: atlaspackConfig,
163
161
  options,
162
+ // @ts-expect-error TS2322
164
163
  report: _workers().default.isWorker() ? _ReporterRunner.reportWorker.bind(null, workerApi) : _ReporterRunner.report,
165
164
  previousDevDeps,
166
165
  previousInvalidations
@@ -172,7 +171,24 @@ async function childInit() {
172
171
  await (_rust().init === null || _rust().init === void 0 ? void 0 : (0, _rust().init)());
173
172
  }
174
173
  const PKG_RE = /node_modules[/\\]((?:@[^/\\]+[/\\][^/\\]+)|[^/\\]+)(?!.*[/\\]node_modules[/\\])/;
175
- function invalidateRequireCache() {
174
+ function invalidateRequireCache(workerApi, file) {
175
+ if (process.env.ATLASPACK_BUILD_ENV === 'test') {
176
+ // Delete this module and all children in the same node_modules folder
177
+ let module = require.cache[file];
178
+ if (module) {
179
+ var _file$match;
180
+ delete require.cache[file];
181
+ let pkg = (_file$match = file.match(PKG_RE)) === null || _file$match === void 0 ? void 0 : _file$match[1];
182
+ for (let child of module.children) {
183
+ var _child$id$match;
184
+ if (pkg === ((_child$id$match = child.id.match(PKG_RE)) === null || _child$id$match === void 0 ? void 0 : _child$id$match[1])) {
185
+ invalidateRequireCache(workerApi, child.id);
186
+ }
187
+ }
188
+ }
189
+ atlaspackConfigCache.clear();
190
+ return;
191
+ }
176
192
  throw new Error('invalidateRequireCache is only for tests');
177
193
  }
178
194
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.16.2-canary.21+3a3e8e7be",
3
+ "version": "2.16.2-canary.211+236e54658",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,33 +9,34 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/index.js",
13
- "types": "index.d.ts",
14
- "source": "src/index.js",
12
+ "main": "./lib/index.js",
13
+ "source": "./src/index.ts",
14
+ "types": "./lib/types/index.d.ts",
15
15
  "engines": {
16
16
  "node": ">= 16.0.0"
17
17
  },
18
18
  "scripts": {
19
19
  "test": "mocha",
20
20
  "test-ci": "mocha",
21
- "check-ts": "tsc --noEmit index.d.ts"
21
+ "generate-ts": "tsc --emitDeclarationOnly",
22
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
22
23
  },
23
24
  "dependencies": {
24
- "@atlaspack/build-cache": "2.13.3-canary.89+3a3e8e7be",
25
- "@atlaspack/cache": "3.1.1-canary.21+3a3e8e7be",
26
- "@atlaspack/diagnostic": "2.14.1-canary.89+3a3e8e7be",
27
- "@atlaspack/events": "2.14.1-canary.89+3a3e8e7be",
28
- "@atlaspack/feature-flags": "2.14.1-canary.89+3a3e8e7be",
29
- "@atlaspack/fs": "2.14.5-canary.21+3a3e8e7be",
30
- "@atlaspack/graph": "3.4.1-canary.89+3a3e8e7be",
31
- "@atlaspack/logger": "2.14.5-canary.21+3a3e8e7be",
32
- "@atlaspack/package-manager": "2.14.5-canary.21+3a3e8e7be",
33
- "@atlaspack/plugin": "2.14.5-canary.21+3a3e8e7be",
34
- "@atlaspack/profiler": "2.14.1-canary.89+3a3e8e7be",
35
- "@atlaspack/rust": "3.2.1-canary.21+3a3e8e7be",
36
- "@atlaspack/types": "2.14.5-canary.21+3a3e8e7be",
37
- "@atlaspack/utils": "2.14.5-canary.21+3a3e8e7be",
38
- "@atlaspack/workers": "2.14.5-canary.21+3a3e8e7be",
25
+ "@atlaspack/build-cache": "2.13.3-canary.279+236e54658",
26
+ "@atlaspack/cache": "3.1.1-canary.211+236e54658",
27
+ "@atlaspack/diagnostic": "2.14.1-canary.279+236e54658",
28
+ "@atlaspack/events": "2.14.1-canary.279+236e54658",
29
+ "@atlaspack/feature-flags": "2.14.1-canary.279+236e54658",
30
+ "@atlaspack/fs": "2.14.5-canary.211+236e54658",
31
+ "@atlaspack/graph": "3.4.1-canary.279+236e54658",
32
+ "@atlaspack/logger": "2.14.5-canary.211+236e54658",
33
+ "@atlaspack/package-manager": "2.14.5-canary.211+236e54658",
34
+ "@atlaspack/plugin": "2.14.5-canary.211+236e54658",
35
+ "@atlaspack/profiler": "2.14.1-canary.279+236e54658",
36
+ "@atlaspack/rust": "3.2.1-canary.211+236e54658",
37
+ "@atlaspack/types": "2.14.5-canary.211+236e54658",
38
+ "@atlaspack/utils": "2.14.5-canary.211+236e54658",
39
+ "@atlaspack/workers": "2.14.5-canary.211+236e54658",
39
40
  "@mischnic/json-sourcemap": "^0.1.0",
40
41
  "@parcel/source-map": "^2.1.1",
41
42
  "base-x": "^3.0.8",
@@ -49,27 +50,16 @@
49
50
  "semver": "^7.5.2"
50
51
  },
51
52
  "devDependencies": {
52
- "@atlaspack/babel-register": "2.14.1",
53
+ "@atlaspack/babel-register": "2.14.4",
53
54
  "@types/node": ">= 18",
54
55
  "graphviz": "^0.0.9",
55
56
  "jest-diff": "*",
56
57
  "rfdc": "1",
57
58
  "tempy": "^0.2.1"
58
59
  },
59
- "exports": {
60
- "./*": "./*",
61
- ".": {
62
- "types": "./index.d.ts",
63
- "default": "./lib/index.js"
64
- },
65
- "./worker": {
66
- "@atlaspack::sources": "./src/worker.js",
67
- "default": "./lib/worker.js"
68
- }
69
- },
70
60
  "browser": {
71
61
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
72
62
  },
73
63
  "type": "commonjs",
74
- "gitHead": "3a3e8e7be9e2dffd7304436d792f0f595d59665a"
75
- }
64
+ "gitHead": "236e5465863dca6044a7191e05260a5b924c342e"
65
+ }
@@ -1,5 +1,3 @@
1
- // @flow strict-local
2
-
3
1
  import type {GraphVisitor} from '@atlaspack/types';
4
2
  import type {
5
3
  ContentGraphOpts,
@@ -28,23 +26,31 @@ import {hashObject} from '@atlaspack/utils';
28
26
  import nullthrows from 'nullthrows';
29
27
  import {ContentGraph} from '@atlaspack/graph';
30
28
  import {createDependency} from './Dependency';
31
- import {type ProjectPath, fromProjectPathRelative} from './projectPath';
32
-
33
- type InitOpts = {|
34
- entries?: Array<ProjectPath>,
35
- targets?: Array<Target>,
36
- assetGroups?: Array<AssetGroup>,
37
- |};
38
-
39
- type AssetGraphOpts = {|
40
- ...ContentGraphOpts<AssetGraphNode>,
41
- hash?: ?string,
42
- |};
43
-
44
- type SerializedAssetGraph = {|
45
- ...SerializedContentGraph<AssetGraphNode>,
46
- hash?: ?string,
47
- |};
29
+ import {ProjectPath, fromProjectPathRelative} from './projectPath';
30
+ import {
31
+ fromEnvironmentId,
32
+ toEnvironmentId,
33
+ toEnvironmentRef,
34
+ } from './EnvironmentManager';
35
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
36
+
37
+ type InitOpts = {
38
+ entries?: Array<ProjectPath>;
39
+ targets?: Array<Target>;
40
+ assetGroups?: Array<AssetGroup>;
41
+ };
42
+
43
+ type AssetGraphOpts = ContentGraphOpts<AssetGraphNode> & {
44
+ bundlingVersion?: number;
45
+ disableIncrementalBundling?: boolean;
46
+ hash?: string | null | undefined;
47
+ };
48
+
49
+ type SerializedAssetGraph = SerializedContentGraph<AssetGraphNode> & {
50
+ bundlingVersion: number;
51
+ disableIncrementalBundling: boolean;
52
+ hash?: string | null | undefined;
53
+ };
48
54
 
49
55
  export function nodeFromDep(dep: Dependency): DependencyNode {
50
56
  return {
@@ -64,8 +70,10 @@ export function nodeFromDep(dep: Dependency): DependencyNode {
64
70
  export function nodeFromAssetGroup(assetGroup: AssetGroup): AssetGroupNode {
65
71
  return {
66
72
  id: hashString(
73
+ // @ts-expect-error TS2345
67
74
  fromProjectPathRelative(assetGroup.filePath) +
68
- assetGroup.env.id +
75
+ // @ts-expect-error TS2345
76
+ toEnvironmentId(assetGroup.env) +
69
77
  String(assetGroup.isSource) +
70
78
  String(assetGroup.sideEffects) +
71
79
  (assetGroup.code ?? '') +
@@ -107,18 +115,36 @@ export function nodeFromEntryFile(entry: Entry): EntryFileNode {
107
115
  };
108
116
  }
109
117
 
118
+ // @ts-expect-error TS2417
110
119
  export default class AssetGraph extends ContentGraph<AssetGraphNode> {
111
- onNodeRemoved: ?(nodeId: NodeId) => mixed;
112
- hash: ?string;
120
+ onNodeRemoved: ((nodeId: NodeId) => unknown) | null | undefined;
121
+ hash: string | null | undefined;
113
122
  envCache: Map<string, Environment>;
123
+
124
+ /**
125
+ * Incremented when the asset graph is modified such that it requires a bundling pass.
126
+ */
127
+ #bundlingVersion: number = 0;
128
+ /**
129
+ * Force incremental bundling to be disabled.
130
+ */
131
+ #disableIncrementalBundling: boolean = false;
132
+
133
+ /**
134
+ * @deprecated
135
+ */
114
136
  safeToIncrementallyBundle: boolean = true;
137
+
115
138
  undeferredDependencies: Set<Dependency>;
116
139
 
117
- constructor(opts: ?AssetGraphOpts) {
140
+ constructor(opts?: AssetGraphOpts | null) {
118
141
  if (opts) {
119
- let {hash, ...rest} = opts;
142
+ let {hash, bundlingVersion, disableIncrementalBundling, ...rest} = opts;
143
+ // @ts-expect-error TS2345
120
144
  super(rest);
121
145
  this.hash = hash;
146
+ this.#bundlingVersion = bundlingVersion ?? 0;
147
+ this.#disableIncrementalBundling = disableIncrementalBundling ?? false;
122
148
  } else {
123
149
  super();
124
150
  this.setRootNodeId(
@@ -134,34 +160,94 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
134
160
  this.envCache = new Map();
135
161
  }
136
162
 
137
- // $FlowFixMe[prop-missing]
138
163
  static deserialize(opts: AssetGraphOpts): AssetGraph {
139
164
  return new AssetGraph(opts);
140
165
  }
141
166
 
142
- // $FlowFixMe[prop-missing]
143
167
  serialize(): SerializedAssetGraph {
144
168
  return {
145
169
  ...super.serialize(),
170
+ bundlingVersion: this.#bundlingVersion,
171
+ disableIncrementalBundling: this.#disableIncrementalBundling,
146
172
  hash: this.hash,
147
173
  };
148
174
  }
149
175
 
176
+ /**
177
+ * Force incremental bundling to be disabled.
178
+ */
179
+ setDisableIncrementalBundling(disable: boolean) {
180
+ this.#disableIncrementalBundling = disable;
181
+ }
182
+
183
+ testing_getDisableIncrementalBundling(): boolean {
184
+ return this.#disableIncrementalBundling;
185
+ }
186
+
187
+ /**
188
+ * Make sure this asset graph is marked as needing a full bundling pass.
189
+ */
190
+ setNeedsBundling() {
191
+ if (!getFeatureFlag('incrementalBundlingVersioning')) {
192
+ // In legacy mode, we rely solely on safeToIncrementallyBundle to
193
+ // invalidate incremental bundling, so we skip bumping the version.
194
+ return;
195
+ }
196
+ this.#bundlingVersion += 1;
197
+ }
198
+
199
+ /**
200
+ * Get the current bundling version.
201
+ *
202
+ * Each bundle pass should keep this version around. Whenever an asset graph has a new version,
203
+ * bundling should be re-run.
204
+ */
205
+ getBundlingVersion(): number {
206
+ if (!getFeatureFlag('incrementalBundlingVersioning')) {
207
+ return 0;
208
+ }
209
+ return this.#bundlingVersion;
210
+ }
211
+
212
+ /**
213
+ * If the `bundlingVersion` has not changed since the last bundling pass,
214
+ * we can incrementally bundle, which will not require a full bundling pass
215
+ * but just update assets into the bundle graph output.
216
+ */
217
+ canIncrementallyBundle(lastVersion: number): boolean {
218
+ if (!getFeatureFlag('incrementalBundlingVersioning')) {
219
+ return (
220
+ this.safeToIncrementallyBundle && !this.#disableIncrementalBundling
221
+ );
222
+ }
223
+ return (
224
+ this.safeToIncrementallyBundle &&
225
+ this.#bundlingVersion === lastVersion &&
226
+ !this.#disableIncrementalBundling
227
+ );
228
+ }
229
+
150
230
  // Deduplicates Environments by making them referentially equal
151
231
  normalizeEnvironment(input: Asset | Dependency | AssetGroup) {
152
- let {id, context} = input.env;
232
+ if (getFeatureFlag('environmentDeduplication')) {
233
+ return;
234
+ }
235
+
236
+ // @ts-expect-error TS2345
237
+ let {id, context} = fromEnvironmentId(input.env);
153
238
  let idAndContext = `${id}-${context}`;
154
239
 
155
240
  let env = this.envCache.get(idAndContext);
156
241
  if (env) {
157
- input.env = env;
242
+ input.env = toEnvironmentRef(env);
158
243
  } else {
159
- this.envCache.set(idAndContext, input.env);
244
+ // @ts-expect-error TS2345
245
+ this.envCache.set(idAndContext, fromEnvironmentId(input.env));
160
246
  }
161
247
  }
162
248
 
163
249
  setRootConnections({entries, assetGroups}: InitOpts) {
164
- let nodes = [];
250
+ let nodes: Array<AssetGroupNode | EntrySpecifierNode> = [];
165
251
  if (entries) {
166
252
  for (let entry of entries) {
167
253
  let node = nodeFromEntrySpecifier(entry);
@@ -185,8 +271,6 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
185
271
  let existing = this.getNodeByContentKey(node.id);
186
272
  if (existing != null) {
187
273
  invariant(existing.type === node.type);
188
- // $FlowFixMe[incompatible-type] Checked above
189
- // $FlowFixMe[prop-missing]
190
274
  existing.value = node.value;
191
275
  let existingId = this.getNodeIdByContentKey(node.id);
192
276
  this.updateNode(existingId, existing);
@@ -235,13 +319,14 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
235
319
  env: target.env,
236
320
  isEntry: true,
237
321
  needsStableName: true,
238
- symbols: target.env.isLibrary
322
+ // @ts-expect-error TS2322
323
+ symbols: fromEnvironmentId(target.env).isLibrary
239
324
  ? new Map([['*', {local: '*', isWeak: true, loc: null}]])
240
325
  : undefined,
241
326
  }),
242
327
  );
243
328
 
244
- if (node.value.env.isLibrary) {
329
+ if (fromEnvironmentId(node.value.env).isLibrary) {
245
330
  // in library mode, all of the entry's symbols are "used"
246
331
  node.usedSymbolsDown.add('*');
247
332
  node.usedSymbolsUp.set('*', undefined);
@@ -262,7 +347,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
262
347
 
263
348
  resolveDependency(
264
349
  dependency: Dependency,
265
- assetGroup: ?AssetGroup,
350
+ assetGroup: AssetGroup | null | undefined,
266
351
  correspondingRequest: string,
267
352
  ) {
268
353
  let depNodeId = this.getNodeIdByContentKey(dependency.id);
@@ -344,9 +429,11 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
344
429
  let hasDeferred = this.getNodeIdsConnectedFrom(traversedNodeId).some(
345
430
  (childNodeId) => {
346
431
  let childNode = nullthrows(this.getNode(childNodeId));
432
+ // @ts-expect-error TS2339
347
433
  return childNode.hasDeferred == null
348
434
  ? false
349
- : childNode.hasDeferred;
435
+ : // @ts-expect-error TS2339
436
+ childNode.hasDeferred;
350
437
  },
351
438
  );
352
439
  if (!hasDeferred) {
@@ -357,13 +444,16 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
357
444
  traversedNode.type === 'asset_group' &&
358
445
  nodeId !== traversedNodeId
359
446
  ) {
447
+ // @ts-expect-error TS2339
360
448
  if (!ctx?.hasDeferred) {
361
449
  this.safeToIncrementallyBundle = false;
450
+ this.setNeedsBundling();
362
451
  delete traversedNode.hasDeferred;
363
452
  }
364
453
  actions.skipChildren();
365
454
  } else if (traversedNode.type === 'dependency') {
366
455
  this.safeToIncrementallyBundle = false;
456
+ this.setNeedsBundling();
367
457
  traversedNode.hasDeferred = false;
368
458
  } else if (nodeId !== traversedNodeId) {
369
459
  actions.skipChildren();
@@ -378,7 +468,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
378
468
  // a huge number of functions since we can avoid even transforming the files that aren't used.
379
469
  shouldDeferDependency(
380
470
  dependency: Dependency,
381
- sideEffects: ?boolean,
471
+ sideEffects: boolean | null | undefined,
382
472
  canDefer: boolean,
383
473
  ): boolean {
384
474
  let dependencySymbols = dependency.symbols;
@@ -389,7 +479,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
389
479
  }
390
480
 
391
481
  let isDeferrable =
392
- [...dependencySymbols].every(([, {isWeak}]) => isWeak) &&
482
+ [...dependencySymbols].every(([, {isWeak}]: [any, any]) => isWeak) &&
393
483
  sideEffects === false &&
394
484
  canDefer &&
395
485
  !dependencySymbols.has('*');
@@ -404,7 +494,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
404
494
 
405
495
  let assets = this.getNodeIdsConnectedTo(depNodeId);
406
496
  let symbols = new Map(
407
- [...dependencySymbols].map(([key, val]) => [val.local, key]),
497
+ [...dependencySymbols].map(([key, val]: [any, any]) => [val.local, key]),
408
498
  );
409
499
  invariant(assets.length === 1);
410
500
  let firstAsset = nullthrows(this.getNode(assets[0]));
@@ -428,7 +518,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
428
518
 
429
519
  let depIsDeferrable =
430
520
  d.symbols &&
431
- !(d.env.isLibrary && d.isEntry) &&
521
+ !(fromEnvironmentId(d.env).isLibrary && d.isEntry) &&
432
522
  !d.symbols.has('*') &&
433
523
  ![...d.symbols.keys()].some((symbol) => {
434
524
  let assetSymbol = resolvedAsset.symbols?.get(symbol)?.local;
@@ -450,6 +540,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
450
540
  ) {
451
541
  this.normalizeEnvironment(assetGroup);
452
542
  let assetGroupNode = nodeFromAssetGroup(assetGroup);
543
+ // @ts-expect-error TS2322
453
544
  assetGroupNode = this.getNodeByContentKey(assetGroupNode.id);
454
545
  if (!assetGroupNode) {
455
546
  return;
@@ -473,16 +564,16 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
473
564
  }
474
565
  }
475
566
 
476
- let assetObjects: Array<{|
477
- assetNodeId: NodeId,
478
- dependentAssets: Array<Asset>,
479
- |}> = [];
480
- let assetNodeIds = [];
567
+ let assetObjects: Array<{
568
+ assetNodeId: NodeId;
569
+ dependentAssets: Array<Asset>;
570
+ }> = [];
571
+ let assetNodeIds: Array<NodeId> = [];
481
572
  for (let asset of assets) {
482
573
  this.normalizeEnvironment(asset);
483
574
  let isDirect = !dependentAssetKeys.has(asset.uniqueKey);
484
575
 
485
- let dependentAssets = [];
576
+ let dependentAssets: Array<Asset> = [];
486
577
  for (let dep of asset.dependencies.values()) {
487
578
  let dependentAsset = assetsByKey.get(dep.specifier);
488
579
  if (dependentAsset) {
@@ -519,7 +610,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
519
610
 
520
611
  resolveAsset(assetNode: AssetNode, dependentAssets: Array<Asset>) {
521
612
  let depNodeIds: Array<NodeId> = [];
522
- let depNodesWithAssets = [];
613
+ let depNodesWithAssets: Array<Array<AssetNode | DependencyNode>> = [];
523
614
  for (let dep of assetNode.value.dependencies.values()) {
524
615
  this.normalizeEnvironment(dep);
525
616
  let depNode = nodeFromDep(dep);
@@ -532,6 +623,19 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
532
623
  ...depNode.value.meta,
533
624
  ...existing.value.resolverMeta,
534
625
  };
626
+
627
+ if (getFeatureFlag('hmrImprovements')) {
628
+ depNode.value.resolverMeta = existing.value.resolverMeta;
629
+ }
630
+ }
631
+ if (getFeatureFlag('hmrImprovements')) {
632
+ if (
633
+ existing?.type === 'dependency' &&
634
+ existing.value.resolverPriority != null
635
+ ) {
636
+ depNode.value.priority = existing.value.resolverPriority;
637
+ depNode.value.resolverPriority = existing.value.resolverPriority;
638
+ }
535
639
  }
536
640
  let dependentAsset = dependentAssets.find(
537
641
  (a) => a.uniqueKey === dep.specifier,
@@ -563,7 +667,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
563
667
  getIncomingDependencies(asset: Asset): Array<Dependency> {
564
668
  let nodeId = this.getNodeIdByContentKey(asset.id);
565
669
  let assetGroupIds = this.getNodeIdsConnectedTo(nodeId);
566
- let dependencies = [];
670
+ let dependencies: Array<Dependency> = [];
567
671
  for (let i = 0; i < assetGroupIds.length; i++) {
568
672
  let assetGroupId = assetGroupIds[i];
569
673
 
@@ -592,8 +696,8 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
592
696
 
593
697
  traverseAssets<TContext>(
594
698
  visit: GraphVisitor<Asset, TContext>,
595
- startNodeId: ?NodeId,
596
- ): ?TContext {
699
+ startNodeId?: NodeId | null,
700
+ ): TContext | null | undefined {
597
701
  return this.filteredTraverse(
598
702
  (nodeId) => {
599
703
  let node = nullthrows(this.getNode(nodeId));
@@ -605,7 +709,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
605
709
  }
606
710
 
607
711
  getEntryAssetGroupNodes(): Array<AssetGroupNode> {
608
- let entryNodes = [];
712
+ let entryNodes: Array<AssetGroupNode> = [];
609
713
  this.traverse((nodeId, _, actions) => {
610
714
  let node = nullthrows(this.getNode(nodeId));
611
715
  if (node.type === 'asset_group') {
@@ -617,7 +721,7 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
617
721
  }
618
722
 
619
723
  getEntryAssets(): Array<Asset> {
620
- let entries = [];
724
+ let entries: Array<Asset> = [];
621
725
  this.traverseAssets((asset, ctx, traversal) => {
622
726
  entries.push(asset);
623
727
  traversal.skipChildren();