@atlaspack/core 2.16.2-canary.27 → 2.16.2-canary.270

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 (358) hide show
  1. package/CHANGELOG.md +665 -0
  2. package/dist/AssetGraph.js +591 -0
  3. package/dist/Atlaspack.js +658 -0
  4. package/dist/AtlaspackConfig.js +324 -0
  5. package/dist/AtlaspackConfig.schema.js +108 -0
  6. package/dist/BundleGraph.js +1635 -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 +490 -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 +297 -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 +262 -0
  60. package/dist/requests/AssetRequest.js +130 -0
  61. package/dist/requests/AtlaspackBuildRequest.js +65 -0
  62. package/dist/requests/AtlaspackConfigRequest.js +493 -0
  63. package/dist/requests/BundleGraphRequest.js +445 -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 +62 -0
  68. package/dist/requests/PathRequest.js +349 -0
  69. package/dist/requests/TargetRequest.js +1311 -0
  70. package/dist/requests/ValidationRequest.js +49 -0
  71. package/dist/requests/WriteBundleRequest.js +254 -0
  72. package/dist/requests/WriteBundlesRequest.js +184 -0
  73. package/dist/requests/asset-graph-diff.js +128 -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 +81 -37
  84. package/lib/AtlaspackConfig.js +15 -3
  85. package/lib/AtlaspackConfig.schema.js +7 -5
  86. package/lib/BundleGraph.js +90 -32
  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 +90 -27
  94. package/lib/ReporterRunner.js +6 -9
  95. package/lib/RequestTracker.js +266 -156
  96. package/lib/SymbolPropagation.js +42 -18
  97. package/lib/TargetDescriptor.schema.js +7 -1
  98. package/lib/Transformation.js +26 -10
  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 +43 -7
  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 +42 -5
  137. package/lib/requests/AssetGraphRequestRust.js +126 -62
  138. package/lib/requests/AssetRequest.js +23 -6
  139. package/lib/requests/AtlaspackBuildRequest.js +10 -4
  140. package/lib/requests/AtlaspackConfigRequest.js +27 -16
  141. package/lib/requests/BundleGraphRequest.js +34 -19
  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 +2 -1
  146. package/lib/requests/PathRequest.js +24 -3
  147. package/lib/requests/TargetRequest.js +122 -57
  148. package/lib/requests/ValidationRequest.js +5 -1
  149. package/lib/requests/WriteBundleRequest.js +39 -11
  150. package/lib/requests/WriteBundlesRequest.js +51 -4
  151. package/lib/requests/asset-graph-diff.js +12 -7
  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 +85 -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 +60 -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 +33 -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 +32 -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} +114 -61
  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} +231 -140
  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} +178 -86
  251. package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
  252. package/src/{RequestTracker.js → RequestTracker.ts} +572 -357
  253. package/src/{SymbolPropagation.js → SymbolPropagation.ts} +165 -57
  254. package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
  255. package/src/{Transformation.js → Transformation.ts} +71 -62
  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} +102 -66
  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} +84 -49
  297. package/src/requests/AssetGraphRequestRust.ts +352 -0
  298. package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
  299. package/src/requests/{AtlaspackBuildRequest.js → AtlaspackBuildRequest.ts} +46 -32
  300. package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
  301. package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +71 -58
  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} +20 -22
  306. package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
  307. package/src/requests/{TargetRequest.js → TargetRequest.ts} +260 -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} +109 -37
  311. package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +25 -21
  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} +75 -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} +66 -92
  340. package/test/fixtures/config-with-reporters/.parcelrc +7 -0
  341. package/test/fixtures/custom-targets/package.json +6 -0
  342. package/test/public/Config.test.ts +104 -0
  343. package/test/requests/{AssetGraphRequestRust.test.js → AssetGraphRequestRust.test.ts} +164 -134
  344. package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
  345. package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
  346. package/test/{test-utils.js → test-utils.ts} +4 -11
  347. package/test/{utils.test.js → utils.test.ts} +1 -3
  348. package/tsconfig.json +57 -0
  349. package/tsconfig.tsbuildinfo +1 -0
  350. package/index.d.ts +0 -30
  351. package/src/atlaspack-v3/AtlaspackV3.js +0 -87
  352. package/src/atlaspack-v3/jsCallable.js +0 -18
  353. package/src/index.js +0 -13
  354. package/src/requests/AssetGraphRequestRust.js +0 -263
  355. package/src/types.js +0 -600
  356. package/test/Environment.test.js +0 -119
  357. package/test/PackagerRunner.test.js +0 -27
  358. package/test/PublicEnvironment.test.js +0 -27
@@ -1,12 +1,10 @@
1
- // @flow strict-local
2
-
3
1
  import type {
4
2
  GraphVisitor,
5
3
  FilePath,
6
- Symbol,
7
4
  TraversalActions,
8
5
  BundleBehavior as IBundleBehavior,
9
6
  ConditionMeta,
7
+ Symbol,
10
8
  } from '@atlaspack/types';
11
9
  import type {
12
10
  ContentKey,
@@ -24,7 +22,6 @@ import type {
24
22
  BundleNode,
25
23
  Dependency,
26
24
  DependencyNode,
27
- Environment,
28
25
  InternalSourceLocation,
29
26
  Target,
30
27
  Condition,
@@ -49,6 +46,8 @@ import {ISOLATED_ENVS} from './public/Environment';
49
46
  import {fromProjectPath, fromProjectPathRelative} from './projectPath';
50
47
  import {HASH_REF_PREFIX} from './constants';
51
48
  import {getFeatureFlag} from '@atlaspack/feature-flags';
49
+ import {fromEnvironmentId} from './EnvironmentManager';
50
+ import type {EnvironmentRef} from './EnvironmentManager';
52
51
 
53
52
  export const bundleGraphEdgeTypes = {
54
53
  // A lack of an edge type indicates to follow the edge while traversing
@@ -76,46 +75,46 @@ export const bundleGraphEdgeTypes = {
76
75
  // This type is used to mark an edge between a bundle and a conditional bundle.
77
76
  // This allows efficient discovery of conditional bundles in packaging
78
77
  conditional: 5,
78
+ } as const;
79
+
80
+ export type BundleGraphEdgeType =
81
+ (typeof bundleGraphEdgeTypes)[keyof typeof bundleGraphEdgeTypes];
82
+
83
+ type InternalSymbolResolution = {
84
+ asset: Asset;
85
+ exportSymbol: string;
86
+ symbol: Symbol | null | undefined | false;
87
+ loc: InternalSourceLocation | null | undefined;
88
+ };
89
+
90
+ type InternalExportSymbolResolution = InternalSymbolResolution & {
91
+ readonly exportAs: Symbol | string;
92
+ };
93
+
94
+ type BundleGraphOpts = {
95
+ graph: ContentGraphOpts<BundleGraphNode, BundleGraphEdgeType>;
96
+ bundleContentHashes: Map<string, string>;
97
+ assetPublicIds: Set<string>;
98
+ publicIdByAssetId: Map<string, string>;
99
+ conditions: Map<string, Condition>;
79
100
  };
80
101
 
81
- export type BundleGraphEdgeType = $Values<typeof bundleGraphEdgeTypes>;
82
-
83
- type InternalSymbolResolution = {|
84
- asset: Asset,
85
- exportSymbol: string,
86
- symbol: ?Symbol | false,
87
- loc: ?InternalSourceLocation,
88
- |};
89
-
90
- type InternalExportSymbolResolution = {|
91
- ...InternalSymbolResolution,
92
- +exportAs: Symbol | string,
93
- |};
94
-
95
- type BundleGraphOpts = {|
96
- graph: ContentGraphOpts<BundleGraphNode, BundleGraphEdgeType>,
97
- bundleContentHashes: Map<string, string>,
98
- assetPublicIds: Set<string>,
99
- publicIdByAssetId: Map<string, string>,
100
- conditions: Map<string, Condition>,
101
- |};
102
-
103
- type SerializedBundleGraph = {|
104
- $$raw: true,
105
- graph: SerializedContentGraph<BundleGraphNode, BundleGraphEdgeType>,
106
- bundleContentHashes: Map<string, string>,
107
- assetPublicIds: Set<string>,
108
- publicIdByAssetId: Map<string, string>,
109
- conditions: Map<string, Condition>,
110
- |};
111
-
112
- function makeReadOnlySet<T>(set: Set<T>): $ReadOnlySet<T> {
102
+ type SerializedBundleGraph = {
103
+ $$raw: true;
104
+ graph: SerializedContentGraph<BundleGraphNode, BundleGraphEdgeType>;
105
+ bundleContentHashes: Map<string, string>;
106
+ assetPublicIds: Set<string>;
107
+ publicIdByAssetId: Map<string, string>;
108
+ conditions: Map<string, Condition>;
109
+ };
110
+
111
+ function makeReadOnlySet<T>(set: Set<T>): ReadonlySet<T> {
113
112
  return new Proxy(set, {
114
- get(target, property) {
113
+ get(target: Set<T>, property: string) {
115
114
  if (property === 'delete' || property === 'add' || property === 'clear') {
116
115
  return undefined;
117
116
  } else {
118
- // $FlowFixMe[incompatible-type]
117
+ // @ts-expect-error TS7053
119
118
  let value = target[property];
120
119
  return typeof value === 'function' ? value.bind(target) : value;
121
120
  }
@@ -155,13 +154,13 @@ export default class BundleGraph {
155
154
  assetPublicIds,
156
155
  bundleContentHashes,
157
156
  conditions,
158
- }: {|
159
- graph: ContentGraph<BundleGraphNode, BundleGraphEdgeType>,
160
- publicIdByAssetId: Map<string, string>,
161
- assetPublicIds: Set<string>,
162
- bundleContentHashes: Map<string, string>,
163
- conditions: Map<string, Condition>,
164
- |}) {
157
+ }: {
158
+ graph: ContentGraph<BundleGraphNode, BundleGraphEdgeType>;
159
+ publicIdByAssetId: Map<string, string>;
160
+ assetPublicIds: Set<string>;
161
+ bundleContentHashes: Map<string, string>;
162
+ conditions: Map<string, Condition>;
163
+ }) {
165
164
  this._graph = graph;
166
165
  this._assetPublicIds = assetPublicIds;
167
166
  this._publicIdByAssetId = publicIdByAssetId;
@@ -219,8 +218,8 @@ export default class BundleGraph {
219
218
  // code need to be mapped to the "real" dependencies, so we need access to a map of placeholders
220
219
  // to dependencies
221
220
  const dep = node.value;
222
- // $FlowFixMe[incompatible-type] Meta is untyped
223
- const placeholder: string | void = dep.meta?.placeholder;
221
+ // @ts-expect-error TS2322
222
+ const placeholder: string | undefined = dep.meta?.placeholder;
224
223
  if (placeholder != null) {
225
224
  placeholderToDependency.set(placeholder, dep);
226
225
  }
@@ -228,7 +227,7 @@ export default class BundleGraph {
228
227
  });
229
228
 
230
229
  let walkVisited = new Set();
231
- function walk(nodeId) {
230
+ function walk(nodeId: NodeId) {
232
231
  if (walkVisited.has(nodeId)) return;
233
232
  walkVisited.add(nodeId);
234
233
 
@@ -237,8 +236,7 @@ export default class BundleGraph {
237
236
  if (getFeatureFlag('conditionalBundlingApi') && node.type === 'asset') {
238
237
  const asset = node.value;
239
238
  if (Array.isArray(asset.meta.conditions)) {
240
- // $FlowFixMe
241
- for (const condition of (asset.meta.conditions: ConditionMeta[])) {
239
+ for (const condition of asset.meta.conditions as ConditionMeta[]) {
242
240
  // Resolve the placeholders that were attached to the asset in JSTransformer to dependencies,
243
241
  // as well as create a public id for the condition.
244
242
  const {
@@ -246,10 +244,9 @@ export default class BundleGraph {
246
244
  ifTruePlaceholder,
247
245
  ifFalsePlaceholder,
248
246
  }: {
249
- key: string,
250
- ifTruePlaceholder: string,
251
- ifFalsePlaceholder: string,
252
- ...
247
+ key: string;
248
+ ifTruePlaceholder: string;
249
+ ifFalsePlaceholder: string;
253
250
  } = condition;
254
251
 
255
252
  const condHash = hashString(
@@ -283,7 +280,7 @@ export default class BundleGraph {
283
280
  if (
284
281
  node.type === 'dependency' &&
285
282
  node.value.symbols != null &&
286
- node.value.env.shouldScopeHoist &&
283
+ fromEnvironmentId(node.value.env).shouldScopeHoist &&
287
284
  // Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
288
285
  isProduction
289
286
  ) {
@@ -333,7 +330,7 @@ export default class BundleGraph {
333
330
  // Don't retarget because this cannot be resolved without also changing the asset symbols
334
331
  // (and the asset content itself).
335
332
  [...targets].every(
336
- ([, t]) => new Set([...t.values()]).size === t.size,
333
+ ([, t]: [any, any]) => new Set([...t.values()]).size === t.size,
337
334
  )
338
335
  ) {
339
336
  let isReexportAll = nodeValueSymbols.get('*')?.local === '*';
@@ -351,13 +348,15 @@ export default class BundleGraph {
351
348
  value: {
352
349
  ...node.value,
353
350
  symbols: new Map(
354
- [...nodeValueSymbols].filter(([k]) =>
351
+ // @ts-expect-error TS2769
352
+ [...nodeValueSymbols].filter(([k]: [any]) =>
355
353
  externalSymbols.has(k),
356
354
  ),
357
355
  ),
358
356
  },
359
357
  usedSymbolsUp: new Map(
360
- [...node.usedSymbolsUp].filter(([k]) =>
358
+ // @ts-expect-error TS2769
359
+ [...node.usedSymbolsUp].filter(([k]: [any]) =>
361
360
  externalSymbols.has(k),
362
361
  ),
363
362
  ),
@@ -365,7 +364,7 @@ export default class BundleGraph {
365
364
  excluded: externalSymbols.size === 0,
366
365
  }),
367
366
  },
368
- ...[...targets].map(([asset, target]) => {
367
+ ...[...targets].map(([asset, target]: [any, any]) => {
369
368
  let newNodeId = hashString(
370
369
  node.id + [...target.keys()].join(','),
371
370
  );
@@ -392,17 +391,28 @@ export default class BundleGraph {
392
391
  local,
393
392
  loc: reexportAllLoc,
394
393
  });
394
+
395
395
  if (node.value.sourceAssetId != null) {
396
- let sourceAssetId = nullthrows(
397
- assetGraphNodeIdToBundleGraphNodeId.get(
398
- assetGraph.getNodeIdByContentKey(
399
- node.value.sourceAssetId,
396
+ let sourceAssetId: NodeId;
397
+
398
+ if (getFeatureFlag('sourceAssetIdBundleGraphFix')) {
399
+ [sourceAssetId] =
400
+ assetGraph.getNodeIdsConnectedTo(nodeId);
401
+ } else {
402
+ sourceAssetId = assetGraph.getNodeIdByContentKey(
403
+ node.value.sourceAssetId,
404
+ );
405
+ }
406
+
407
+ let sourceAsset = nullthrows(
408
+ graph.getNode(
409
+ nullthrows(
410
+ assetGraphNodeIdToBundleGraphNodeId.get(
411
+ sourceAssetId,
412
+ ),
400
413
  ),
401
414
  ),
402
415
  );
403
- let sourceAsset = nullthrows(
404
- graph.getNode(sourceAssetId),
405
- );
406
416
  invariant(sourceAsset.type === 'asset');
407
417
  let sourceAssetSymbols = sourceAsset.value.symbols;
408
418
  if (sourceAssetSymbols) {
@@ -421,8 +431,9 @@ export default class BundleGraph {
421
431
  }
422
432
  let usedSymbolsUp = new Map(
423
433
  [...node.usedSymbolsUp]
424
- .filter(([k]) => target.has(k) || k === '*')
425
- .map(([k, v]) => [target.get(k) ?? k, v]),
434
+ // @ts-expect-error TS2769
435
+ .filter(([k]: [any]) => target.has(k) || k === '*')
436
+ .map(([k, v]: [any, any]) => [target.get(k) ?? k, v]),
426
437
  );
427
438
  return {
428
439
  asset,
@@ -478,6 +489,7 @@ export default class BundleGraph {
478
489
  }
479
490
  walk(nullthrows(assetGraph.rootNodeId));
480
491
 
492
+ // @ts-expect-error TS2488
481
493
  for (let edge of assetGraph.getAllEdges()) {
482
494
  if (assetGroupIds.has(edge.from)) {
483
495
  continue;
@@ -502,10 +514,22 @@ export default class BundleGraph {
502
514
  continue;
503
515
  }
504
516
 
505
- let to: Array<NodeId> = dependencies.get(edge.to)?.map((v) => v.dep) ??
517
+ let to: Array<NodeId> = dependencies.get(edge.to)?.map(
518
+ (
519
+ v:
520
+ | {
521
+ asset: null;
522
+ dep: NodeId;
523
+ }
524
+ | {
525
+ asset: ContentKey;
526
+ dep: NodeId;
527
+ },
528
+ ) => v.dep,
529
+ ) ??
506
530
  assetGroupIds
507
531
  .get(edge.to)
508
- ?.map((id) =>
532
+ ?.map((id: NodeId) =>
509
533
  nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(id)),
510
534
  ) ?? [nullthrows(assetGraphNodeIdToBundleGraphNodeId.get(edge.to))];
511
535
 
@@ -549,29 +573,32 @@ export default class BundleGraph {
549
573
 
550
574
  createBundle(
551
575
  opts:
552
- | {|
553
- +entryAsset: Asset,
554
- +target: Target,
555
- +needsStableName?: ?boolean,
556
- +bundleBehavior?: ?IBundleBehavior,
557
- +shouldContentHash: boolean,
558
- +env: Environment,
559
- |}
560
- | {|
561
- +type: string,
562
- +env: Environment,
563
- +uniqueKey: string,
564
- +target: Target,
565
- +needsStableName?: ?boolean,
566
- +bundleBehavior?: ?IBundleBehavior,
567
- +isSplittable?: ?boolean,
568
- +pipeline?: ?string,
569
- +shouldContentHash: boolean,
570
- |},
576
+ | {
577
+ readonly entryAsset: Asset;
578
+ readonly bundleRoots?: Array<Asset>;
579
+ readonly target: Target;
580
+ readonly needsStableName?: boolean | null | undefined;
581
+ readonly bundleBehavior?: IBundleBehavior | null | undefined;
582
+ readonly shouldContentHash: boolean;
583
+ readonly env: EnvironmentRef;
584
+ }
585
+ | {
586
+ readonly type: string;
587
+ readonly env: EnvironmentRef;
588
+ readonly uniqueKey: string;
589
+ readonly target: Target;
590
+ readonly needsStableName?: boolean | null | undefined;
591
+ readonly bundleBehavior?: IBundleBehavior | null | undefined;
592
+ readonly isSplittable?: boolean | null | undefined;
593
+ readonly pipeline?: string | null | undefined;
594
+ readonly shouldContentHash: boolean;
595
+ },
571
596
  ): Bundle {
597
+ // @ts-expect-error TS2339
572
598
  let {entryAsset, target} = opts;
573
599
  let bundleId = hashString(
574
600
  'bundle:' +
601
+ // @ts-expect-error TS2339
575
602
  (opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) +
576
603
  fromProjectPathRelative(target.distDir) +
577
604
  (opts.bundleBehavior ?? ''),
@@ -603,19 +630,24 @@ export default class BundleGraph {
603
630
  hashReference: opts.shouldContentHash
604
631
  ? HASH_REF_PREFIX + bundleId
605
632
  : bundleId.slice(-8),
633
+ // @ts-expect-error TS2339
606
634
  type: opts.entryAsset ? opts.entryAsset.type : opts.type,
607
635
  env: opts.env,
608
636
  entryAssetIds: entryAsset ? [entryAsset.id] : [],
609
637
  mainEntryId: entryAsset?.id,
638
+ // @ts-expect-error TS2339
610
639
  pipeline: opts.entryAsset ? opts.entryAsset.pipeline : opts.pipeline,
611
640
  needsStableName: opts.needsStableName,
612
641
  bundleBehavior:
613
642
  opts.bundleBehavior != null
614
643
  ? BundleBehavior[opts.bundleBehavior]
615
644
  : null,
645
+ // @ts-expect-error TS2339
616
646
  isSplittable: opts.entryAsset
617
- ? opts.entryAsset.isBundleSplittable
618
- : opts.isSplittable,
647
+ ? // @ts-expect-error TS2339
648
+ opts.entryAsset.isBundleSplittable
649
+ : // @ts-expect-error TS2339
650
+ opts.isSplittable,
619
651
  isPlaceholder,
620
652
  target,
621
653
  name: null,
@@ -626,9 +658,11 @@ export default class BundleGraph {
626
658
 
627
659
  let bundleNodeId = this._graph.addNodeByContentKey(bundleId, bundleNode);
628
660
 
661
+ // @ts-expect-error TS2339
629
662
  if (opts.entryAsset) {
630
663
  this._graph.addEdge(
631
664
  bundleNodeId,
665
+ // @ts-expect-error TS2339
632
666
  this._graph.getNodeIdByContentKey(opts.entryAsset.id),
633
667
  );
634
668
  }
@@ -661,10 +695,13 @@ export default class BundleGraph {
661
695
  for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
662
696
  .getNodeIdsConnectedFrom(dependencyNodeId)
663
697
  .map((id) => [id, nullthrows(this._graph.getNode(id))])
664
- .filter(([, node]) => node.type === 'bundle_group')) {
698
+ // @ts-expect-error TS2769
699
+ .filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
700
+ // @ts-expect-error TS2339
665
701
  invariant(bundleGroupNode.type === 'bundle_group');
666
702
  this._graph.addEdge(
667
703
  bundleNodeId,
704
+ // @ts-expect-error TS2345
668
705
  bundleGroupNodeId,
669
706
  bundleGraphEdgeTypes.bundle,
670
707
  );
@@ -693,7 +730,7 @@ export default class BundleGraph {
693
730
  addAssetGraphToBundle(
694
731
  asset: Asset,
695
732
  bundle: Bundle,
696
- shouldSkipDependency: (Dependency) => boolean = (d) =>
733
+ shouldSkipDependency: (arg1: Dependency) => boolean = (d: Dependency) =>
697
734
  this.isDependencySkipped(d),
698
735
  ) {
699
736
  let assetNodeId = this._graph.getNodeIdByContentKey(asset.id);
@@ -726,10 +763,13 @@ export default class BundleGraph {
726
763
  for (let [bundleGroupNodeId, bundleGroupNode] of this._graph
727
764
  .getNodeIdsConnectedFrom(nodeId)
728
765
  .map((id) => [id, nullthrows(this._graph.getNode(id))])
729
- .filter(([, node]) => node.type === 'bundle_group')) {
766
+ // @ts-expect-error TS2769
767
+ .filter(([, node]: [any, any]) => node.type === 'bundle_group')) {
768
+ // @ts-expect-error TS2339
730
769
  invariant(bundleGroupNode.type === 'bundle_group');
731
770
  this._graph.addEdge(
732
771
  bundleNodeId,
772
+ // @ts-expect-error TS2345
733
773
  bundleGroupNodeId,
734
774
  bundleGraphEdgeTypes.bundle,
735
775
  );
@@ -769,7 +809,7 @@ export default class BundleGraph {
769
809
  addEntryToBundle(
770
810
  asset: Asset,
771
811
  bundle: Bundle,
772
- shouldSkipDependency?: (Dependency) => boolean,
812
+ shouldSkipDependency?: (arg1: Dependency) => boolean,
773
813
  ) {
774
814
  this.addAssetGraphToBundle(asset, bundle, shouldSkipDependency);
775
815
  if (!bundle.entryAssetIds.includes(asset.id)) {
@@ -836,11 +876,18 @@ export default class BundleGraph {
836
876
 
837
877
  resolveAsyncDependency(
838
878
  dependency: Dependency,
839
- bundle: ?Bundle,
840
- ): ?(
841
- | {|type: 'bundle_group', value: BundleGroup|}
842
- | {|type: 'asset', value: Asset|}
843
- ) {
879
+ bundle?: Bundle | null,
880
+ ):
881
+ | {
882
+ type: 'bundle_group';
883
+ value: BundleGroup;
884
+ }
885
+ | {
886
+ type: 'asset';
887
+ value: Asset;
888
+ }
889
+ | null
890
+ | undefined {
844
891
  let depNodeId = this._graph.getNodeIdByContentKey(dependency.id);
845
892
  let bundleNodeId =
846
893
  bundle != null ? this._graph.getNodeIdByContentKey(bundle.id) : null;
@@ -899,7 +946,10 @@ export default class BundleGraph {
899
946
  }
900
947
 
901
948
  // eslint-disable-next-line no-unused-vars
902
- getReferencedBundle(dependency: Dependency, fromBundle: Bundle): ?Bundle {
949
+ getReferencedBundle(
950
+ dependency: Dependency,
951
+ fromBundle: Bundle,
952
+ ): Bundle | null | undefined {
903
953
  let dependencyNodeId = this._graph.getNodeIdByContentKey(dependency.id);
904
954
 
905
955
  // Find an attached bundle via a reference edge (e.g. from createAssetReference).
@@ -931,8 +981,12 @@ export default class BundleGraph {
931
981
  return this.getBundlesInBundleGroup(node.value, {
932
982
  includeInline: true,
933
983
  }).find((b) => {
934
- let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
935
- return mainEntryId != null && node.value.entryAssetId === mainEntryId;
984
+ if (getFeatureFlag('supportWebpackChunkName')) {
985
+ return b.entryAssetIds.some((id) => id === node.value.entryAssetId);
986
+ } else {
987
+ let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
988
+ return mainEntryId != null && node.value.entryAssetId === mainEntryId;
989
+ }
936
990
  });
937
991
  }
938
992
  }
@@ -1226,7 +1280,10 @@ export default class BundleGraph {
1226
1280
  });
1227
1281
  }
1228
1282
 
1229
- getResolvedAsset(dep: Dependency, bundle: ?Bundle): ?Asset {
1283
+ getResolvedAsset(
1284
+ dep: Dependency,
1285
+ bundle?: Bundle | null,
1286
+ ): Asset | null | undefined {
1230
1287
  let assets = this.getDependencyAssets(dep);
1231
1288
  let firstAsset = assets[0];
1232
1289
  let resolved =
@@ -1240,7 +1297,7 @@ export default class BundleGraph {
1240
1297
 
1241
1298
  // If a resolution still hasn't been found, return the first referenced asset.
1242
1299
  if (resolved == null) {
1243
- let potential = [];
1300
+ let potential: Array<Asset> = [];
1244
1301
  this._graph.traverse(
1245
1302
  (nodeId, _, traversal) => {
1246
1303
  let node = nullthrows(this._graph.getNode(nodeId));
@@ -1255,6 +1312,7 @@ export default class BundleGraph {
1255
1312
  );
1256
1313
 
1257
1314
  if (bundle) {
1315
+ // @ts-expect-error TS2322
1258
1316
  resolved = potential.find((a) => a.type === bundle.type);
1259
1317
  }
1260
1318
  resolved ||= potential[0];
@@ -1276,7 +1334,7 @@ export default class BundleGraph {
1276
1334
  bundle: Bundle,
1277
1335
  visit: GraphVisitor<Asset, TContext>,
1278
1336
  startAsset?: Asset,
1279
- ): ?TContext {
1337
+ ): TContext | null | undefined {
1280
1338
  return this.traverseBundle(
1281
1339
  bundle,
1282
1340
  mapVisitor((node) => (node.type === 'asset' ? node.value : null), visit),
@@ -1359,7 +1417,8 @@ export default class BundleGraph {
1359
1417
 
1360
1418
  if (
1361
1419
  descendant.type !== bundle.type ||
1362
- descendant.env.context !== bundle.env.context
1420
+ fromEnvironmentId(descendant.env).context !==
1421
+ fromEnvironmentId(bundle.env).context
1363
1422
  ) {
1364
1423
  actions.skipChildren();
1365
1424
  return;
@@ -1400,10 +1459,11 @@ export default class BundleGraph {
1400
1459
  // If a bundle's environment is isolated, it can't access assets present
1401
1460
  // in any ancestor bundles. Don't consider any assets reachable.
1402
1461
  if (
1403
- ISOLATED_ENVS.has(bundle.env.context) ||
1462
+ ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
1404
1463
  !bundle.isSplittable ||
1405
1464
  bundle.bundleBehavior === BundleBehavior.isolated ||
1406
- bundle.bundleBehavior === BundleBehavior.inline
1465
+ bundle.bundleBehavior === BundleBehavior.inline ||
1466
+ bundle.bundleBehavior === BundleBehavior.inlineIsolated
1407
1467
  ) {
1408
1468
  return false;
1409
1469
  }
@@ -1420,6 +1480,7 @@ export default class BundleGraph {
1420
1480
  b.id !== bundle.id &&
1421
1481
  b.bundleBehavior !== BundleBehavior.isolated &&
1422
1482
  b.bundleBehavior !== BundleBehavior.inline &&
1483
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1423
1484
  this.bundleHasAsset(b, asset),
1424
1485
  )
1425
1486
  ) {
@@ -1438,7 +1499,8 @@ export default class BundleGraph {
1438
1499
  if (
1439
1500
  bundleNode.type !== 'bundle' ||
1440
1501
  bundleNode.value.bundleBehavior === BundleBehavior.isolated ||
1441
- bundleNode.value.bundleBehavior === BundleBehavior.inline
1502
+ bundleNode.value.bundleBehavior === BundleBehavior.inline ||
1503
+ bundleNode.value.bundleBehavior === BundleBehavior.inlineIsolated
1442
1504
  ) {
1443
1505
  return false;
1444
1506
  }
@@ -1454,7 +1516,8 @@ export default class BundleGraph {
1454
1516
  node.type === 'root' ||
1455
1517
  (node.type === 'bundle' &&
1456
1518
  (node.value.id === bundle.id ||
1457
- node.value.env.context !== bundle.env.context))
1519
+ fromEnvironmentId(node.value.env).context !==
1520
+ fromEnvironmentId(bundle.env).context))
1458
1521
  ) {
1459
1522
  isReachable = false;
1460
1523
  actions.stop();
@@ -1469,6 +1532,7 @@ export default class BundleGraph {
1469
1532
  b.id !== bundle.id &&
1470
1533
  b.bundleBehavior !== BundleBehavior.isolated &&
1471
1534
  b.bundleBehavior !== BundleBehavior.inline &&
1535
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1472
1536
  this.bundleHasAsset(b, asset),
1473
1537
  )
1474
1538
  ) {
@@ -1493,7 +1557,7 @@ export default class BundleGraph {
1493
1557
  bundle: Bundle,
1494
1558
  visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
1495
1559
  startAsset?: Asset,
1496
- ): ?TContext {
1560
+ ): TContext | null | undefined {
1497
1561
  let entries = !startAsset;
1498
1562
  let bundleNodeId = this._graph.getNodeIdByContentKey(bundle.id);
1499
1563
 
@@ -1531,7 +1595,8 @@ export default class BundleGraph {
1531
1595
 
1532
1596
  let sorted =
1533
1597
  entries && bundle.entryAssetIds.length > 0
1534
- ? children.sort(([, a], [, b]) => {
1598
+ ? // @ts-expect-error TS2345
1599
+ children.sort(([, a]: [any, any], [, b]: [any, any]) => {
1535
1600
  let aIndex = bundle.entryAssetIds.indexOf(a.id);
1536
1601
  let bIndex = bundle.entryAssetIds.indexOf(b.id);
1537
1602
 
@@ -1550,7 +1615,8 @@ export default class BundleGraph {
1550
1615
  : children;
1551
1616
 
1552
1617
  entries = false;
1553
- return sorted.map(([id]) => id);
1618
+ // @ts-expect-error TS2345
1619
+ return sorted.map(([id]: [any]) => id);
1554
1620
  },
1555
1621
  });
1556
1622
  }
@@ -1558,7 +1624,7 @@ export default class BundleGraph {
1558
1624
  traverse<TContext>(
1559
1625
  visit: GraphVisitor<AssetNode | DependencyNode, TContext>,
1560
1626
  start?: Asset,
1561
- ): ?TContext {
1627
+ ): TContext | null | undefined {
1562
1628
  return this._graph.filteredTraverse(
1563
1629
  (nodeId) => {
1564
1630
  let node = nullthrows(this._graph.getNode(nodeId));
@@ -1574,7 +1640,7 @@ export default class BundleGraph {
1574
1640
 
1575
1641
  getChildBundles(bundle: Bundle): Array<Bundle> {
1576
1642
  let siblings = new Set(this.getReferencedBundles(bundle));
1577
- let bundles = [];
1643
+ let bundles: Array<Bundle> = [];
1578
1644
  this.traverseBundles((b, _, actions) => {
1579
1645
  if (bundle.id === b.id) {
1580
1646
  return;
@@ -1591,8 +1657,8 @@ export default class BundleGraph {
1591
1657
 
1592
1658
  traverseBundles<TContext>(
1593
1659
  visit: GraphVisitor<Bundle, TContext>,
1594
- startBundle: ?Bundle,
1595
- ): ?TContext {
1660
+ startBundle?: Bundle | null,
1661
+ ): TContext | null | undefined {
1596
1662
  return this._graph.filteredTraverse(
1597
1663
  (nodeId) => {
1598
1664
  let node = nullthrows(this._graph.getNode(nodeId));
@@ -1604,12 +1670,13 @@ export default class BundleGraph {
1604
1670
  );
1605
1671
  }
1606
1672
 
1607
- getBundles(opts?: {|includeInline: boolean|}): Array<Bundle> {
1608
- let bundles = [];
1673
+ getBundles(opts?: {includeInline: boolean}): Array<Bundle> {
1674
+ let bundles: Array<Bundle> = [];
1609
1675
  this.traverseBundles((bundle) => {
1610
1676
  if (
1611
1677
  opts?.includeInline ||
1612
- bundle.bundleBehavior !== BundleBehavior.inline
1678
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
1679
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1613
1680
  ) {
1614
1681
  bundles.push(bundle);
1615
1682
  }
@@ -1679,7 +1746,9 @@ export default class BundleGraph {
1679
1746
 
1680
1747
  getBundlesInBundleGroup(
1681
1748
  bundleGroup: BundleGroup,
1682
- opts?: {|includeInline: boolean|},
1749
+ opts?: {
1750
+ includeInline: boolean;
1751
+ },
1683
1752
  ): Array<Bundle> {
1684
1753
  let bundles: Set<Bundle> = new Set();
1685
1754
  for (let bundleNodeId of this._graph.getNodeIdsConnectedFrom(
@@ -1691,7 +1760,8 @@ export default class BundleGraph {
1691
1760
  let bundle = bundleNode.value;
1692
1761
  if (
1693
1762
  opts?.includeInline ||
1694
- bundle.bundleBehavior !== BundleBehavior.inline
1763
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
1764
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1695
1765
  ) {
1696
1766
  bundles.add(bundle);
1697
1767
  }
@@ -1708,7 +1778,10 @@ export default class BundleGraph {
1708
1778
 
1709
1779
  getReferencedBundles(
1710
1780
  bundle: Bundle,
1711
- opts?: {|recursive?: boolean, includeInline?: boolean|},
1781
+ opts?: {
1782
+ recursive?: boolean;
1783
+ includeInline?: boolean;
1784
+ },
1712
1785
  ): Array<Bundle> {
1713
1786
  let recursive = opts?.recursive ?? true;
1714
1787
  let includeInline = opts?.includeInline ?? false;
@@ -1726,7 +1799,8 @@ export default class BundleGraph {
1726
1799
 
1727
1800
  if (
1728
1801
  includeInline ||
1729
- node.value.bundleBehavior !== BundleBehavior.inline
1802
+ (node.value.bundleBehavior !== BundleBehavior.inline &&
1803
+ node.value.bundleBehavior !== BundleBehavior.inlineIsolated)
1730
1804
  ) {
1731
1805
  referencedBundles.add(node.value);
1732
1806
  }
@@ -1746,6 +1820,7 @@ export default class BundleGraph {
1746
1820
  ),
1747
1821
  });
1748
1822
 
1823
+ // @ts-expect-error TS2322
1749
1824
  return [...referencedBundles];
1750
1825
  }
1751
1826
 
@@ -1768,7 +1843,7 @@ export default class BundleGraph {
1768
1843
  });
1769
1844
  }
1770
1845
 
1771
- getAssetWithDependency(dep: Dependency): ?Asset {
1846
+ getAssetWithDependency(dep: Dependency): Asset | null | undefined {
1772
1847
  if (!this._graph.hasContentKey(dep.id)) {
1773
1848
  return null;
1774
1849
  }
@@ -1777,6 +1852,7 @@ export default class BundleGraph {
1777
1852
  let count = 0;
1778
1853
  this._graph.forEachNodeIdConnectedTo(
1779
1854
  this._graph.getNodeIdByContentKey(dep.id),
1855
+ // @ts-expect-error TS2345
1780
1856
  (node) => {
1781
1857
  res = node;
1782
1858
  count += 1;
@@ -1817,16 +1893,16 @@ export default class BundleGraph {
1817
1893
 
1818
1894
  filteredTraverse<TValue, TContext>(
1819
1895
  bundleNodeId: NodeId,
1820
- filter: (NodeId, TraversalActions) => ?TValue,
1896
+ filter: (arg1: NodeId, arg2: TraversalActions) => TValue | null | undefined,
1821
1897
  visit: GraphVisitor<TValue, TContext>,
1822
- ): ?TContext {
1898
+ ): TContext | null | undefined {
1823
1899
  return this._graph.filteredTraverse(filter, visit, bundleNodeId);
1824
1900
  }
1825
1901
 
1826
1902
  getSymbolResolution(
1827
1903
  asset: Asset,
1828
1904
  symbol: Symbol,
1829
- boundary: ?Bundle,
1905
+ boundary?: Bundle | null,
1830
1906
  ): InternalSymbolResolution {
1831
1907
  let assetOutside = boundary && !this.bundleHasAsset(boundary, asset);
1832
1908
 
@@ -1853,7 +1929,7 @@ export default class BundleGraph {
1853
1929
  }
1854
1930
  // If this is a re-export, find the original module.
1855
1931
  let symbolLookup = new Map(
1856
- [...depSymbols].map(([key, val]) => [val.local, key]),
1932
+ [...depSymbols].map(([key, val]: [any, any]) => [val.local, key]),
1857
1933
  );
1858
1934
  let depSymbol = symbolLookup.get(identifier);
1859
1935
  if (depSymbol != null) {
@@ -1971,17 +2047,20 @@ export default class BundleGraph {
1971
2047
  let result = identifier;
1972
2048
  if (skipped) {
1973
2049
  // ... and it was excluded (by symbol propagation) or deferred.
2050
+ // @ts-expect-error TS2322
1974
2051
  result = false;
1975
2052
  } else {
1976
2053
  // ... and there is no single reexport, but it might still be exported:
1977
2054
  if (found) {
1978
2055
  // Fallback to namespace access, because of a bundle boundary.
2056
+ // @ts-expect-error TS2322
1979
2057
  result = null;
1980
2058
  } else if (result === undefined) {
1981
2059
  // If not exported explicitly by the asset (= would have to be in * or a reexport-all) ...
1982
2060
  if (nonStaticDependency || asset.symbols?.has('*')) {
1983
2061
  // ... and if there are non-statically analyzable dependencies or it's a CJS asset,
1984
2062
  // fallback to namespace access.
2063
+ // @ts-expect-error TS2322
1985
2064
  result = null;
1986
2065
  }
1987
2066
  // (It shouldn't be possible for the symbol to be in a reexport-all and to end up here).
@@ -2019,13 +2098,13 @@ export default class BundleGraph {
2019
2098
 
2020
2099
  getExportedSymbols(
2021
2100
  asset: Asset,
2022
- boundary: ?Bundle,
2101
+ boundary?: Bundle | null,
2023
2102
  ): Array<InternalExportSymbolResolution> {
2024
2103
  if (!asset.symbols) {
2025
2104
  return [];
2026
2105
  }
2027
2106
 
2028
- let symbols = [];
2107
+ let symbols: Array<InternalExportSymbolResolution> = [];
2029
2108
 
2030
2109
  for (let symbol of asset.symbols.keys()) {
2031
2110
  symbols.push({
@@ -2076,9 +2155,9 @@ export default class BundleGraph {
2076
2155
  }
2077
2156
 
2078
2157
  getInlineBundles(bundle: Bundle): Array<Bundle> {
2079
- let bundles = [];
2158
+ let bundles: Array<Bundle> = [];
2080
2159
  let seen = new Set();
2081
- let addReferencedBundles = (bundle) => {
2160
+ let addReferencedBundles = (bundle: Bundle) => {
2082
2161
  if (seen.has(bundle.id)) {
2083
2162
  return;
2084
2163
  }
@@ -2089,7 +2168,10 @@ export default class BundleGraph {
2089
2168
  includeInline: true,
2090
2169
  });
2091
2170
  for (let referenced of referencedBundles) {
2092
- if (referenced.bundleBehavior === BundleBehavior.inline) {
2171
+ if (
2172
+ referenced.bundleBehavior === BundleBehavior.inline ||
2173
+ referenced.bundleBehavior === BundleBehavior.inlineIsolated
2174
+ ) {
2093
2175
  bundles.push(referenced);
2094
2176
  addReferencedBundles(referenced);
2095
2177
  }
@@ -2099,7 +2181,10 @@ export default class BundleGraph {
2099
2181
  addReferencedBundles(bundle);
2100
2182
 
2101
2183
  this.traverseBundles((childBundle, _, traversal) => {
2102
- if (childBundle.bundleBehavior === BundleBehavior.inline) {
2184
+ if (
2185
+ childBundle.bundleBehavior === BundleBehavior.inline ||
2186
+ childBundle.bundleBehavior === BundleBehavior.inlineIsolated
2187
+ ) {
2103
2188
  bundles.push(childBundle);
2104
2189
  } else if (childBundle.id !== bundle.id) {
2105
2190
  traversal.skipChildren();
@@ -2128,7 +2213,9 @@ export default class BundleGraph {
2128
2213
  hash.writeString(referencedBundle.id);
2129
2214
  }
2130
2215
 
2131
- hash.writeString(JSON.stringify(objectSortedEntriesDeep(bundle.env)));
2216
+ hash.writeString(
2217
+ JSON.stringify(objectSortedEntriesDeep(fromEnvironmentId(bundle.env))),
2218
+ );
2132
2219
  return hash.finish();
2133
2220
  }
2134
2221
 
@@ -2172,7 +2259,7 @@ export default class BundleGraph {
2172
2259
  }
2173
2260
  }
2174
2261
 
2175
- getUsedSymbolsAsset(asset: Asset): ?$ReadOnlySet<Symbol> {
2262
+ getUsedSymbolsAsset(asset: Asset): ReadonlySet<Symbol> | null | undefined {
2176
2263
  let node = this._graph.getNodeByContentKey(asset.id);
2177
2264
  invariant(node && node.type === 'asset');
2178
2265
  return node.value.symbols
@@ -2180,7 +2267,9 @@ export default class BundleGraph {
2180
2267
  : null;
2181
2268
  }
2182
2269
 
2183
- getUsedSymbolsDependency(dep: Dependency): ?$ReadOnlySet<Symbol> {
2270
+ getUsedSymbolsDependency(
2271
+ dep: Dependency,
2272
+ ): ReadonlySet<Symbol> | null | undefined {
2184
2273
  let node = this._graph.getNodeByContentKey(dep.id);
2185
2274
  invariant(node && node.type === 'dependency');
2186
2275
  return node.value.symbols
@@ -2228,6 +2317,7 @@ export default class BundleGraph {
2228
2317
  }
2229
2318
  }
2230
2319
 
2320
+ // @ts-expect-error TS2488
2231
2321
  for (let edge of other._graph.getAllEdges()) {
2232
2322
  this._graph.addEdge(
2233
2323
  nullthrows(otherGraphIdToThisNodeId.get(edge.from)),
@@ -2272,7 +2362,7 @@ export default class BundleGraph {
2272
2362
  bundleGraphEdgeTypes.bundle,
2273
2363
  );
2274
2364
 
2275
- let entries = [];
2365
+ let entries: Array<FilePath> = [];
2276
2366
  for (let bundleGroupId of entryBundleGroupIds) {
2277
2367
  let bundleGroupNode = this._graph.getNode(bundleGroupId);
2278
2368
  invariant(bundleGroupNode?.type === 'bundle_group');
@@ -2312,6 +2402,7 @@ export default class BundleGraph {
2312
2402
  ),
2313
2403
  });
2314
2404
 
2405
+ // @ts-expect-error TS2322
2315
2406
  return [...referencedBundles];
2316
2407
  }
2317
2408
  }