@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,381 @@
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 _AtlaspackWorker_resolvers, _AtlaspackWorker_transformers, _AtlaspackWorker_fs, _AtlaspackWorker_packageManager, _AtlaspackWorker_options, _AtlaspackWorker_sideEffectDetector;
50
+ Object.defineProperty(exports, "__esModule", { value: true });
51
+ exports.AtlaspackWorker = void 0;
52
+ /* eslint-disable import/first */
53
+ const side_effect_detector_1 = require("./side-effect-detector");
54
+ // Install side effect detection patches BEFORE importing any modules that use fs
55
+ const sideEffectDetector = new side_effect_detector_1.SideEffectDetector();
56
+ sideEffectDetector.install();
57
+ const assert_1 = __importDefault(require("assert"));
58
+ const napi = __importStar(require("@atlaspack/rust"));
59
+ const fs_1 = require("@atlaspack/fs");
60
+ const package_manager_1 = require("@atlaspack/package-manager");
61
+ const worker_threads_1 = require("worker_threads");
62
+ const module = __importStar(require("module"));
63
+ const jsCallable_1 = require("../jsCallable");
64
+ const compat_1 = require("./compat");
65
+ const CONFIG = Symbol.for('parcel-plugin-config');
66
+ class AtlaspackWorker {
67
+ constructor() {
68
+ _AtlaspackWorker_resolvers.set(this, void 0);
69
+ _AtlaspackWorker_transformers.set(this, void 0);
70
+ _AtlaspackWorker_fs.set(this, void 0);
71
+ _AtlaspackWorker_packageManager.set(this, void 0);
72
+ _AtlaspackWorker_options.set(this, void 0);
73
+ _AtlaspackWorker_sideEffectDetector.set(this, void 0);
74
+ this.loadPlugin = (0, jsCallable_1.jsCallable)(async ({ kind, specifier, resolveFrom, options }) => {
75
+ // Use packageManager.require() instead of dynamic import() to support TypeScript plugins
76
+ let resolvedModule = await __classPrivateFieldGet(this, _AtlaspackWorker_packageManager, "f").require(specifier, resolveFrom, { shouldAutoInstall: false });
77
+ let instance = undefined;
78
+ // Check for CommonJS export (module.exports = new Plugin(...))
79
+ if (resolvedModule[CONFIG]) {
80
+ instance = resolvedModule[CONFIG];
81
+ }
82
+ else if (resolvedModule.default && resolvedModule.default[CONFIG]) {
83
+ // ESM default export
84
+ instance = resolvedModule.default[CONFIG];
85
+ }
86
+ else if (resolvedModule.default &&
87
+ resolvedModule.default.default &&
88
+ resolvedModule.default.default[CONFIG]) {
89
+ // Double-wrapped default export
90
+ instance = resolvedModule.default.default[CONFIG];
91
+ }
92
+ else {
93
+ throw new Error(`Plugin could not be resolved\n\t${kind}\n\t${resolveFrom}\n\t${specifier}`);
94
+ }
95
+ if (__classPrivateFieldGet(this, _AtlaspackWorker_options, "f") == null) {
96
+ __classPrivateFieldSet(this, _AtlaspackWorker_options, {
97
+ ...options,
98
+ inputFS: __classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"),
99
+ outputFS: __classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"),
100
+ packageManager: __classPrivateFieldGet(this, _AtlaspackWorker_packageManager, "f"),
101
+ shouldAutoInstall: false,
102
+ }, "f");
103
+ }
104
+ // Set feature flags in the worker process
105
+ let featureFlagsModule = await __classPrivateFieldGet(this, _AtlaspackWorker_packageManager, "f").require('@atlaspack/feature-flags', __filename, { shouldAutoInstall: false });
106
+ featureFlagsModule.setFeatureFlags(options.featureFlags);
107
+ switch (kind) {
108
+ case 'resolver':
109
+ __classPrivateFieldGet(this, _AtlaspackWorker_resolvers, "f").set(specifier, { resolver: instance });
110
+ break;
111
+ case 'transformer': {
112
+ return this.initializeTransformer(instance, specifier);
113
+ }
114
+ }
115
+ });
116
+ this.runResolverResolve = (0, jsCallable_1.jsCallable)(async ({ key, dependency: napiDependency, specifier, pipeline }) => {
117
+ const state = __classPrivateFieldGet(this, _AtlaspackWorker_resolvers, "f").get(key);
118
+ if (!state) {
119
+ throw new Error(`Resolver not found: ${key}`);
120
+ }
121
+ const env = new compat_1.Environment(napiDependency.env);
122
+ const dependency = new compat_1.Dependency(napiDependency, env);
123
+ const defaultOptions = {
124
+ logger: new compat_1.PluginLogger(),
125
+ tracer: new compat_1.PluginTracer(),
126
+ options: new compat_1.PluginOptions(this.options),
127
+ };
128
+ if (!('config' in state)) {
129
+ // @ts-expect-error TS2345
130
+ state.config = await state.resolver.loadConfig?.({
131
+ config: new compat_1.PluginConfig({
132
+ env: napiDependency.env,
133
+ plugin: key,
134
+ isSource: true,
135
+ searchPath: 'index',
136
+ }, this.options),
137
+ ...defaultOptions,
138
+ });
139
+ }
140
+ // @ts-expect-error TS2345
141
+ const result = await state.resolver.resolve({
142
+ specifier,
143
+ dependency,
144
+ pipeline,
145
+ config: state.config,
146
+ ...defaultOptions,
147
+ });
148
+ if (!result) {
149
+ return {
150
+ invalidations: [],
151
+ resolution: { type: 'unresolved' },
152
+ };
153
+ }
154
+ if (result.isExcluded) {
155
+ return {
156
+ invalidations: [],
157
+ resolution: { type: 'excluded' },
158
+ };
159
+ }
160
+ return {
161
+ invalidations: [],
162
+ resolution: {
163
+ type: 'resolved',
164
+ filePath: result.filePath || '',
165
+ canDefer: result.canDefer || false,
166
+ sideEffects: result.sideEffects ?? true,
167
+ code: result.code || undefined,
168
+ meta: result.meta || undefined,
169
+ pipeline: result.pipeline || undefined,
170
+ priority: compat_1.dependencyPriorityMap.intoNullable(result.priority),
171
+ query: result.query && result.query.toString(),
172
+ },
173
+ };
174
+ });
175
+ this.runTransformerTransform = (0, jsCallable_1.jsCallable)(async ({ key, asset: innerAsset }, contents, map) => {
176
+ const instance = __classPrivateFieldGet(this, _AtlaspackWorker_transformers, "f").get(key);
177
+ if (!instance) {
178
+ throw new Error(`Transformer not found: ${key}`);
179
+ }
180
+ let { transformer, config, allowedEnv = new Set() } = instance;
181
+ let cacheBailouts = [];
182
+ const resolveFunc = (from, to) => {
183
+ let customRequire = module.createRequire(from);
184
+ let resolvedPath = customRequire.resolve(to);
185
+ // Tranformer not cacheable due to use of the resolve function
186
+ cacheBailouts.push(`resolve(${from}, ${to})`);
187
+ return Promise.resolve(resolvedPath);
188
+ };
189
+ const env = new compat_1.Environment(innerAsset.env);
190
+ let mutableAsset = new compat_1.MutableAsset(innerAsset,
191
+ // @ts-expect-error TS2345
192
+ contents, env, __classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"), map, this.options.projectRoot);
193
+ const pluginOptions = new compat_1.PluginOptions(this.options);
194
+ const defaultOptions = {
195
+ logger: new compat_1.PluginLogger(),
196
+ tracer: new compat_1.PluginTracer(),
197
+ options: pluginOptions,
198
+ };
199
+ if (transformer.loadConfig) {
200
+ if (config != null) {
201
+ throw new Error(`Transformer (${key}) should not implement 'setup' and 'loadConfig'`);
202
+ }
203
+ // @ts-expect-error TS2345
204
+ config = await transformer.loadConfig({
205
+ config: new compat_1.PluginConfig({
206
+ plugin: key,
207
+ isSource: innerAsset.isSource,
208
+ searchPath: innerAsset.filePath,
209
+ env,
210
+ }, this.options),
211
+ ...defaultOptions,
212
+ });
213
+ // Transformer uses the deprecated loadConfig API, so mark as not
214
+ // cachable
215
+ cacheBailouts.push(`Transformer.loadConfig`);
216
+ }
217
+ if (transformer.parse) {
218
+ const ast = await transformer.parse({
219
+ // @ts-expect-error TS2322
220
+ asset: mutableAsset,
221
+ config,
222
+ resolve: resolveFunc,
223
+ ...defaultOptions,
224
+ });
225
+ if (ast) {
226
+ mutableAsset.setAST(ast);
227
+ }
228
+ cacheBailouts.push(`Transformer.parse`);
229
+ }
230
+ const [result, sideEffects] = await __classPrivateFieldGet(this, _AtlaspackWorker_sideEffectDetector, "f").monitorSideEffects(key, () => transformer.transform({
231
+ // @ts-expect-error TS2322
232
+ asset: mutableAsset,
233
+ config,
234
+ resolve: resolveFunc,
235
+ ...defaultOptions,
236
+ }));
237
+ if (sideEffects.envUsage.didEnumerate) {
238
+ cacheBailouts.push(`Env access: enumeration of process.env`);
239
+ }
240
+ for (let variable of sideEffects.envUsage.vars) {
241
+ if (variable in allowedEnv) {
242
+ continue;
243
+ }
244
+ cacheBailouts.push(`Env access: ${variable}`);
245
+ }
246
+ for (let { method, path } of sideEffects.fsUsage) {
247
+ cacheBailouts.push(`FS usage: ${method}(${path})`);
248
+ }
249
+ (0, assert_1.default)(result.length === 1, '[V3] Unimplemented: Multiple asset return from Node transformer');
250
+ (0, assert_1.default)(result[0] === mutableAsset, '[V3] Unimplemented: New asset returned from Node transformer');
251
+ if (transformer.generate) {
252
+ const ast = await mutableAsset.getAST();
253
+ if (ast) {
254
+ const output = await transformer.generate({
255
+ // @ts-expect-error TS2322
256
+ asset: mutableAsset,
257
+ ast,
258
+ ...defaultOptions,
259
+ });
260
+ if (typeof output.content === 'string') {
261
+ mutableAsset.setCode(output.content);
262
+ }
263
+ else if (output.content instanceof Buffer) {
264
+ mutableAsset.setBuffer(output.content);
265
+ }
266
+ else {
267
+ // @ts-expect-error TS2345
268
+ mutableAsset.setStream(output.content);
269
+ }
270
+ if (output.map) {
271
+ mutableAsset.setMap(output.map);
272
+ }
273
+ }
274
+ }
275
+ let assetBuffer = await mutableAsset.getBuffer();
276
+ // If the asset has no code, we set the buffer to null, which we can
277
+ // detect in Rust, to avoid passing back an empty buffer, which we can't.
278
+ if (assetBuffer.length === 0) {
279
+ assetBuffer = null;
280
+ }
281
+ if (pluginOptions.used) {
282
+ // Plugin options accessed, so not cachable
283
+ cacheBailouts.push(`Plugin options accessed`);
284
+ }
285
+ return [
286
+ {
287
+ id: mutableAsset.id,
288
+ bundleBehavior: compat_1.bundleBehaviorMap.intoNullable(mutableAsset.bundleBehavior),
289
+ code: [],
290
+ filePath: mutableAsset.filePath,
291
+ isBundleSplittable: mutableAsset.isBundleSplittable,
292
+ isSource: mutableAsset.isSource,
293
+ meta: mutableAsset.meta,
294
+ pipeline: mutableAsset.pipeline,
295
+ // Query should be undefined if it's empty
296
+ query: mutableAsset.query.toString() || undefined,
297
+ sideEffects: mutableAsset.sideEffects,
298
+ symbols: mutableAsset.symbols.intoNapi(),
299
+ type: mutableAsset.type,
300
+ uniqueKey: mutableAsset.uniqueKey,
301
+ },
302
+ assetBuffer,
303
+ // Only send back the map if it has changed
304
+ mutableAsset.isMapDirty
305
+ ? // @ts-expect-error TS2533
306
+ JSON.stringify((await mutableAsset.getMap()).toVLQ())
307
+ : '',
308
+ // Limit to first 10 bailouts
309
+ cacheBailouts.slice(0, 10),
310
+ ];
311
+ });
312
+ __classPrivateFieldSet(this, _AtlaspackWorker_resolvers, new Map(), "f");
313
+ __classPrivateFieldSet(this, _AtlaspackWorker_transformers, new Map(), "f");
314
+ __classPrivateFieldSet(this, _AtlaspackWorker_fs, new fs_1.NodeFS(), "f");
315
+ __classPrivateFieldSet(this, _AtlaspackWorker_packageManager, new package_manager_1.NodePackageManager(__classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"), '/'), "f");
316
+ __classPrivateFieldSet(this, _AtlaspackWorker_sideEffectDetector, sideEffectDetector, "f"); // Use the global detector that was installed before imports
317
+ }
318
+ clearState() {
319
+ __classPrivateFieldGet(this, _AtlaspackWorker_resolvers, "f").clear();
320
+ __classPrivateFieldGet(this, _AtlaspackWorker_transformers, "f").clear();
321
+ __classPrivateFieldSet(this, _AtlaspackWorker_options, undefined, "f");
322
+ }
323
+ get options() {
324
+ if (__classPrivateFieldGet(this, _AtlaspackWorker_options, "f") == null) {
325
+ throw new Error('Plugin options have not been initialized');
326
+ }
327
+ return __classPrivateFieldGet(this, _AtlaspackWorker_options, "f");
328
+ }
329
+ async initializeTransformer(instance, specifier) {
330
+ let transformer = instance;
331
+ let setup, config, allowedEnv;
332
+ let packageManager = new package_manager_1.NodePackageManager(__classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"), this.options.projectRoot);
333
+ if (transformer.setup) {
334
+ let setupResult = await transformer.setup({
335
+ logger: new compat_1.PluginLogger(),
336
+ options: new compat_1.PluginOptions({
337
+ ...this.options,
338
+ shouldAutoInstall: false,
339
+ inputFS: __classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"),
340
+ outputFS: __classPrivateFieldGet(this, _AtlaspackWorker_fs, "f"),
341
+ packageManager,
342
+ }),
343
+ config: new compat_1.PluginConfig({
344
+ plugin: specifier,
345
+ searchPath: 'index',
346
+ // Consider project setup config as source
347
+ isSource: true,
348
+ }, this.options),
349
+ });
350
+ config = setupResult?.config;
351
+ allowedEnv = Object.fromEntries(setupResult?.env?.map((env) => [env, process.env[env]]) || []);
352
+ // Always add the following env vars to the cache key
353
+ allowedEnv['NODE_ENV'] = process.env['NODE_ENV'];
354
+ setup = {
355
+ conditions: setupResult?.conditions,
356
+ config,
357
+ env: allowedEnv,
358
+ };
359
+ }
360
+ __classPrivateFieldGet(this, _AtlaspackWorker_transformers, "f").set(specifier, {
361
+ transformer,
362
+ config,
363
+ packageManager,
364
+ allowedEnv,
365
+ });
366
+ return setup;
367
+ }
368
+ }
369
+ exports.AtlaspackWorker = AtlaspackWorker;
370
+ _AtlaspackWorker_resolvers = new WeakMap(), _AtlaspackWorker_transformers = new WeakMap(), _AtlaspackWorker_fs = new WeakMap(), _AtlaspackWorker_packageManager = new WeakMap(), _AtlaspackWorker_options = new WeakMap(), _AtlaspackWorker_sideEffectDetector = new WeakMap();
371
+ // Create napi worker and send it back to main thread
372
+ const worker = new AtlaspackWorker();
373
+ const napiWorker = napi.newNodejsWorker(worker);
374
+ worker_threads_1.parentPort?.postMessage(napiWorker);
375
+ worker_threads_1.parentPort?.setMaxListeners(worker_threads_1.parentPort.getMaxListeners() + 1);
376
+ worker_threads_1.parentPort?.addListener('message', (message) => {
377
+ if (message === 'clearState') {
378
+ worker.clearState();
379
+ worker_threads_1.parentPort?.postMessage('stateCleared');
380
+ }
381
+ });
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERROR = exports.STARTUP = exports.OPTION_CHANGE = exports.ENV_CHANGE = exports.FILE_DELETE = exports.FILE_UPDATE = exports.FILE_CREATE = exports.INITIAL_BUILD = exports.VALID = exports.HASH_REF_REGEX = exports.HASH_REF_HASH_LEN = exports.HASH_REF_PREFIX = exports.ATLASPACK_VERSION = void 0;
4
+ const package_json_1 = require("../package.json");
5
+ exports.ATLASPACK_VERSION = package_json_1.version;
6
+ exports.HASH_REF_PREFIX = 'HASH_REF_';
7
+ exports.HASH_REF_HASH_LEN = 16;
8
+ exports.HASH_REF_REGEX = new RegExp(`${exports.HASH_REF_PREFIX}\\w{${exports.HASH_REF_HASH_LEN}}`, 'g');
9
+ exports.VALID = 0;
10
+ exports.INITIAL_BUILD = 1 << 0;
11
+ exports.FILE_CREATE = 1 << 1;
12
+ exports.FILE_UPDATE = 1 << 2;
13
+ exports.FILE_DELETE = 1 << 3;
14
+ exports.ENV_CHANGE = 1 << 4;
15
+ exports.OPTION_CHANGE = 1 << 5;
16
+ exports.STARTUP = 1 << 6;
17
+ exports.ERROR = 1 << 7;
@@ -0,0 +1,281 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = dumpGraphToGraphViz;
7
+ const path_1 = __importDefault(require("path"));
8
+ const graph_1 = require("@atlaspack/graph");
9
+ const projectPath_1 = require("./projectPath");
10
+ const types_1 = require("./types");
11
+ const COLORS = {
12
+ root: 'gray',
13
+ asset: 'green',
14
+ dependency: 'orange',
15
+ transformer_request: 'cyan',
16
+ file: 'gray',
17
+ default: 'white',
18
+ };
19
+ const TYPE_COLORS = {
20
+ // bundle graph
21
+ bundle: 'blue',
22
+ contains: 'grey',
23
+ internal_async: 'orange',
24
+ references: 'red',
25
+ sibling: 'green',
26
+ // asset graph
27
+ // request graph
28
+ invalidated_by_create: 'green',
29
+ invalidated_by_create_above: 'orange',
30
+ invalidate_by_update: 'cyan',
31
+ invalidated_by_delete: 'red',
32
+ };
33
+ async function dumpGraphToGraphViz(graph, name, edgeTypes) {
34
+ if (process.env.ATLASPACK_BUILD_ENV === 'production' &&
35
+ !process.env.ATLASPACK_BUILD_REPL) {
36
+ return;
37
+ }
38
+ let mode = process.env.ATLASPACK_BUILD_REPL
39
+ ? // @ts-expect-error TS7017
40
+ globalThis.ATLASPACK_DUMP_GRAPHVIZ?.mode
41
+ : process.env.ATLASPACK_DUMP_GRAPHVIZ;
42
+ // @ts-expect-error TS2367
43
+ if (mode == null || mode == false) {
44
+ return;
45
+ }
46
+ let detailedSymbols = mode === 'symbols';
47
+ let GraphVizGraph = require('graphviz/lib/deps/graph').Graph;
48
+ let g = new GraphVizGraph(null, 'G');
49
+ g.type = 'digraph';
50
+ for (let [id, node] of graph.nodes.entries()) {
51
+ if (node == null)
52
+ continue;
53
+ let n = g.addNode(nodeId(id));
54
+ // @ts-expect-error TS7053
55
+ n.set('color', COLORS[node.type || 'default']);
56
+ n.set('shape', 'box');
57
+ n.set('style', 'filled');
58
+ let label;
59
+ if (typeof node === 'string') {
60
+ label = node;
61
+ // @ts-expect-error TS2339
62
+ }
63
+ else if (node.assets) {
64
+ // @ts-expect-error TS2339
65
+ label = `(${nodeId(id)}), (assetIds: ${[...node.assets]
66
+ .map((a) => {
67
+ let arr = a.filePath.split('/');
68
+ return arr[arr.length - 1];
69
+ })
70
+ // @ts-expect-error TS2339
71
+ .join(', ')}) (sourceBundles: ${[...node.sourceBundles].join(', ')}) (bb ${node.bundleBehavior ?? 'none'})`;
72
+ // @ts-expect-error TS2339
73
+ }
74
+ else if (node.type) {
75
+ // @ts-expect-error TS2339
76
+ label = `[${(0, graph_1.fromNodeId)(id)}] ${node.type || 'No Type'}: [${node.id}]: `;
77
+ // @ts-expect-error TS2339
78
+ if (node.type === 'dependency') {
79
+ // @ts-expect-error TS2339
80
+ label += node.value.specifier;
81
+ let parts = [];
82
+ // @ts-expect-error TS2339
83
+ if (node.value.priority !== types_1.Priority.sync) {
84
+ parts.push(Object.entries(types_1.Priority).find(
85
+ // @ts-expect-error TS2339
86
+ ([, v]) => v === node.value.priority)?.[0]);
87
+ }
88
+ // @ts-expect-error TS2339
89
+ if (node.value.isOptional)
90
+ parts.push('optional');
91
+ // @ts-expect-error TS2339
92
+ if (node.value.specifierType === types_1.SpecifierType.url)
93
+ parts.push('url');
94
+ // @ts-expect-error TS2339
95
+ if (node.hasDeferred)
96
+ parts.push('deferred');
97
+ // @ts-expect-error TS2339
98
+ if (node.deferred)
99
+ parts.push('deferred');
100
+ // @ts-expect-error TS2339
101
+ if (node.excluded)
102
+ parts.push('excluded');
103
+ if (parts.length)
104
+ label += ' (' + parts.join(', ') + ')';
105
+ // @ts-expect-error TS2339
106
+ if (node.value.env)
107
+ label += ` (${getEnvDescription(node.value.env)})`;
108
+ // @ts-expect-error TS2339
109
+ let depSymbols = node.value.symbols;
110
+ if (detailedSymbols) {
111
+ if (depSymbols) {
112
+ if (depSymbols.size) {
113
+ label +=
114
+ '\\nsymbols: ' +
115
+ [...depSymbols]
116
+ .map(([e, { local }]) => [e, local])
117
+ .join(';');
118
+ }
119
+ let weakSymbols = [...depSymbols]
120
+ .filter(([, { isWeak }]) => isWeak)
121
+ .map(([s]) => s);
122
+ if (weakSymbols.length) {
123
+ label += '\\nweakSymbols: ' + weakSymbols.join(',');
124
+ }
125
+ // @ts-expect-error TS2339
126
+ if (node.usedSymbolsUp.size > 0) {
127
+ label +=
128
+ '\\nusedSymbolsUp: ' +
129
+ // @ts-expect-error TS2339
130
+ [...node.usedSymbolsUp]
131
+ .map(([s, sAsset]) => sAsset
132
+ ? `${s}(${sAsset.asset}.${sAsset.symbol ?? ''})`
133
+ : sAsset === null
134
+ ? `${s}(external)`
135
+ : `${s}(ambiguous)`)
136
+ .join(',');
137
+ }
138
+ // @ts-expect-error TS2339
139
+ if (node.usedSymbolsDown.size > 0) {
140
+ label +=
141
+ // @ts-expect-error TS2339
142
+ '\\nusedSymbolsDown: ' + [...node.usedSymbolsDown].join(',');
143
+ }
144
+ // if (node.usedSymbolsDownDirty) label += '\\nusedSymbolsDownDirty';
145
+ // if (node.usedSymbolsUpDirtyDown)
146
+ // label += '\\nusedSymbolsUpDirtyDown';
147
+ // if (node.usedSymbolsUpDirtyUp) label += '\\nusedSymbolsUpDirtyUp';
148
+ }
149
+ else {
150
+ label += '\\nsymbols: cleared';
151
+ }
152
+ }
153
+ // @ts-expect-error TS2339
154
+ }
155
+ else if (node.type === 'asset') {
156
+ label +=
157
+ // @ts-expect-error TS2339
158
+ path_1.default.basename((0, projectPath_1.fromProjectPathRelative)(node.value.filePath)) +
159
+ '#' +
160
+ // @ts-expect-error TS2339
161
+ node.value.type;
162
+ if (detailedSymbols) {
163
+ // @ts-expect-error TS2339
164
+ if (!node.value.symbols) {
165
+ label += '\\nsymbols: cleared';
166
+ // @ts-expect-error TS2339
167
+ }
168
+ else if (node.value.symbols.size) {
169
+ label +=
170
+ '\\nsymbols: ' +
171
+ // @ts-expect-error TS2339
172
+ [...node.value.symbols]
173
+ .map(([e, { local }]) => [e, local])
174
+ .join(';');
175
+ }
176
+ // @ts-expect-error TS2339
177
+ if (node.usedSymbols.size) {
178
+ // @ts-expect-error TS2339
179
+ label += '\\nusedSymbols: ' + [...node.usedSymbols].join(',');
180
+ }
181
+ // if (node.usedSymbolsDownDirty) label += '\\nusedSymbolsDownDirty';
182
+ // if (node.usedSymbolsUpDirty) label += '\\nusedSymbolsUpDirty';
183
+ }
184
+ else {
185
+ label += '\\nsymbols: cleared';
186
+ }
187
+ // @ts-expect-error TS2339
188
+ }
189
+ else if (node.type === 'asset_group') {
190
+ // @ts-expect-error TS2339
191
+ if (node.deferred)
192
+ label += '(deferred)';
193
+ // @ts-expect-error TS2339
194
+ }
195
+ else if (node.type === 'file') {
196
+ // @ts-expect-error TS2339
197
+ label += path_1.default.basename(node.id);
198
+ // @ts-expect-error TS2339
199
+ }
200
+ else if (node.type === 'transformer_request') {
201
+ label +=
202
+ // @ts-expect-error TS2339
203
+ path_1.default.basename(node.value.filePath) +
204
+ // @ts-expect-error TS2339
205
+ ` (${getEnvDescription(node.value.env)})`;
206
+ // @ts-expect-error TS2339
207
+ }
208
+ else if (node.type === 'bundle') {
209
+ let parts = [];
210
+ // @ts-expect-error TS2339
211
+ if (node.value.needsStableName)
212
+ parts.push('stable name');
213
+ // @ts-expect-error TS2339
214
+ parts.push(node.value.name);
215
+ // @ts-expect-error TS2339
216
+ parts.push('bb:' + (node.value.bundleBehavior ?? 'null'));
217
+ // @ts-expect-error TS2339
218
+ if (node.value.isPlaceholder)
219
+ parts.push('placeholder');
220
+ if (parts.length)
221
+ label += ' (' + parts.join(', ') + ')';
222
+ // @ts-expect-error TS2339
223
+ if (node.value.env)
224
+ label += ` (${getEnvDescription(node.value.env)})`;
225
+ // @ts-expect-error TS2339
226
+ }
227
+ else if (node.type === 'request') {
228
+ // @ts-expect-error TS2339
229
+ label = node.requestType + ':' + node.id;
230
+ }
231
+ }
232
+ n.set('label', label);
233
+ }
234
+ let edgeNames;
235
+ if (edgeTypes) {
236
+ edgeNames = Object.fromEntries(Object.entries(edgeTypes).map(([k, v]) => [v, k]));
237
+ }
238
+ // @ts-expect-error TS2488
239
+ for (let edge of graph.getAllEdges()) {
240
+ let gEdge = g.addEdge(nodeId(edge.from), nodeId(edge.to));
241
+ let color = null;
242
+ if (edge.type != 1 && edgeNames) {
243
+ // @ts-expect-error TS7053
244
+ color = TYPE_COLORS[edgeNames[edge.type]];
245
+ }
246
+ if (color != null) {
247
+ gEdge.set('color', color);
248
+ }
249
+ }
250
+ if (process.env.ATLASPACK_BUILD_REPL) {
251
+ // @ts-expect-error TS7017
252
+ globalThis.ATLASPACK_DUMP_GRAPHVIZ?.(name, g.to_dot());
253
+ }
254
+ else {
255
+ const tempy = require('tempy');
256
+ let tmp = tempy.file({ name: `parcel-${name}.png` });
257
+ await g.output('png', tmp);
258
+ // eslint-disable-next-line no-console
259
+ console.log('Dumped', tmp);
260
+ }
261
+ }
262
+ // @ts-expect-error TS2552
263
+ function nodeId(id) {
264
+ return `node${id}`;
265
+ }
266
+ function getEnvDescription(env) {
267
+ let description;
268
+ if (typeof env.engines.browsers === 'string') {
269
+ description = `${env.context}: ${env.engines.browsers}`;
270
+ }
271
+ else if (Array.isArray(env.engines.browsers)) {
272
+ description = `${env.context}: ${env.engines.browsers.join(', ')}`;
273
+ }
274
+ else if (env.engines.node) {
275
+ description = `node: ${env.engines.node}`;
276
+ }
277
+ else if (env.engines.electron) {
278
+ description = `electron: ${env.engines.electron}`;
279
+ }
280
+ return description ?? '';
281
+ }