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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/CHANGELOG.md +941 -0
  2. package/dist/AssetGraph.js +591 -0
  3. package/dist/Atlaspack.js +666 -0
  4. package/dist/AtlaspackConfig.js +324 -0
  5. package/dist/AtlaspackConfig.schema.js +117 -0
  6. package/dist/BundleGraph.js +1740 -0
  7. package/dist/CommittedAsset.js +142 -0
  8. package/dist/Dependency.js +125 -0
  9. package/dist/Environment.js +132 -0
  10. package/dist/EnvironmentManager.js +108 -0
  11. package/dist/IdentifierRegistry.js +38 -0
  12. package/dist/InternalConfig.js +37 -0
  13. package/dist/PackagerRunner.js +545 -0
  14. package/dist/ReporterRunner.js +151 -0
  15. package/dist/RequestTracker.js +1360 -0
  16. package/dist/SymbolPropagation.js +620 -0
  17. package/dist/TargetDescriptor.schema.js +143 -0
  18. package/dist/Transformation.js +514 -0
  19. package/dist/UncommittedAsset.js +315 -0
  20. package/dist/Validation.js +196 -0
  21. package/dist/applyRuntimes.js +383 -0
  22. package/dist/assetUtils.js +169 -0
  23. package/dist/atlaspack-v3/AtlaspackV3.js +74 -0
  24. package/dist/atlaspack-v3/NapiWorkerPool.js +81 -0
  25. package/dist/atlaspack-v3/fs.js +52 -0
  26. package/dist/atlaspack-v3/index.js +25 -0
  27. package/dist/atlaspack-v3/jsCallable.js +16 -0
  28. package/dist/atlaspack-v3/worker/compat/asset-symbols.js +190 -0
  29. package/dist/atlaspack-v3/worker/compat/bitflags.js +98 -0
  30. package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
  31. package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
  32. package/dist/atlaspack-v3/worker/compat/index.js +25 -0
  33. package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
  34. package/dist/atlaspack-v3/worker/compat/plugin-config.js +64 -0
  35. package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
  36. package/dist/atlaspack-v3/worker/compat/plugin-options.js +137 -0
  37. package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
  38. package/dist/atlaspack-v3/worker/compat/target.js +14 -0
  39. package/dist/atlaspack-v3/worker/side-effect-detector.js +243 -0
  40. package/dist/atlaspack-v3/worker/worker.js +381 -0
  41. package/dist/constants.js +17 -0
  42. package/dist/dumpGraphToGraphViz.js +281 -0
  43. package/dist/index.js +62 -0
  44. package/dist/loadAtlaspackPlugin.js +128 -0
  45. package/dist/loadDotEnv.js +41 -0
  46. package/dist/projectPath.js +83 -0
  47. package/dist/public/Asset.js +279 -0
  48. package/dist/public/Bundle.js +224 -0
  49. package/dist/public/BundleGraph.js +371 -0
  50. package/dist/public/BundleGroup.js +53 -0
  51. package/dist/public/Config.js +286 -0
  52. package/dist/public/Dependency.js +138 -0
  53. package/dist/public/Environment.js +278 -0
  54. package/dist/public/MutableBundleGraph.js +277 -0
  55. package/dist/public/PluginOptions.js +80 -0
  56. package/dist/public/Symbols.js +248 -0
  57. package/dist/public/Target.js +69 -0
  58. package/dist/registerCoreWithSerializer.js +38 -0
  59. package/dist/requests/AssetGraphRequest.js +439 -0
  60. package/dist/requests/AssetGraphRequestRust.js +273 -0
  61. package/dist/requests/AssetRequest.js +130 -0
  62. package/dist/requests/AtlaspackBuildRequest.js +92 -0
  63. package/dist/requests/AtlaspackConfigRequest.js +493 -0
  64. package/dist/requests/BundleGraphRequest.js +447 -0
  65. package/dist/requests/ConfigRequest.js +246 -0
  66. package/dist/requests/DevDepRequest.js +204 -0
  67. package/dist/requests/EntryRequest.js +314 -0
  68. package/dist/requests/PackageRequest.js +72 -0
  69. package/dist/requests/PathRequest.js +349 -0
  70. package/dist/requests/TargetRequest.js +1311 -0
  71. package/dist/requests/ValidationRequest.js +49 -0
  72. package/dist/requests/WriteBundleRequest.js +254 -0
  73. package/dist/requests/WriteBundlesRequest.js +184 -0
  74. package/dist/requests/asset-graph-diff.js +128 -0
  75. package/dist/requests/asset-graph-dot.js +131 -0
  76. package/dist/resolveOptions.js +269 -0
  77. package/dist/rustWorkerThreadDylibHack.js +19 -0
  78. package/dist/serializerCore.browser.js +43 -0
  79. package/dist/summarizeRequest.js +39 -0
  80. package/dist/types.js +31 -0
  81. package/dist/utils.js +172 -0
  82. package/dist/worker.js +123 -0
  83. package/lib/AssetGraph.js +111 -14
  84. package/lib/Atlaspack.js +94 -41
  85. package/lib/AtlaspackConfig.js +15 -3
  86. package/lib/AtlaspackConfig.schema.js +16 -5
  87. package/lib/BundleGraph.js +197 -32
  88. package/lib/CommittedAsset.js +7 -1
  89. package/lib/Dependency.js +8 -2
  90. package/lib/Environment.js +15 -8
  91. package/lib/EnvironmentManager.js +143 -0
  92. package/lib/IdentifierRegistry.js +1 -3
  93. package/lib/InternalConfig.js +3 -2
  94. package/lib/PackagerRunner.js +90 -27
  95. package/lib/ReporterRunner.js +6 -9
  96. package/lib/RequestTracker.js +266 -156
  97. package/lib/SymbolPropagation.js +42 -18
  98. package/lib/TargetDescriptor.schema.js +7 -1
  99. package/lib/Transformation.js +66 -15
  100. package/lib/UncommittedAsset.js +33 -12
  101. package/lib/Validation.js +18 -2
  102. package/lib/applyRuntimes.js +96 -4
  103. package/lib/assetUtils.js +15 -5
  104. package/lib/atlaspack-v3/AtlaspackV3.js +52 -14
  105. package/lib/atlaspack-v3/NapiWorkerPool.js +28 -1
  106. package/lib/atlaspack-v3/fs.js +3 -1
  107. package/lib/atlaspack-v3/index.js +28 -1
  108. package/lib/atlaspack-v3/jsCallable.js +0 -2
  109. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +7 -4
  110. package/lib/atlaspack-v3/worker/compat/bitflags.js +31 -25
  111. package/lib/atlaspack-v3/worker/compat/dependency.js +4 -1
  112. package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
  113. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +15 -10
  114. package/lib/atlaspack-v3/worker/compat/plugin-config.js +13 -34
  115. package/lib/atlaspack-v3/worker/compat/plugin-options.js +16 -0
  116. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
  117. package/lib/atlaspack-v3/worker/compat/target.js +2 -0
  118. package/lib/atlaspack-v3/worker/index.js +3 -0
  119. package/lib/atlaspack-v3/worker/side-effect-detector.js +215 -0
  120. package/lib/atlaspack-v3/worker/worker.js +199 -71
  121. package/lib/constants.js +0 -1
  122. package/lib/dumpGraphToGraphViz.js +71 -16
  123. package/lib/index.js +45 -1
  124. package/lib/loadDotEnv.js +4 -1
  125. package/lib/projectPath.js +5 -0
  126. package/lib/public/Asset.js +21 -11
  127. package/lib/public/Bundle.js +15 -16
  128. package/lib/public/BundleGraph.js +25 -22
  129. package/lib/public/BundleGroup.js +4 -5
  130. package/lib/public/Config.js +118 -17
  131. package/lib/public/Dependency.js +8 -6
  132. package/lib/public/Environment.js +12 -7
  133. package/lib/public/MutableBundleGraph.js +54 -12
  134. package/lib/public/PluginOptions.js +2 -2
  135. package/lib/public/Symbols.js +11 -11
  136. package/lib/public/Target.js +7 -6
  137. package/lib/registerCoreWithSerializer.js +5 -3
  138. package/lib/requests/AssetGraphRequest.js +74 -27
  139. package/lib/requests/AssetGraphRequestRust.js +140 -64
  140. package/lib/requests/AssetRequest.js +23 -6
  141. package/lib/requests/AtlaspackBuildRequest.js +43 -4
  142. package/lib/requests/AtlaspackConfigRequest.js +27 -16
  143. package/lib/requests/BundleGraphRequest.js +41 -24
  144. package/lib/requests/ConfigRequest.js +53 -4
  145. package/lib/requests/DevDepRequest.js +31 -5
  146. package/lib/requests/EntryRequest.js +2 -0
  147. package/lib/requests/PackageRequest.js +16 -2
  148. package/lib/requests/PathRequest.js +24 -3
  149. package/lib/requests/TargetRequest.js +122 -57
  150. package/lib/requests/ValidationRequest.js +5 -1
  151. package/lib/requests/WriteBundleRequest.js +39 -11
  152. package/lib/requests/WriteBundlesRequest.js +51 -4
  153. package/lib/requests/asset-graph-diff.js +12 -7
  154. package/lib/requests/asset-graph-dot.js +1 -7
  155. package/lib/resolveOptions.js +38 -11
  156. package/lib/rustWorkerThreadDylibHack.js +0 -1
  157. package/lib/types/AssetGraph.d.ts +80 -0
  158. package/lib/types/Atlaspack.d.ts +52 -0
  159. package/lib/types/AtlaspackConfig.d.ts +65 -0
  160. package/lib/types/AtlaspackConfig.schema.d.ts +53 -0
  161. package/lib/types/BundleGraph.d.ts +184 -0
  162. package/lib/types/CommittedAsset.d.ts +23 -0
  163. package/lib/types/Dependency.d.ts +44 -0
  164. package/lib/types/Environment.d.ts +11 -0
  165. package/lib/types/EnvironmentManager.d.ts +37 -0
  166. package/lib/types/IdentifierRegistry.d.ts +6 -0
  167. package/lib/types/InternalConfig.d.ts +23 -0
  168. package/lib/types/PackagerRunner.d.ts +85 -0
  169. package/lib/types/ReporterRunner.d.ts +25 -0
  170. package/lib/types/RequestTracker.d.ts +385 -0
  171. package/lib/types/SymbolPropagation.d.ts +11 -0
  172. package/lib/types/TargetDescriptor.schema.d.ts +5 -0
  173. package/lib/types/Transformation.d.ts +72 -0
  174. package/lib/types/UncommittedAsset.d.ts +61 -0
  175. package/lib/types/Validation.d.ts +37 -0
  176. package/lib/types/applyRuntimes.d.ts +25 -0
  177. package/lib/types/assetUtils.d.ts +42 -0
  178. package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +34 -0
  179. package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +13 -0
  180. package/lib/types/atlaspack-v3/fs.d.ts +12 -0
  181. package/lib/types/atlaspack-v3/index.d.ts +6 -0
  182. package/lib/types/atlaspack-v3/jsCallable.d.ts +1 -0
  183. package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
  184. package/lib/types/atlaspack-v3/worker/compat/bitflags.d.ts +14 -0
  185. package/lib/types/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
  186. package/lib/types/atlaspack-v3/worker/compat/environment.d.ts +27 -0
  187. package/{src/atlaspack-v3/worker/compat/index.js → lib/types/atlaspack-v3/worker/compat/index.d.ts} +0 -1
  188. package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
  189. package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +29 -0
  190. package/lib/types/atlaspack-v3/worker/compat/plugin-logger.d.ts +9 -0
  191. package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +23 -0
  192. package/lib/types/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
  193. package/lib/types/atlaspack-v3/worker/compat/target.d.ts +11 -0
  194. package/lib/types/atlaspack-v3/worker/side-effect-detector.d.ts +76 -0
  195. package/lib/types/atlaspack-v3/worker/worker.d.ts +80 -0
  196. package/lib/types/constants.d.ts +13 -0
  197. package/lib/types/dumpGraphToGraphViz.d.ts +10 -0
  198. package/lib/types/index.d.ts +8 -0
  199. package/lib/types/loadAtlaspackPlugin.d.ts +8 -0
  200. package/lib/types/loadDotEnv.d.ts +3 -0
  201. package/lib/types/projectPath.d.ts +19 -0
  202. package/lib/types/public/Asset.d.ts +74 -0
  203. package/lib/types/public/Bundle.d.ts +45 -0
  204. package/lib/types/public/BundleGraph.d.ts +72 -0
  205. package/lib/types/public/BundleGroup.d.ts +12 -0
  206. package/lib/types/public/Config.d.ts +75 -0
  207. package/lib/types/public/Dependency.d.ts +32 -0
  208. package/lib/types/public/Environment.d.ts +34 -0
  209. package/lib/types/public/MutableBundleGraph.d.ts +26 -0
  210. package/lib/types/public/PluginOptions.d.ts +25 -0
  211. package/lib/types/public/Symbols.d.ts +81 -0
  212. package/lib/types/public/Target.d.ts +16 -0
  213. package/lib/types/registerCoreWithSerializer.d.ts +2 -0
  214. package/lib/types/requests/AssetGraphRequest.d.ts +76 -0
  215. package/lib/types/requests/AssetGraphRequestRust.d.ts +21 -0
  216. package/lib/types/requests/AssetRequest.d.ts +16 -0
  217. package/lib/types/requests/AtlaspackBuildRequest.d.ts +33 -0
  218. package/lib/types/requests/AtlaspackConfigRequest.d.ts +45 -0
  219. package/lib/types/requests/BundleGraphRequest.d.ts +28 -0
  220. package/lib/types/requests/ConfigRequest.d.ts +67 -0
  221. package/lib/types/requests/DevDepRequest.d.ts +30 -0
  222. package/lib/types/requests/EntryRequest.d.ts +36 -0
  223. package/lib/types/requests/PackageRequest.d.ts +27 -0
  224. package/lib/types/requests/PathRequest.d.ts +48 -0
  225. package/lib/types/requests/TargetRequest.d.ts +48 -0
  226. package/lib/types/requests/ValidationRequest.d.ts +20 -0
  227. package/lib/types/requests/WriteBundleRequest.d.ts +28 -0
  228. package/lib/types/requests/WriteBundlesRequest.d.ts +32 -0
  229. package/lib/types/requests/asset-graph-diff.d.ts +1 -0
  230. package/lib/types/requests/asset-graph-dot.d.ts +9 -0
  231. package/lib/types/resolveOptions.d.ts +3 -0
  232. package/lib/types/rustWorkerThreadDylibHack.d.ts +9 -0
  233. package/lib/types/serializerCore.browser.d.ts +3 -0
  234. package/lib/types/summarizeRequest.d.ts +10 -0
  235. package/lib/types/types.d.ts +495 -0
  236. package/lib/types/utils.d.ts +23 -0
  237. package/lib/types/worker.d.ts +44 -0
  238. package/lib/types.js +8 -1
  239. package/lib/utils.js +17 -2
  240. package/lib/worker.js +30 -14
  241. package/package.json +25 -35
  242. package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
  243. package/src/{Atlaspack.js → Atlaspack.ts} +134 -67
  244. package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +25 -19
  245. package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
  246. package/src/{BundleGraph.js → BundleGraph.ts} +383 -140
  247. package/src/{CommittedAsset.js → CommittedAsset.ts} +15 -13
  248. package/src/{Dependency.js → Dependency.ts} +59 -42
  249. package/src/{Environment.js → Environment.ts} +24 -15
  250. package/src/EnvironmentManager.ts +154 -0
  251. package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
  252. package/src/{InternalConfig.js → InternalConfig.ts} +22 -23
  253. package/src/{PackagerRunner.js → PackagerRunner.ts} +179 -87
  254. package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
  255. package/src/{RequestTracker.js → RequestTracker.ts} +572 -357
  256. package/src/{SymbolPropagation.js → SymbolPropagation.ts} +165 -57
  257. package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
  258. package/src/{Transformation.js → Transformation.ts} +110 -65
  259. package/src/{UncommittedAsset.js → UncommittedAsset.ts} +60 -39
  260. package/src/{Validation.js → Validation.ts} +32 -17
  261. package/src/{applyRuntimes.js → applyRuntimes.ts} +133 -26
  262. package/src/{assetUtils.js → assetUtils.ts} +49 -36
  263. package/src/atlaspack-v3/AtlaspackV3.ts +143 -0
  264. package/src/atlaspack-v3/NapiWorkerPool.ts +91 -0
  265. package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
  266. package/src/atlaspack-v3/{index.js → index.ts} +3 -4
  267. package/src/atlaspack-v3/jsCallable.ts +14 -0
  268. package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +40 -30
  269. package/src/atlaspack-v3/worker/compat/bitflags.ts +102 -0
  270. package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +13 -13
  271. package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
  272. package/src/atlaspack-v3/worker/compat/index.ts +9 -0
  273. package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +21 -20
  274. package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +25 -56
  275. package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
  276. package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +19 -5
  277. package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
  278. package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
  279. package/src/atlaspack-v3/worker/index.js +2 -1
  280. package/src/atlaspack-v3/worker/side-effect-detector.ts +298 -0
  281. package/src/atlaspack-v3/worker/worker.ts +531 -0
  282. package/src/{constants.js → constants.ts} +0 -3
  283. package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
  284. package/src/index.ts +18 -0
  285. package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +8 -9
  286. package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
  287. package/src/{projectPath.js → projectPath.ts} +20 -9
  288. package/src/public/{Asset.js → Asset.ts} +41 -28
  289. package/src/public/{Bundle.js → Bundle.ts} +28 -29
  290. package/src/public/{BundleGraph.js → BundleGraph.ts} +103 -68
  291. package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
  292. package/src/public/{Config.js → Config.ts} +171 -33
  293. package/src/public/{Dependency.js → Dependency.ts} +20 -17
  294. package/src/public/{Environment.js → Environment.ts} +28 -17
  295. package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
  296. package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
  297. package/src/public/{Symbols.js → Symbols.ts} +75 -36
  298. package/src/public/{Target.js → Target.ts} +10 -8
  299. package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
  300. package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +129 -80
  301. package/src/requests/AssetGraphRequestRust.ts +364 -0
  302. package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
  303. package/src/requests/AtlaspackBuildRequest.ts +163 -0
  304. package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
  305. package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +97 -79
  306. package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +110 -50
  307. package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +60 -35
  308. package/src/requests/{EntryRequest.js → EntryRequest.ts} +36 -31
  309. package/src/requests/{PackageRequest.js → PackageRequest.ts} +34 -22
  310. package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
  311. package/src/requests/{TargetRequest.js → TargetRequest.ts} +260 -179
  312. package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
  313. package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +77 -49
  314. package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +109 -37
  315. package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +25 -21
  316. package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
  317. package/src/{resolveOptions.js → resolveOptions.ts} +59 -25
  318. package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
  319. package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
  320. package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
  321. package/src/types.ts +650 -0
  322. package/src/{utils.js → utils.ts} +52 -21
  323. package/src/{worker.js → worker.ts} +50 -42
  324. package/test/{AssetGraph.test.js → AssetGraph.test.ts} +37 -8
  325. package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
  326. package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
  327. package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +76 -16
  328. package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
  329. package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
  330. package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
  331. package/test/Environment.test.ts +153 -0
  332. package/test/EnvironmentManager.test.ts +188 -0
  333. package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
  334. package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
  335. package/test/PackagerRunner.test.ts +0 -0
  336. package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
  337. package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
  338. package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
  339. package/test/PublicEnvironment.test.ts +49 -0
  340. package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
  341. package/test/{RequestTracker.test.js → RequestTracker.test.ts} +314 -59
  342. package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
  343. package/test/{TargetRequest.test.js → TargetRequest.test.ts} +66 -92
  344. package/test/fixtures/config-with-reporters/.parcelrc +7 -0
  345. package/test/fixtures/custom-targets/package.json +6 -0
  346. package/test/public/Config.test.ts +104 -0
  347. package/test/requests/AssetGraphRequestRust.test.ts +443 -0
  348. package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
  349. package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
  350. package/test/{test-utils.js → test-utils.ts} +4 -11
  351. package/test/{utils.test.js → utils.test.ts} +1 -3
  352. package/tsconfig.json +60 -0
  353. package/tsconfig.tsbuildinfo +1 -0
  354. package/index.d.ts +0 -30
  355. package/src/atlaspack-v3/AtlaspackV3.js +0 -87
  356. package/src/atlaspack-v3/NapiWorkerPool.js +0 -53
  357. package/src/atlaspack-v3/jsCallable.js +0 -18
  358. package/src/atlaspack-v3/worker/compat/bitflags.js +0 -100
  359. package/src/atlaspack-v3/worker/worker.js +0 -362
  360. package/src/index.js +0 -13
  361. package/src/requests/AssetGraphRequestRust.js +0 -263
  362. package/src/requests/AtlaspackBuildRequest.js +0 -111
  363. package/src/types.js +0 -600
  364. package/test/Environment.test.js +0 -119
  365. package/test/PackagerRunner.test.js +0 -27
  366. package/test/PublicEnvironment.test.js +0 -27
  367. package/test/requests/AssetGraphRequestRust.test.js +0 -411
@@ -0,0 +1,224 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ var _Bundle_bundle, _Bundle_bundleGraph, _Bundle_options, _NamedBundle_bundle, _NamedBundle_bundleGraph, _NamedBundle_options, _PackagedBundle_bundle, _PackagedBundle_bundleGraph, _PackagedBundle_options, _PackagedBundle_bundleInfo;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.PackagedBundle = exports.NamedBundle = exports.Bundle = void 0;
19
+ exports.bundleToInternalBundle = bundleToInternalBundle;
20
+ exports.bundleToInternalBundleGraph = bundleToInternalBundleGraph;
21
+ const assert_1 = __importDefault(require("assert"));
22
+ const nullthrows_1 = __importDefault(require("nullthrows"));
23
+ const utils_1 = require("@atlaspack/utils");
24
+ const Asset_1 = require("./Asset");
25
+ const graph_1 = require("@atlaspack/graph");
26
+ const Environment_1 = __importDefault(require("./Environment"));
27
+ const Dependency_1 = require("./Dependency");
28
+ const Target_1 = __importDefault(require("./Target"));
29
+ const types_1 = require("../types");
30
+ const projectPath_1 = require("../projectPath");
31
+ const EnvironmentManager_1 = require("../EnvironmentManager");
32
+ const inspect = Symbol.for('nodejs.util.inspect.custom');
33
+ const internalBundleToBundle = new utils_1.DefaultWeakMap(() => new utils_1.DefaultWeakMap(() => new WeakMap()));
34
+ const internalBundleToNamedBundle = new utils_1.DefaultWeakMap(() => new utils_1.DefaultWeakMap(() => new WeakMap()));
35
+ const internalBundleToPackagedBundle = new utils_1.DefaultWeakMap(() => new utils_1.DefaultWeakMap(() => new WeakMap()));
36
+ // Friendly access for other modules within this package that need access
37
+ // to the internal bundle.
38
+ const _bundleToInternalBundle = new WeakMap();
39
+ function bundleToInternalBundle(bundle) {
40
+ return (0, nullthrows_1.default)(_bundleToInternalBundle.get(bundle));
41
+ }
42
+ const _bundleToInternalBundleGraph = new WeakMap();
43
+ function bundleToInternalBundleGraph(bundle) {
44
+ return (0, nullthrows_1.default)(_bundleToInternalBundleGraph.get(bundle));
45
+ }
46
+ // Require this private object to be present when invoking these constructors,
47
+ // preventing others from using them. They should use the static `get` method.
48
+ let _private = {};
49
+ class Bundle {
50
+ [(_Bundle_bundle = new WeakMap(), _Bundle_bundleGraph = new WeakMap(), _Bundle_options = new WeakMap(), inspect)]() {
51
+ return `Bundle(${__classPrivateFieldGet(this, _Bundle_bundle, "f").id})`;
52
+ }
53
+ constructor(sentinel, bundle, bundleGraph, options) {
54
+ _Bundle_bundle.set(this, void 0);
55
+ _Bundle_bundleGraph.set(this, void 0);
56
+ _Bundle_options.set(this, void 0);
57
+ if (sentinel !== _private) {
58
+ throw new Error('Unexpected public usage');
59
+ }
60
+ __classPrivateFieldSet(this, _Bundle_bundle, bundle, "f");
61
+ __classPrivateFieldSet(this, _Bundle_bundleGraph, bundleGraph, "f");
62
+ __classPrivateFieldSet(this, _Bundle_options, options, "f");
63
+ }
64
+ static get(internalBundle, bundleGraph, options) {
65
+ let existingMap = internalBundleToBundle.get(options).get(bundleGraph);
66
+ let existing = existingMap.get(internalBundle);
67
+ if (existing != null) {
68
+ return existing;
69
+ }
70
+ let bundle = new Bundle(_private, internalBundle, bundleGraph, options);
71
+ _bundleToInternalBundle.set(bundle, internalBundle);
72
+ _bundleToInternalBundleGraph.set(bundle, bundleGraph);
73
+ existingMap.set(internalBundle, bundle);
74
+ return bundle;
75
+ }
76
+ get id() {
77
+ return __classPrivateFieldGet(this, _Bundle_bundle, "f").id;
78
+ }
79
+ get hashReference() {
80
+ return __classPrivateFieldGet(this, _Bundle_bundle, "f").hashReference;
81
+ }
82
+ get type() {
83
+ return __classPrivateFieldGet(this, _Bundle_bundle, "f").type;
84
+ }
85
+ get env() {
86
+ return new Environment_1.default((0, EnvironmentManager_1.fromEnvironmentId)(__classPrivateFieldGet(this, _Bundle_bundle, "f").env), __classPrivateFieldGet(this, _Bundle_options, "f"));
87
+ }
88
+ get needsStableName() {
89
+ return __classPrivateFieldGet(this, _Bundle_bundle, "f").needsStableName;
90
+ }
91
+ get bundleBehavior() {
92
+ let bundleBehavior = __classPrivateFieldGet(this, _Bundle_bundle, "f").bundleBehavior;
93
+ return bundleBehavior != null ? types_1.BundleBehaviorNames[bundleBehavior] : null;
94
+ }
95
+ get isSplittable() {
96
+ return __classPrivateFieldGet(this, _Bundle_bundle, "f").isSplittable;
97
+ }
98
+ get manualSharedBundle() {
99
+ return __classPrivateFieldGet(this, _Bundle_bundle, "f").manualSharedBundle;
100
+ }
101
+ get target() {
102
+ return new Target_1.default(__classPrivateFieldGet(this, _Bundle_bundle, "f").target, __classPrivateFieldGet(this, _Bundle_options, "f"));
103
+ }
104
+ hasAsset(asset) {
105
+ return __classPrivateFieldGet(this, _Bundle_bundleGraph, "f").bundleHasAsset(__classPrivateFieldGet(this, _Bundle_bundle, "f"), (0, Asset_1.assetToAssetValue)(asset));
106
+ }
107
+ hasDependency(dep) {
108
+ return __classPrivateFieldGet(this, _Bundle_bundleGraph, "f").bundleHasDependency(__classPrivateFieldGet(this, _Bundle_bundle, "f"), (0, Dependency_1.dependencyToInternalDependency)(dep));
109
+ }
110
+ getEntryAssets() {
111
+ return __classPrivateFieldGet(this, _Bundle_bundle, "f").entryAssetIds.map((id) => {
112
+ let assetNode = __classPrivateFieldGet(this, _Bundle_bundleGraph, "f")._graph.getNodeByContentKey(id);
113
+ (0, assert_1.default)(assetNode != null && assetNode.type === 'asset');
114
+ return (0, Asset_1.assetFromValue)(assetNode.value, __classPrivateFieldGet(this, _Bundle_options, "f"));
115
+ });
116
+ }
117
+ getMainEntry() {
118
+ if (__classPrivateFieldGet(this, _Bundle_bundle, "f").mainEntryId != null) {
119
+ let assetNode = __classPrivateFieldGet(this, _Bundle_bundleGraph, "f")._graph.getNodeByContentKey(__classPrivateFieldGet(this, _Bundle_bundle, "f").mainEntryId);
120
+ (0, assert_1.default)(assetNode != null && assetNode.type === 'asset');
121
+ return (0, Asset_1.assetFromValue)(assetNode.value, __classPrivateFieldGet(this, _Bundle_options, "f"));
122
+ }
123
+ }
124
+ traverse(visit) {
125
+ return __classPrivateFieldGet(this, _Bundle_bundleGraph, "f").traverseBundle(__classPrivateFieldGet(this, _Bundle_bundle, "f"),
126
+ // @ts-expect-error TS2345
127
+ (0, graph_1.mapVisitor)((node) => {
128
+ if (node.type === 'asset') {
129
+ return {
130
+ type: 'asset',
131
+ value: (0, Asset_1.assetFromValue)(node.value, __classPrivateFieldGet(this, _Bundle_options, "f")),
132
+ };
133
+ }
134
+ else if (node.type === 'dependency') {
135
+ return {
136
+ type: 'dependency',
137
+ value: (0, Dependency_1.getPublicDependency)(node.value, __classPrivateFieldGet(this, _Bundle_options, "f")),
138
+ };
139
+ }
140
+ }, visit));
141
+ }
142
+ traverseAssets(visit, startAsset) {
143
+ return __classPrivateFieldGet(this, _Bundle_bundleGraph, "f").traverseAssets(__classPrivateFieldGet(this, _Bundle_bundle, "f"), (0, graph_1.mapVisitor)((asset) => (0, Asset_1.assetFromValue)(asset, __classPrivateFieldGet(this, _Bundle_options, "f")), visit), startAsset ? (0, Asset_1.assetToAssetValue)(startAsset) : undefined);
144
+ }
145
+ }
146
+ exports.Bundle = Bundle;
147
+ class NamedBundle extends Bundle {
148
+ constructor(sentinel, bundle, bundleGraph, options) {
149
+ super(sentinel, bundle, bundleGraph, options);
150
+ _NamedBundle_bundle.set(this, void 0);
151
+ _NamedBundle_bundleGraph.set(this, void 0);
152
+ _NamedBundle_options.set(this, void 0);
153
+ __classPrivateFieldSet(this, _NamedBundle_bundle, bundle, "f"); // Repeating for flow
154
+ __classPrivateFieldSet(this, _NamedBundle_bundleGraph, bundleGraph, "f"); // Repeating for flow
155
+ __classPrivateFieldSet(this, _NamedBundle_options, options, "f");
156
+ }
157
+ static get(internalBundle, bundleGraph, options) {
158
+ let existingMap = internalBundleToNamedBundle.get(options).get(bundleGraph);
159
+ let existing = existingMap.get(internalBundle);
160
+ if (existing != null) {
161
+ return existing;
162
+ }
163
+ let namedBundle = new NamedBundle(_private, internalBundle, bundleGraph, options);
164
+ _bundleToInternalBundle.set(namedBundle, internalBundle);
165
+ _bundleToInternalBundleGraph.set(namedBundle, bundleGraph);
166
+ existingMap.set(internalBundle, namedBundle);
167
+ return namedBundle;
168
+ }
169
+ get name() {
170
+ return (0, nullthrows_1.default)(__classPrivateFieldGet(this, _NamedBundle_bundle, "f").name);
171
+ }
172
+ get displayName() {
173
+ return (0, nullthrows_1.default)(__classPrivateFieldGet(this, _NamedBundle_bundle, "f").displayName);
174
+ }
175
+ get publicId() {
176
+ return (0, nullthrows_1.default)(__classPrivateFieldGet(this, _NamedBundle_bundle, "f").publicId);
177
+ }
178
+ }
179
+ exports.NamedBundle = NamedBundle;
180
+ _NamedBundle_bundle = new WeakMap(), _NamedBundle_bundleGraph = new WeakMap(), _NamedBundle_options = new WeakMap();
181
+ class PackagedBundle extends NamedBundle {
182
+ constructor(sentinel, bundle, bundleGraph, options) {
183
+ super(sentinel, bundle, bundleGraph, options);
184
+ _PackagedBundle_bundle.set(this, void 0);
185
+ _PackagedBundle_bundleGraph.set(this, void 0);
186
+ _PackagedBundle_options.set(this, void 0);
187
+ _PackagedBundle_bundleInfo.set(this, void 0);
188
+ __classPrivateFieldSet(this, _PackagedBundle_bundle, bundle, "f"); // Repeating for flow
189
+ __classPrivateFieldSet(this, _PackagedBundle_bundleGraph, bundleGraph, "f"); // Repeating for flow
190
+ __classPrivateFieldSet(this, _PackagedBundle_options, options, "f"); // Repeating for flow
191
+ }
192
+ static get(internalBundle, bundleGraph, options) {
193
+ let existingMap = internalBundleToPackagedBundle
194
+ .get(options)
195
+ .get(bundleGraph);
196
+ let existing = existingMap.get(internalBundle);
197
+ if (existing != null) {
198
+ return existing;
199
+ }
200
+ let packagedBundle = new PackagedBundle(_private, internalBundle, bundleGraph, options);
201
+ _bundleToInternalBundle.set(packagedBundle, internalBundle);
202
+ _bundleToInternalBundleGraph.set(packagedBundle, bundleGraph);
203
+ existingMap.set(internalBundle, packagedBundle);
204
+ return packagedBundle;
205
+ }
206
+ static getWithInfo(internalBundle, bundleGraph, options, bundleInfo) {
207
+ let packagedBundle = PackagedBundle.get(internalBundle, bundleGraph, options);
208
+ __classPrivateFieldSet(packagedBundle, _PackagedBundle_bundleInfo, bundleInfo, "f");
209
+ return packagedBundle;
210
+ }
211
+ get filePath() {
212
+ return (0, projectPath_1.fromProjectPath)(__classPrivateFieldGet(this, _PackagedBundle_options, "f").projectRoot, (0, nullthrows_1.default)(__classPrivateFieldGet(this, _PackagedBundle_bundleInfo, "f")).filePath);
213
+ }
214
+ get type() {
215
+ // The bundle type may be overridden in the packager.
216
+ // However, inline bundles will not have a bundleInfo here since they are not written to the filesystem.
217
+ return __classPrivateFieldGet(this, _PackagedBundle_bundleInfo, "f") ? __classPrivateFieldGet(this, _PackagedBundle_bundleInfo, "f").type : __classPrivateFieldGet(this, _PackagedBundle_bundle, "f").type;
218
+ }
219
+ get stats() {
220
+ return (0, nullthrows_1.default)(__classPrivateFieldGet(this, _PackagedBundle_bundleInfo, "f")).stats;
221
+ }
222
+ }
223
+ exports.PackagedBundle = PackagedBundle;
224
+ _PackagedBundle_bundle = new WeakMap(), _PackagedBundle_bundleGraph = new WeakMap(), _PackagedBundle_options = new WeakMap(), _PackagedBundle_bundleInfo = new WeakMap();
@@ -0,0 +1,371 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
36
+ if (kind === "m") throw new TypeError("Private method is not writable");
37
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
38
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
39
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
40
+ };
41
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
42
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
43
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
44
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
45
+ };
46
+ var __importDefault = (this && this.__importDefault) || function (mod) {
47
+ return (mod && mod.__esModule) ? mod : { "default": mod };
48
+ };
49
+ var _BundleGraph_graph, _BundleGraph_options, _BundleGraph_createBundle;
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.bundleGraphToInternalBundleGraph = bundleGraphToInternalBundleGraph;
52
+ const assert_1 = __importDefault(require("assert"));
53
+ const nullthrows_1 = __importDefault(require("nullthrows"));
54
+ const graph_1 = require("@atlaspack/graph");
55
+ const Asset_1 = require("./Asset");
56
+ const Bundle_1 = require("./Bundle");
57
+ const Dependency_1 = __importStar(require("./Dependency"));
58
+ const Target_1 = require("./Target");
59
+ const utils_1 = require("../utils");
60
+ const BundleGroup_1 = __importStar(require("./BundleGroup"));
61
+ // Friendly access for other modules within this package that need access
62
+ // to the internal bundle.
63
+ const _bundleGraphToInternalBundleGraph = new WeakMap();
64
+ function bundleGraphToInternalBundleGraph(bundleGraph) {
65
+ return (0, nullthrows_1.default)(_bundleGraphToInternalBundleGraph.get(bundleGraph));
66
+ }
67
+ class BundleGraph {
68
+ constructor(graph, createBundle, options) {
69
+ _BundleGraph_graph.set(this, void 0);
70
+ _BundleGraph_options.set(this, void 0);
71
+ _BundleGraph_createBundle.set(this, void 0);
72
+ __classPrivateFieldSet(this, _BundleGraph_graph, graph, "f");
73
+ __classPrivateFieldSet(this, _BundleGraph_options, options, "f");
74
+ __classPrivateFieldSet(this, _BundleGraph_createBundle, createBundle, "f");
75
+ _bundleGraphToInternalBundleGraph.set(this, graph);
76
+ }
77
+ getAssetById(id) {
78
+ return (0, Asset_1.assetFromValue)(__classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetById(id), __classPrivateFieldGet(this, _BundleGraph_options, "f"));
79
+ }
80
+ getAssetPublicId(asset) {
81
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetPublicId((0, Asset_1.assetToAssetValue)(asset));
82
+ }
83
+ isDependencySkipped(dep) {
84
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isDependencySkipped((0, Dependency_1.dependencyToInternalDependency)(dep));
85
+ }
86
+ getResolvedAsset(dep, bundle) {
87
+ let resolution = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getResolvedAsset((0, Dependency_1.dependencyToInternalDependency)(dep), bundle && (0, Bundle_1.bundleToInternalBundle)(bundle));
88
+ if (resolution) {
89
+ return (0, Asset_1.assetFromValue)(resolution, __classPrivateFieldGet(this, _BundleGraph_options, "f"));
90
+ }
91
+ }
92
+ getIncomingDependencies(asset) {
93
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
94
+ .getIncomingDependencies((0, Asset_1.assetToAssetValue)(asset))
95
+ .map((dep) => (0, Dependency_1.getPublicDependency)(dep, __classPrivateFieldGet(this, _BundleGraph_options, "f")));
96
+ }
97
+ getAssetWithDependency(dep) {
98
+ let asset = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetWithDependency((0, Dependency_1.dependencyToInternalDependency)(dep));
99
+ if (asset) {
100
+ return (0, Asset_1.assetFromValue)(asset, __classPrivateFieldGet(this, _BundleGraph_options, "f"));
101
+ }
102
+ }
103
+ getBundleGroupsContainingBundle(bundle) {
104
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
105
+ .getBundleGroupsContainingBundle((0, Bundle_1.bundleToInternalBundle)(bundle))
106
+ .map((bundleGroup) => new BundleGroup_1.default(bundleGroup, __classPrivateFieldGet(this, _BundleGraph_options, "f")));
107
+ }
108
+ getReferencedBundles(bundle, opts) {
109
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
110
+ .getReferencedBundles((0, Bundle_1.bundleToInternalBundle)(bundle), opts)
111
+ .map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
112
+ }
113
+ getReferencingBundles(bundle) {
114
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
115
+ .getReferencingBundles((0, Bundle_1.bundleToInternalBundle)(bundle))
116
+ .map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
117
+ }
118
+ resolveAsyncDependency(dependency, bundle) {
119
+ let resolved = __classPrivateFieldGet(this, _BundleGraph_graph, "f").resolveAsyncDependency((0, Dependency_1.dependencyToInternalDependency)(dependency), bundle && (0, Bundle_1.bundleToInternalBundle)(bundle));
120
+ if (resolved == null) {
121
+ return;
122
+ }
123
+ else if (resolved.type === 'bundle_group') {
124
+ return {
125
+ type: 'bundle_group',
126
+ value: new BundleGroup_1.default(resolved.value, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
127
+ };
128
+ }
129
+ return {
130
+ type: 'asset',
131
+ value: (0, Asset_1.assetFromValue)(resolved.value, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
132
+ };
133
+ }
134
+ getReferencedBundle(dependency, bundle) {
135
+ let result = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getReferencedBundle((0, Dependency_1.dependencyToInternalDependency)(dependency), (0, Bundle_1.bundleToInternalBundle)(bundle));
136
+ if (result != null) {
137
+ return __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, result, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f"));
138
+ }
139
+ }
140
+ getDependencies(asset) {
141
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
142
+ .getDependencies((0, Asset_1.assetToAssetValue)(asset))
143
+ .map((dep) => (0, Dependency_1.getPublicDependency)(dep, __classPrivateFieldGet(this, _BundleGraph_options, "f")));
144
+ }
145
+ isAssetReachableFromBundle(asset, bundle) {
146
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isAssetReachableFromBundle((0, Asset_1.assetToAssetValue)(asset), (0, Bundle_1.bundleToInternalBundle)(bundle));
147
+ }
148
+ isAssetReferenced(bundle, asset) {
149
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isAssetReferenced((0, Bundle_1.bundleToInternalBundle)(bundle), (0, Asset_1.assetToAssetValue)(asset));
150
+ }
151
+ isAssetReferencedFastCheck(bundle, asset) {
152
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isAssetReferencedFastCheck((0, Bundle_1.bundleToInternalBundle)(bundle), (0, Asset_1.assetToAssetValue)(asset));
153
+ }
154
+ getReferencedAssets(bundle) {
155
+ let internalReferencedAssets = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getReferencedAssets((0, Bundle_1.bundleToInternalBundle)(bundle));
156
+ // Convert internal assets to public assets
157
+ let publicReferencedAssets = new Set();
158
+ for (let internalAsset of internalReferencedAssets) {
159
+ publicReferencedAssets.add((0, Asset_1.assetFromValue)(internalAsset, __classPrivateFieldGet(this, _BundleGraph_options, "f")));
160
+ }
161
+ return publicReferencedAssets;
162
+ }
163
+ hasParentBundleOfType(bundle, type) {
164
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").hasParentBundleOfType((0, Bundle_1.bundleToInternalBundle)(bundle), type);
165
+ }
166
+ getBundlesInBundleGroup(bundleGroup, opts) {
167
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
168
+ .getBundlesInBundleGroup((0, BundleGroup_1.bundleGroupToInternalBundleGroup)(bundleGroup), opts)
169
+ .map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
170
+ }
171
+ getBundles(opts) {
172
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
173
+ .getBundles(opts)
174
+ .map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
175
+ }
176
+ isEntryBundleGroup(bundleGroup) {
177
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").isEntryBundleGroup((0, BundleGroup_1.bundleGroupToInternalBundleGroup)(bundleGroup));
178
+ }
179
+ getChildBundles(bundle) {
180
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
181
+ .getChildBundles((0, Bundle_1.bundleToInternalBundle)(bundle))
182
+ .map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
183
+ }
184
+ getParentBundles(bundle) {
185
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
186
+ .getParentBundles((0, Bundle_1.bundleToInternalBundle)(bundle))
187
+ .map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
188
+ }
189
+ getSymbolResolution(asset, symbol, boundary) {
190
+ let res = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getSymbolResolution((0, Asset_1.assetToAssetValue)(asset), symbol, boundary ? (0, Bundle_1.bundleToInternalBundle)(boundary) : null);
191
+ return {
192
+ asset: (0, Asset_1.assetFromValue)(res.asset, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
193
+ exportSymbol: res.exportSymbol,
194
+ symbol: res.symbol,
195
+ loc: (0, utils_1.fromInternalSourceLocation)(__classPrivateFieldGet(this, _BundleGraph_options, "f").projectRoot, res.loc),
196
+ };
197
+ }
198
+ getExportedSymbols(asset, boundary) {
199
+ let res = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getExportedSymbols((0, Asset_1.assetToAssetValue)(asset), boundary ? (0, Bundle_1.bundleToInternalBundle)(boundary) : null);
200
+ return res.map((e) => ({
201
+ asset: (0, Asset_1.assetFromValue)(e.asset, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
202
+ exportSymbol: e.exportSymbol,
203
+ symbol: e.symbol,
204
+ loc: (0, utils_1.fromInternalSourceLocation)(__classPrivateFieldGet(this, _BundleGraph_options, "f").projectRoot, e.loc),
205
+ exportAs: e.exportAs,
206
+ }));
207
+ }
208
+ traverse(visit, start, opts) {
209
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").traverse(
210
+ // @ts-expect-error TS2345
211
+ (0, graph_1.mapVisitor)((node, actions) => {
212
+ // Skipping unused dependencies here is faster than doing an isDependencySkipped check inside the visitor
213
+ // because the node needs to be re-looked up by id from the hashmap.
214
+ if (opts?.skipUnusedDependencies &&
215
+ node.type === 'dependency' &&
216
+ (node.hasDeferred || node.excluded)) {
217
+ actions.skipChildren();
218
+ return null;
219
+ }
220
+ return node.type === 'asset'
221
+ ? { type: 'asset', value: (0, Asset_1.assetFromValue)(node.value, __classPrivateFieldGet(this, _BundleGraph_options, "f")) }
222
+ : {
223
+ type: 'dependency',
224
+ value: (0, Dependency_1.getPublicDependency)(node.value, __classPrivateFieldGet(this, _BundleGraph_options, "f")),
225
+ };
226
+ }, visit), start ? (0, Asset_1.assetToAssetValue)(start) : undefined);
227
+ }
228
+ traverseBundles(visit, startBundle) {
229
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").traverseBundles((0, graph_1.mapVisitor)((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")), visit), startBundle == null ? undefined : (0, Bundle_1.bundleToInternalBundle)(startBundle));
230
+ }
231
+ getBundlesWithAsset(asset) {
232
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
233
+ .getBundlesWithAsset((0, Asset_1.assetToAssetValue)(asset))
234
+ .map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
235
+ }
236
+ getBundlesWithDependency(dependency) {
237
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
238
+ .getBundlesWithDependency((0, Dependency_1.dependencyToInternalDependency)(dependency))
239
+ .map((bundle) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, bundle, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
240
+ }
241
+ getUsedSymbols(v) {
242
+ if (v instanceof Asset_1.Asset) {
243
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").getUsedSymbolsAsset((0, Asset_1.assetToAssetValue)(v));
244
+ }
245
+ else {
246
+ (0, assert_1.default)(v instanceof Dependency_1.default);
247
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").getUsedSymbolsDependency((0, Dependency_1.dependencyToInternalDependency)(v));
248
+ }
249
+ }
250
+ getEntryRoot(target) {
251
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f").getEntryRoot(__classPrivateFieldGet(this, _BundleGraph_options, "f").projectRoot, (0, Target_1.targetToInternalTarget)(target));
252
+ }
253
+ // Given a set of dependencies, return any conditions where those dependencies are either
254
+ // the true or false dependency for those conditions. This is currently used to work out which
255
+ // conditions belong to a bundle in packaging.
256
+ getConditionsForDependencies(deps, bundle) {
257
+ const conditions = new Set();
258
+ const depIds = deps.map((dep) => dep.id);
259
+ for (const condition of __classPrivateFieldGet(this, _BundleGraph_graph, "f")._conditions.values()) {
260
+ if (depIds.includes(condition.ifTrueDependency.id) ||
261
+ depIds.includes(condition.ifFalseDependency.id)) {
262
+ const [[trueAsset, ifTrueBundles], [falseAsset, ifFalseBundles]] = [
263
+ condition.ifTrueDependency,
264
+ condition.ifFalseDependency,
265
+ ].map((dep) => {
266
+ const asset = __classPrivateFieldGet(this, _BundleGraph_graph, "f").getResolvedAsset(dep, (0, Bundle_1.bundleToInternalBundle)(bundle));
267
+ if (asset &&
268
+ __classPrivateFieldGet(this, _BundleGraph_graph, "f").bundleHasAsset((0, Bundle_1.bundleToInternalBundle)(bundle), asset)) {
269
+ // Asset is in the same bundle, we know it doesn't need to be loaded externally
270
+ return [asset, []];
271
+ }
272
+ const resolvedAsync = __classPrivateFieldGet(this, _BundleGraph_graph, "f").resolveAsyncDependency(dep, (0, Bundle_1.bundleToInternalBundle)(bundle));
273
+ if (resolvedAsync?.type === 'asset') {
274
+ // Single bundle to load dynamically
275
+ return [
276
+ resolvedAsync.value,
277
+ [
278
+ __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, (0, nullthrows_1.default)(__classPrivateFieldGet(this, _BundleGraph_graph, "f").getReferencedBundle(dep, (0, Bundle_1.bundleToInternalBundle)(bundle)), `Failed to load referenced bundle for '${dep.specifier}' specifier from '${String(dep.sourcePath)}'`), __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")),
279
+ ],
280
+ ];
281
+ }
282
+ else if (resolvedAsync) {
283
+ // Bundle group means we have multiple bundles to load first
284
+ return [
285
+ __classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetById(resolvedAsync.value.entryAssetId),
286
+ __classPrivateFieldGet(this, _BundleGraph_graph, "f")
287
+ .getBundlesInBundleGroup(resolvedAsync.value)
288
+ .map((b) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, b, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f"))),
289
+ ];
290
+ }
291
+ else {
292
+ return [
293
+ (0, nullthrows_1.default)(asset, `Failed to load depenendency for '${dep.specifier}' specifier from '${String(dep.sourcePath)}'`),
294
+ [],
295
+ ];
296
+ }
297
+ });
298
+ conditions.add({
299
+ publicId: condition.publicId,
300
+ key: condition.key,
301
+ ifTrueDependency: (0, nullthrows_1.default)(deps.find((dep) => dep.id === condition.ifTrueDependency.id), 'ifTrueDependency was null'),
302
+ ifFalseDependency: (0, nullthrows_1.default)(deps.find((dep) => dep.id === condition.ifFalseDependency.id), 'ifFalseDependency was null'),
303
+ ifTrueBundles,
304
+ ifFalseBundles,
305
+ ifTrueAssetId: __classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetPublicId(trueAsset),
306
+ ifFalseAssetId: __classPrivateFieldGet(this, _BundleGraph_graph, "f").getAssetPublicId(falseAsset),
307
+ });
308
+ }
309
+ }
310
+ // @ts-expect-error TS2322
311
+ return conditions;
312
+ }
313
+ // This is used to generate information for building a manifest that can
314
+ // be used by a webserver to understand which conditions are used by which bundles,
315
+ // and which bundles those conditions require depending on what they evaluate to.
316
+ getConditionalBundleMapping() {
317
+ let bundleConditions = new Map();
318
+ // Convert the internal references in conditions to public API references
319
+ for (const cond of __classPrivateFieldGet(this, _BundleGraph_graph, "f")._conditions.values()) {
320
+ let assets = Array.from(cond.assets).map((asset) => (0, nullthrows_1.default)(this.getAssetById(asset.id)));
321
+ let bundles = new Set();
322
+ let ifTrueBundles = [];
323
+ let ifFalseBundles = [];
324
+ for (const asset of assets) {
325
+ const bundlesWithAsset = this.getBundlesWithAsset(asset);
326
+ for (const bundle of bundlesWithAsset) {
327
+ bundles.add(bundle);
328
+ }
329
+ const assetDeps = this.getDependencies(asset);
330
+ const depToBundles = (dep) => {
331
+ const publicDep = (0, nullthrows_1.default)(assetDeps.find((assetDep) => dep.id === assetDep.id));
332
+ const resolved = this.resolveAsyncDependency(publicDep);
333
+ if (!resolved) {
334
+ // If there's no async dependency, don't list it as required
335
+ return [];
336
+ }
337
+ (0, assert_1.default)(resolved.type === 'bundle_group');
338
+ return this.getBundlesInBundleGroup(resolved.value);
339
+ };
340
+ // @ts-expect-error TS2345
341
+ ifTrueBundles.push(...depToBundles(cond.ifTrueDependency));
342
+ // @ts-expect-error TS2345
343
+ ifFalseBundles.push(...depToBundles(cond.ifFalseDependency));
344
+ }
345
+ for (let bundle of bundles) {
346
+ const conditions = bundleConditions.get(bundle.id) ?? new Map();
347
+ const currentCondition = conditions.get(cond.key);
348
+ conditions.set(cond.key, {
349
+ bundle,
350
+ ifTrueBundles: [
351
+ ...(currentCondition?.ifTrueBundles ?? []),
352
+ ...ifTrueBundles,
353
+ ],
354
+ ifFalseBundles: [
355
+ ...(currentCondition?.ifFalseBundles ?? []),
356
+ ...ifFalseBundles,
357
+ ],
358
+ });
359
+ bundleConditions.set(bundle.id, conditions);
360
+ }
361
+ }
362
+ return bundleConditions;
363
+ }
364
+ getReferencedConditionalBundles(bundle) {
365
+ return __classPrivateFieldGet(this, _BundleGraph_graph, "f")
366
+ .getReferencedConditionalBundles((0, Bundle_1.bundleToInternalBundle)(bundle))
367
+ .map((result) => __classPrivateFieldGet(this, _BundleGraph_createBundle, "f").call(this, result, __classPrivateFieldGet(this, _BundleGraph_graph, "f"), __classPrivateFieldGet(this, _BundleGraph_options, "f")));
368
+ }
369
+ }
370
+ _BundleGraph_graph = new WeakMap(), _BundleGraph_options = new WeakMap(), _BundleGraph_createBundle = new WeakMap();
371
+ exports.default = BundleGraph;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
+ if (kind === "m") throw new TypeError("Private method is not writable");
4
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
+ };
8
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
+ };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
16
+ var _BundleGroup_bundleGroup, _BundleGroup_options;
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.bundleGroupToInternalBundleGroup = bundleGroupToInternalBundleGroup;
19
+ const nullthrows_1 = __importDefault(require("nullthrows"));
20
+ const Target_1 = __importDefault(require("./Target"));
21
+ const internalBundleGroupToBundleGroup = new WeakMap();
22
+ const _bundleGroupToInternalBundleGroup = new WeakMap();
23
+ function bundleGroupToInternalBundleGroup(target) {
24
+ return (0, nullthrows_1.default)(_bundleGroupToInternalBundleGroup.get(target));
25
+ }
26
+ const inspect = Symbol.for('nodejs.util.inspect.custom');
27
+ class BundleGroup {
28
+ constructor(bundleGroup, options) {
29
+ // @ts-expect-error TS2564
30
+ _BundleGroup_bundleGroup.set(this, void 0);
31
+ // @ts-expect-error TS2564
32
+ _BundleGroup_options.set(this, void 0);
33
+ let existing = internalBundleGroupToBundleGroup.get(bundleGroup);
34
+ if (existing != null) {
35
+ return existing;
36
+ }
37
+ __classPrivateFieldSet(this, _BundleGroup_bundleGroup, bundleGroup, "f");
38
+ __classPrivateFieldSet(this, _BundleGroup_options, options, "f");
39
+ _bundleGroupToInternalBundleGroup.set(this, bundleGroup);
40
+ internalBundleGroupToBundleGroup.set(bundleGroup, this);
41
+ return this;
42
+ }
43
+ get target() {
44
+ return new Target_1.default(__classPrivateFieldGet(this, _BundleGroup_bundleGroup, "f").target, __classPrivateFieldGet(this, _BundleGroup_options, "f"));
45
+ }
46
+ get entryAssetId() {
47
+ return __classPrivateFieldGet(this, _BundleGroup_bundleGroup, "f").entryAssetId;
48
+ }
49
+ [(_BundleGroup_bundleGroup = new WeakMap(), _BundleGroup_options = new WeakMap(), inspect)]() {
50
+ return `BundleGroup(${this.entryAssetId})`;
51
+ }
52
+ }
53
+ exports.default = BundleGroup;