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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/CHANGELOG.md +665 -0
  2. package/dist/AssetGraph.js +591 -0
  3. package/dist/Atlaspack.js +658 -0
  4. package/dist/AtlaspackConfig.js +324 -0
  5. package/dist/AtlaspackConfig.schema.js +108 -0
  6. package/dist/BundleGraph.js +1635 -0
  7. package/dist/CommittedAsset.js +142 -0
  8. package/dist/Dependency.js +125 -0
  9. package/dist/Environment.js +132 -0
  10. package/dist/EnvironmentManager.js +108 -0
  11. package/dist/IdentifierRegistry.js +38 -0
  12. package/dist/InternalConfig.js +37 -0
  13. package/dist/PackagerRunner.js +545 -0
  14. package/dist/ReporterRunner.js +151 -0
  15. package/dist/RequestTracker.js +1360 -0
  16. package/dist/SymbolPropagation.js +620 -0
  17. package/dist/TargetDescriptor.schema.js +143 -0
  18. package/dist/Transformation.js +490 -0
  19. package/dist/UncommittedAsset.js +315 -0
  20. package/dist/Validation.js +196 -0
  21. package/dist/applyRuntimes.js +305 -0
  22. package/dist/assetUtils.js +168 -0
  23. package/dist/atlaspack-v3/AtlaspackV3.js +70 -0
  24. package/dist/atlaspack-v3/NapiWorkerPool.js +57 -0
  25. package/dist/atlaspack-v3/fs.js +52 -0
  26. package/dist/atlaspack-v3/index.js +25 -0
  27. package/dist/atlaspack-v3/jsCallable.js +16 -0
  28. package/dist/atlaspack-v3/worker/compat/asset-symbols.js +190 -0
  29. package/dist/atlaspack-v3/worker/compat/bitflags.js +94 -0
  30. package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
  31. package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
  32. package/dist/atlaspack-v3/worker/compat/index.js +25 -0
  33. package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
  34. package/dist/atlaspack-v3/worker/compat/plugin-config.js +76 -0
  35. package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
  36. package/dist/atlaspack-v3/worker/compat/plugin-options.js +122 -0
  37. package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
  38. package/dist/atlaspack-v3/worker/compat/target.js +14 -0
  39. package/dist/atlaspack-v3/worker/worker.js +297 -0
  40. package/dist/constants.js +17 -0
  41. package/dist/dumpGraphToGraphViz.js +281 -0
  42. package/dist/index.js +62 -0
  43. package/dist/loadAtlaspackPlugin.js +128 -0
  44. package/dist/loadDotEnv.js +41 -0
  45. package/dist/projectPath.js +83 -0
  46. package/dist/public/Asset.js +279 -0
  47. package/dist/public/Bundle.js +224 -0
  48. package/dist/public/BundleGraph.js +359 -0
  49. package/dist/public/BundleGroup.js +53 -0
  50. package/dist/public/Config.js +286 -0
  51. package/dist/public/Dependency.js +138 -0
  52. package/dist/public/Environment.js +278 -0
  53. package/dist/public/MutableBundleGraph.js +277 -0
  54. package/dist/public/PluginOptions.js +80 -0
  55. package/dist/public/Symbols.js +248 -0
  56. package/dist/public/Target.js +69 -0
  57. package/dist/registerCoreWithSerializer.js +38 -0
  58. package/dist/requests/AssetGraphRequest.js +429 -0
  59. package/dist/requests/AssetGraphRequestRust.js +262 -0
  60. package/dist/requests/AssetRequest.js +130 -0
  61. package/dist/requests/AtlaspackBuildRequest.js +65 -0
  62. package/dist/requests/AtlaspackConfigRequest.js +493 -0
  63. package/dist/requests/BundleGraphRequest.js +445 -0
  64. package/dist/requests/ConfigRequest.js +222 -0
  65. package/dist/requests/DevDepRequest.js +204 -0
  66. package/dist/requests/EntryRequest.js +314 -0
  67. package/dist/requests/PackageRequest.js +62 -0
  68. package/dist/requests/PathRequest.js +349 -0
  69. package/dist/requests/TargetRequest.js +1311 -0
  70. package/dist/requests/ValidationRequest.js +49 -0
  71. package/dist/requests/WriteBundleRequest.js +254 -0
  72. package/dist/requests/WriteBundlesRequest.js +184 -0
  73. package/dist/requests/asset-graph-diff.js +128 -0
  74. package/dist/requests/asset-graph-dot.js +131 -0
  75. package/dist/resolveOptions.js +268 -0
  76. package/dist/rustWorkerThreadDylibHack.js +19 -0
  77. package/dist/serializerCore.browser.js +43 -0
  78. package/dist/summarizeRequest.js +39 -0
  79. package/dist/types.js +31 -0
  80. package/dist/utils.js +172 -0
  81. package/dist/worker.js +123 -0
  82. package/lib/AssetGraph.js +111 -14
  83. package/lib/Atlaspack.js +81 -37
  84. package/lib/AtlaspackConfig.js +15 -3
  85. package/lib/AtlaspackConfig.schema.js +7 -5
  86. package/lib/BundleGraph.js +90 -32
  87. package/lib/CommittedAsset.js +6 -0
  88. package/lib/Dependency.js +8 -2
  89. package/lib/Environment.js +15 -8
  90. package/lib/EnvironmentManager.js +143 -0
  91. package/lib/IdentifierRegistry.js +1 -3
  92. package/lib/InternalConfig.js +3 -2
  93. package/lib/PackagerRunner.js +90 -27
  94. package/lib/ReporterRunner.js +6 -9
  95. package/lib/RequestTracker.js +266 -156
  96. package/lib/SymbolPropagation.js +42 -18
  97. package/lib/TargetDescriptor.schema.js +7 -1
  98. package/lib/Transformation.js +26 -10
  99. package/lib/UncommittedAsset.js +30 -9
  100. package/lib/Validation.js +18 -2
  101. package/lib/applyRuntimes.js +9 -1
  102. package/lib/assetUtils.js +7 -4
  103. package/lib/atlaspack-v3/AtlaspackV3.js +32 -7
  104. package/lib/atlaspack-v3/NapiWorkerPool.js +3 -0
  105. package/lib/atlaspack-v3/fs.js +3 -1
  106. package/lib/atlaspack-v3/index.js +28 -1
  107. package/lib/atlaspack-v3/jsCallable.js +0 -2
  108. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +7 -4
  109. package/lib/atlaspack-v3/worker/compat/bitflags.js +7 -6
  110. package/lib/atlaspack-v3/worker/compat/dependency.js +3 -0
  111. package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
  112. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +14 -9
  113. package/lib/atlaspack-v3/worker/compat/plugin-config.js +8 -10
  114. package/lib/atlaspack-v3/worker/compat/plugin-options.js +1 -0
  115. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
  116. package/lib/atlaspack-v3/worker/compat/target.js +2 -0
  117. package/lib/atlaspack-v3/worker/index.js +3 -0
  118. package/lib/atlaspack-v3/worker/worker.js +43 -7
  119. package/lib/constants.js +0 -1
  120. package/lib/dumpGraphToGraphViz.js +71 -16
  121. package/lib/index.js +45 -1
  122. package/lib/loadDotEnv.js +4 -1
  123. package/lib/projectPath.js +5 -0
  124. package/lib/public/Asset.js +21 -11
  125. package/lib/public/Bundle.js +15 -16
  126. package/lib/public/BundleGraph.js +10 -4
  127. package/lib/public/BundleGroup.js +4 -5
  128. package/lib/public/Config.js +118 -17
  129. package/lib/public/Dependency.js +8 -6
  130. package/lib/public/Environment.js +12 -7
  131. package/lib/public/MutableBundleGraph.js +54 -12
  132. package/lib/public/PluginOptions.js +2 -2
  133. package/lib/public/Symbols.js +11 -11
  134. package/lib/public/Target.js +7 -6
  135. package/lib/registerCoreWithSerializer.js +5 -3
  136. package/lib/requests/AssetGraphRequest.js +42 -5
  137. package/lib/requests/AssetGraphRequestRust.js +126 -62
  138. package/lib/requests/AssetRequest.js +23 -6
  139. package/lib/requests/AtlaspackBuildRequest.js +10 -4
  140. package/lib/requests/AtlaspackConfigRequest.js +27 -16
  141. package/lib/requests/BundleGraphRequest.js +34 -19
  142. package/lib/requests/ConfigRequest.js +28 -4
  143. package/lib/requests/DevDepRequest.js +31 -5
  144. package/lib/requests/EntryRequest.js +2 -0
  145. package/lib/requests/PackageRequest.js +2 -1
  146. package/lib/requests/PathRequest.js +24 -3
  147. package/lib/requests/TargetRequest.js +122 -57
  148. package/lib/requests/ValidationRequest.js +5 -1
  149. package/lib/requests/WriteBundleRequest.js +39 -11
  150. package/lib/requests/WriteBundlesRequest.js +51 -4
  151. package/lib/requests/asset-graph-diff.js +12 -7
  152. package/lib/requests/asset-graph-dot.js +1 -7
  153. package/lib/resolveOptions.js +36 -10
  154. package/lib/rustWorkerThreadDylibHack.js +0 -1
  155. package/lib/types/AssetGraph.d.ts +80 -0
  156. package/lib/types/Atlaspack.d.ts +52 -0
  157. package/lib/types/AtlaspackConfig.d.ts +65 -0
  158. package/lib/types/AtlaspackConfig.schema.d.ts +46 -0
  159. package/lib/types/BundleGraph.d.ts +182 -0
  160. package/lib/types/CommittedAsset.d.ts +23 -0
  161. package/lib/types/Dependency.d.ts +44 -0
  162. package/lib/types/Environment.d.ts +11 -0
  163. package/lib/types/EnvironmentManager.d.ts +37 -0
  164. package/lib/types/IdentifierRegistry.d.ts +6 -0
  165. package/lib/types/InternalConfig.d.ts +24 -0
  166. package/lib/types/PackagerRunner.d.ts +85 -0
  167. package/lib/types/ReporterRunner.d.ts +25 -0
  168. package/lib/types/RequestTracker.d.ts +385 -0
  169. package/lib/types/SymbolPropagation.d.ts +11 -0
  170. package/lib/types/TargetDescriptor.schema.d.ts +5 -0
  171. package/lib/types/Transformation.d.ts +72 -0
  172. package/lib/types/UncommittedAsset.d.ts +61 -0
  173. package/lib/types/Validation.d.ts +37 -0
  174. package/lib/types/applyRuntimes.d.ts +25 -0
  175. package/lib/types/assetUtils.d.ts +42 -0
  176. package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +26 -0
  177. package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +12 -0
  178. package/lib/types/atlaspack-v3/fs.d.ts +12 -0
  179. package/lib/types/atlaspack-v3/index.d.ts +5 -0
  180. package/lib/types/atlaspack-v3/jsCallable.d.ts +1 -0
  181. package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
  182. package/lib/types/atlaspack-v3/worker/compat/bitflags.d.ts +15 -0
  183. package/lib/types/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
  184. package/lib/types/atlaspack-v3/worker/compat/environment.d.ts +27 -0
  185. package/{src/atlaspack-v3/worker/compat/index.js → lib/types/atlaspack-v3/worker/compat/index.d.ts} +0 -1
  186. package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
  187. package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +37 -0
  188. package/lib/types/atlaspack-v3/worker/compat/plugin-logger.d.ts +9 -0
  189. package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +22 -0
  190. package/lib/types/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
  191. package/lib/types/atlaspack-v3/worker/compat/target.d.ts +11 -0
  192. package/lib/types/atlaspack-v3/worker/worker.d.ts +60 -0
  193. package/lib/types/constants.d.ts +13 -0
  194. package/lib/types/dumpGraphToGraphViz.d.ts +10 -0
  195. package/lib/types/index.d.ts +8 -0
  196. package/lib/types/loadAtlaspackPlugin.d.ts +8 -0
  197. package/lib/types/loadDotEnv.d.ts +3 -0
  198. package/lib/types/projectPath.d.ts +19 -0
  199. package/lib/types/public/Asset.d.ts +74 -0
  200. package/lib/types/public/Bundle.d.ts +45 -0
  201. package/lib/types/public/BundleGraph.d.ts +70 -0
  202. package/lib/types/public/BundleGroup.d.ts +12 -0
  203. package/lib/types/public/Config.d.ts +75 -0
  204. package/lib/types/public/Dependency.d.ts +32 -0
  205. package/lib/types/public/Environment.d.ts +34 -0
  206. package/lib/types/public/MutableBundleGraph.d.ts +26 -0
  207. package/lib/types/public/PluginOptions.d.ts +25 -0
  208. package/lib/types/public/Symbols.d.ts +81 -0
  209. package/lib/types/public/Target.d.ts +16 -0
  210. package/lib/types/registerCoreWithSerializer.d.ts +2 -0
  211. package/lib/types/requests/AssetGraphRequest.d.ts +74 -0
  212. package/lib/types/requests/AssetGraphRequestRust.d.ts +21 -0
  213. package/lib/types/requests/AssetRequest.d.ts +16 -0
  214. package/lib/types/requests/AtlaspackBuildRequest.d.ts +33 -0
  215. package/lib/types/requests/AtlaspackConfigRequest.d.ts +45 -0
  216. package/lib/types/requests/BundleGraphRequest.d.ts +28 -0
  217. package/lib/types/requests/ConfigRequest.d.ts +59 -0
  218. package/lib/types/requests/DevDepRequest.d.ts +30 -0
  219. package/lib/types/requests/EntryRequest.d.ts +36 -0
  220. package/lib/types/requests/PackageRequest.d.ts +27 -0
  221. package/lib/types/requests/PathRequest.d.ts +48 -0
  222. package/lib/types/requests/TargetRequest.d.ts +48 -0
  223. package/lib/types/requests/ValidationRequest.d.ts +20 -0
  224. package/lib/types/requests/WriteBundleRequest.d.ts +28 -0
  225. package/lib/types/requests/WriteBundlesRequest.d.ts +32 -0
  226. package/lib/types/requests/asset-graph-diff.d.ts +1 -0
  227. package/lib/types/requests/asset-graph-dot.d.ts +9 -0
  228. package/lib/types/resolveOptions.d.ts +3 -0
  229. package/lib/types/rustWorkerThreadDylibHack.d.ts +9 -0
  230. package/lib/types/serializerCore.browser.d.ts +3 -0
  231. package/lib/types/summarizeRequest.d.ts +10 -0
  232. package/lib/types/types.d.ts +493 -0
  233. package/lib/types/utils.d.ts +23 -0
  234. package/lib/types/worker.d.ts +44 -0
  235. package/lib/types.js +8 -1
  236. package/lib/utils.js +17 -2
  237. package/lib/worker.js +29 -13
  238. package/package.json +24 -34
  239. package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
  240. package/src/{Atlaspack.js → Atlaspack.ts} +114 -61
  241. package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +16 -19
  242. package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
  243. package/src/{BundleGraph.js → BundleGraph.ts} +231 -140
  244. package/src/{CommittedAsset.js → CommittedAsset.ts} +14 -12
  245. package/src/{Dependency.js → Dependency.ts} +59 -42
  246. package/src/{Environment.js → Environment.ts} +24 -15
  247. package/src/EnvironmentManager.ts +154 -0
  248. package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
  249. package/src/{InternalConfig.js → InternalConfig.ts} +22 -23
  250. package/src/{PackagerRunner.js → PackagerRunner.ts} +178 -86
  251. package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
  252. package/src/{RequestTracker.js → RequestTracker.ts} +572 -357
  253. package/src/{SymbolPropagation.js → SymbolPropagation.ts} +165 -57
  254. package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
  255. package/src/{Transformation.js → Transformation.ts} +71 -62
  256. package/src/{UncommittedAsset.js → UncommittedAsset.ts} +57 -36
  257. package/src/{Validation.js → Validation.ts} +32 -17
  258. package/src/{applyRuntimes.js → applyRuntimes.ts} +35 -26
  259. package/src/{assetUtils.js → assetUtils.ts} +47 -35
  260. package/src/atlaspack-v3/AtlaspackV3.ts +122 -0
  261. package/src/atlaspack-v3/{NapiWorkerPool.js → NapiWorkerPool.ts} +10 -5
  262. package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
  263. package/src/atlaspack-v3/{index.js → index.ts} +2 -4
  264. package/src/atlaspack-v3/jsCallable.ts +14 -0
  265. package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +40 -30
  266. package/src/atlaspack-v3/worker/compat/{bitflags.js → bitflags.ts} +9 -10
  267. package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +12 -12
  268. package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
  269. package/src/atlaspack-v3/worker/compat/index.ts +9 -0
  270. package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +20 -19
  271. package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +27 -26
  272. package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
  273. package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +4 -5
  274. package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
  275. package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
  276. package/src/atlaspack-v3/worker/index.js +2 -1
  277. package/src/atlaspack-v3/worker/{worker.js → worker.ts} +102 -66
  278. package/src/{constants.js → constants.ts} +0 -3
  279. package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
  280. package/src/index.ts +18 -0
  281. package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +8 -9
  282. package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
  283. package/src/{projectPath.js → projectPath.ts} +20 -9
  284. package/src/public/{Asset.js → Asset.ts} +40 -27
  285. package/src/public/{Bundle.js → Bundle.ts} +28 -29
  286. package/src/public/{BundleGraph.js → BundleGraph.ts} +81 -50
  287. package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
  288. package/src/public/{Config.js → Config.ts} +171 -33
  289. package/src/public/{Dependency.js → Dependency.ts} +20 -17
  290. package/src/public/{Environment.js → Environment.ts} +28 -17
  291. package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
  292. package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
  293. package/src/public/{Symbols.js → Symbols.ts} +75 -36
  294. package/src/public/{Target.js → Target.ts} +10 -8
  295. package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
  296. package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +84 -49
  297. package/src/requests/AssetGraphRequestRust.ts +352 -0
  298. package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
  299. package/src/requests/{AtlaspackBuildRequest.js → AtlaspackBuildRequest.ts} +46 -32
  300. package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +72 -58
  301. package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +71 -58
  302. package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +71 -50
  303. package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +60 -35
  304. package/src/requests/{EntryRequest.js → EntryRequest.ts} +36 -31
  305. package/src/requests/{PackageRequest.js → PackageRequest.ts} +20 -22
  306. package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
  307. package/src/requests/{TargetRequest.js → TargetRequest.ts} +260 -179
  308. package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
  309. package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +77 -49
  310. package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +109 -37
  311. package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +25 -21
  312. package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
  313. package/src/{resolveOptions.js → resolveOptions.ts} +56 -24
  314. package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
  315. package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
  316. package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
  317. package/src/types.ts +647 -0
  318. package/src/{utils.js → utils.ts} +52 -21
  319. package/src/{worker.js → worker.ts} +49 -41
  320. package/test/{AssetGraph.test.js → AssetGraph.test.ts} +37 -8
  321. package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
  322. package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
  323. package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +75 -15
  324. package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
  325. package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
  326. package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
  327. package/test/Environment.test.ts +153 -0
  328. package/test/EnvironmentManager.test.ts +188 -0
  329. package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
  330. package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
  331. package/test/PackagerRunner.test.ts +0 -0
  332. package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
  333. package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
  334. package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
  335. package/test/PublicEnvironment.test.ts +49 -0
  336. package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
  337. package/test/{RequestTracker.test.js → RequestTracker.test.ts} +314 -59
  338. package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
  339. package/test/{TargetRequest.test.js → TargetRequest.test.ts} +66 -92
  340. package/test/fixtures/config-with-reporters/.parcelrc +7 -0
  341. package/test/fixtures/custom-targets/package.json +6 -0
  342. package/test/public/Config.test.ts +104 -0
  343. package/test/requests/{AssetGraphRequestRust.test.js → AssetGraphRequestRust.test.ts} +164 -134
  344. package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
  345. package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
  346. package/test/{test-utils.js → test-utils.ts} +4 -11
  347. package/test/{utils.test.js → utils.test.ts} +1 -3
  348. package/tsconfig.json +57 -0
  349. package/tsconfig.tsbuildinfo +1 -0
  350. package/index.d.ts +0 -30
  351. package/src/atlaspack-v3/AtlaspackV3.js +0 -87
  352. package/src/atlaspack-v3/jsCallable.js +0 -18
  353. package/src/index.js +0 -13
  354. package/src/requests/AssetGraphRequestRust.js +0 -263
  355. package/src/types.js +0 -600
  356. package/test/Environment.test.js +0 -119
  357. package/test/PackagerRunner.test.js +0 -27
  358. package/test/PublicEnvironment.test.js +0 -27
@@ -51,6 +51,7 @@ function _featureFlags() {
51
51
  };
52
52
  return data;
53
53
  }
54
+ var _EnvironmentManager = require("./EnvironmentManager");
54
55
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
55
56
  const bundleGraphEdgeTypes = exports.bundleGraphEdgeTypes = {
56
57
  // A lack of an edge type indicates to follow the edge while traversing
@@ -85,7 +86,7 @@ function makeReadOnlySet(set) {
85
86
  if (property === 'delete' || property === 'add' || property === 'clear') {
86
87
  return undefined;
87
88
  } else {
88
- // $FlowFixMe[incompatible-type]
89
+ // @ts-expect-error TS7053
89
90
  let value = target[property];
90
91
  return typeof value === 'function' ? value.bind(target) : value;
91
92
  }
@@ -167,7 +168,7 @@ class BundleGraph {
167
168
  // code need to be mapped to the "real" dependencies, so we need access to a map of placeholders
168
169
  // to dependencies
169
170
  const dep = node.value;
170
- // $FlowFixMe[incompatible-type] Meta is untyped
171
+ // @ts-expect-error TS2322
171
172
  const placeholder = (_dep$meta = dep.meta) === null || _dep$meta === void 0 ? void 0 : _dep$meta.placeholder;
172
173
  if (placeholder != null) {
173
174
  placeholderToDependency.set(placeholder, dep);
@@ -182,7 +183,6 @@ class BundleGraph {
182
183
  if ((0, _featureFlags().getFeatureFlag)('conditionalBundlingApi') && node.type === 'asset') {
183
184
  const asset = node.value;
184
185
  if (Array.isArray(asset.meta.conditions)) {
185
- // $FlowFixMe
186
186
  for (const condition of asset.meta.conditions) {
187
187
  // Resolve the placeholders that were attached to the asset in JSTransformer to dependencies,
188
188
  // as well as create a public id for the condition.
@@ -207,7 +207,7 @@ class BundleGraph {
207
207
  }
208
208
  }
209
209
  }
210
- if (node.type === 'dependency' && node.value.symbols != null && node.value.env.shouldScopeHoist &&
210
+ if (node.type === 'dependency' && node.value.symbols != null && (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).shouldScopeHoist &&
211
211
  // Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
212
212
  isProduction) {
213
213
  let nodeValueSymbols = node.value.symbols;
@@ -263,9 +263,13 @@ class BundleGraph {
263
263
  ...node,
264
264
  value: {
265
265
  ...node.value,
266
- symbols: new Map([...nodeValueSymbols].filter(([k]) => externalSymbols.has(k)))
266
+ symbols: new Map(
267
+ // @ts-expect-error TS2769
268
+ [...nodeValueSymbols].filter(([k]) => externalSymbols.has(k)))
267
269
  },
268
- usedSymbolsUp: new Map([...node.usedSymbolsUp].filter(([k]) => externalSymbols.has(k))),
270
+ usedSymbolsUp: new Map(
271
+ // @ts-expect-error TS2769
272
+ [...node.usedSymbolsUp].filter(([k]) => externalSymbols.has(k))),
269
273
  usedSymbolsDown: new Set(),
270
274
  excluded: externalSymbols.size === 0
271
275
  })
@@ -294,8 +298,13 @@ class BundleGraph {
294
298
  loc: reexportAllLoc
295
299
  });
296
300
  if (node.value.sourceAssetId != null) {
297
- let sourceAssetId = (0, _nullthrows().default)(assetGraphNodeIdToBundleGraphNodeId.get(assetGraph.getNodeIdByContentKey(node.value.sourceAssetId)));
298
- let sourceAsset = (0, _nullthrows().default)(graph.getNode(sourceAssetId));
301
+ let sourceAssetId;
302
+ if ((0, _featureFlags().getFeatureFlag)('sourceAssetIdBundleGraphFix')) {
303
+ [sourceAssetId] = assetGraph.getNodeIdsConnectedTo(nodeId);
304
+ } else {
305
+ sourceAssetId = assetGraph.getNodeIdByContentKey(node.value.sourceAssetId);
306
+ }
307
+ let sourceAsset = (0, _nullthrows().default)(graph.getNode((0, _nullthrows().default)(assetGraphNodeIdToBundleGraphNodeId.get(sourceAssetId))));
299
308
  (0, _assert().default)(sourceAsset.type === 'asset');
300
309
  let sourceAssetSymbols = sourceAsset.value.symbols;
301
310
  if (sourceAssetSymbols) {
@@ -312,7 +321,9 @@ class BundleGraph {
312
321
  }
313
322
  }
314
323
  }
315
- let usedSymbolsUp = new Map([...node.usedSymbolsUp].filter(([k]) => target.has(k) || k === '*').map(([k, v]) => [target.get(k) ?? k, v]));
324
+ let usedSymbolsUp = new Map([...node.usedSymbolsUp]
325
+ // @ts-expect-error TS2769
326
+ .filter(([k]) => target.has(k) || k === '*').map(([k, v]) => [target.get(k) ?? k, v]));
316
327
  return {
317
328
  asset,
318
329
  dep: graph.addNodeByContentKey(newNodeId, {
@@ -363,6 +374,8 @@ class BundleGraph {
363
374
  }
364
375
  }
365
376
  walk((0, _nullthrows().default)(assetGraph.rootNodeId));
377
+
378
+ // @ts-expect-error TS2488
366
379
  for (let edge of assetGraph.getAllEdges()) {
367
380
  var _dependencies$get, _assetGroupIds$get;
368
381
  if (assetGroupIds.has(edge.from)) {
@@ -416,11 +429,14 @@ class BundleGraph {
416
429
  });
417
430
  }
418
431
  createBundle(opts) {
432
+ // @ts-expect-error TS2339
419
433
  let {
420
434
  entryAsset,
421
435
  target
422
436
  } = opts;
423
- let bundleId = (0, _rust().hashString)('bundle:' + (opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) + (0, _projectPath.fromProjectPathRelative)(target.distDir) + (opts.bundleBehavior ?? ''));
437
+ let bundleId = (0, _rust().hashString)('bundle:' + (
438
+ // @ts-expect-error TS2339
439
+ opts.entryAsset ? opts.entryAsset.id : opts.uniqueKey) + (0, _projectPath.fromProjectPathRelative)(target.distDir) + (opts.bundleBehavior ?? ''));
424
440
  let existing = this._graph.getNodeByContentKey(bundleId);
425
441
  if (existing != null) {
426
442
  (0, _assert().default)(existing.type === 'bundle');
@@ -440,14 +456,21 @@ class BundleGraph {
440
456
  value: {
441
457
  id: bundleId,
442
458
  hashReference: opts.shouldContentHash ? _constants.HASH_REF_PREFIX + bundleId : bundleId.slice(-8),
459
+ // @ts-expect-error TS2339
443
460
  type: opts.entryAsset ? opts.entryAsset.type : opts.type,
444
461
  env: opts.env,
445
462
  entryAssetIds: entryAsset ? [entryAsset.id] : [],
446
463
  mainEntryId: entryAsset === null || entryAsset === void 0 ? void 0 : entryAsset.id,
464
+ // @ts-expect-error TS2339
447
465
  pipeline: opts.entryAsset ? opts.entryAsset.pipeline : opts.pipeline,
448
466
  needsStableName: opts.needsStableName,
449
467
  bundleBehavior: opts.bundleBehavior != null ? _types.BundleBehavior[opts.bundleBehavior] : null,
450
- isSplittable: opts.entryAsset ? opts.entryAsset.isBundleSplittable : opts.isSplittable,
468
+ // @ts-expect-error TS2339
469
+ isSplittable: opts.entryAsset ?
470
+ // @ts-expect-error TS2339
471
+ opts.entryAsset.isBundleSplittable :
472
+ // @ts-expect-error TS2339
473
+ opts.isSplittable,
451
474
  isPlaceholder,
452
475
  target,
453
476
  name: null,
@@ -456,8 +479,12 @@ class BundleGraph {
456
479
  }
457
480
  };
458
481
  let bundleNodeId = this._graph.addNodeByContentKey(bundleId, bundleNode);
482
+
483
+ // @ts-expect-error TS2339
459
484
  if (opts.entryAsset) {
460
- this._graph.addEdge(bundleNodeId, this._graph.getNodeIdByContentKey(opts.entryAsset.id));
485
+ this._graph.addEdge(bundleNodeId,
486
+ // @ts-expect-error TS2339
487
+ this._graph.getNodeIdByContentKey(opts.entryAsset.id));
461
488
  }
462
489
  _assert().default;
463
490
  return bundleNode.value;
@@ -470,9 +497,14 @@ class BundleGraph {
470
497
  for (let dependency of dependencies) {
471
498
  let dependencyNodeId = this._graph.getNodeIdByContentKey(dependency.id);
472
499
  this._graph.addEdge(bundleNodeId, dependencyNodeId, bundleGraphEdgeTypes.contains);
473
- for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(dependencyNodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))]).filter(([, node]) => node.type === 'bundle_group')) {
500
+ for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(dependencyNodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))])
501
+ // @ts-expect-error TS2769
502
+ .filter(([, node]) => node.type === 'bundle_group')) {
503
+ // @ts-expect-error TS2339
474
504
  (0, _assert().default)(bundleGroupNode.type === 'bundle_group');
475
- this._graph.addEdge(bundleNodeId, bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
505
+ this._graph.addEdge(bundleNodeId,
506
+ // @ts-expect-error TS2345
507
+ bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
476
508
  }
477
509
  // If the dependency references a target bundle, add a reference edge from
478
510
  // the source bundle to the dependency for easy traversal.
@@ -503,9 +535,14 @@ class BundleGraph {
503
535
  this._graph.addEdge(bundleNodeId, nodeId, bundleGraphEdgeTypes.contains);
504
536
  }
505
537
  if (node.type === 'dependency') {
506
- for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(nodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))]).filter(([, node]) => node.type === 'bundle_group')) {
538
+ for (let [bundleGroupNodeId, bundleGroupNode] of this._graph.getNodeIdsConnectedFrom(nodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))])
539
+ // @ts-expect-error TS2769
540
+ .filter(([, node]) => node.type === 'bundle_group')) {
541
+ // @ts-expect-error TS2339
507
542
  (0, _assert().default)(bundleGroupNode.type === 'bundle_group');
508
- this._graph.addEdge(bundleNodeId, bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
543
+ this._graph.addEdge(bundleNodeId,
544
+ // @ts-expect-error TS2345
545
+ bundleGroupNodeId, bundleGraphEdgeTypes.bundle);
509
546
  }
510
547
 
511
548
  // If the dependency references a target bundle, add a reference edge from
@@ -616,8 +653,12 @@ class BundleGraph {
616
653
  return this.getBundlesInBundleGroup(node.value, {
617
654
  includeInline: true
618
655
  }).find(b => {
619
- let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
620
- return mainEntryId != null && node.value.entryAssetId === mainEntryId;
656
+ if ((0, _featureFlags().getFeatureFlag)('supportWebpackChunkName')) {
657
+ return b.entryAssetIds.some(id => id === node.value.entryAssetId);
658
+ } else {
659
+ let mainEntryId = b.entryAssetIds[b.entryAssetIds.length - 1];
660
+ return mainEntryId != null && node.value.entryAssetId === mainEntryId;
661
+ }
621
662
  });
622
663
  }
623
664
  }
@@ -805,6 +846,7 @@ class BundleGraph {
805
846
  }
806
847
  }, this._graph.getNodeIdByContentKey(dep.id), bundleGraphEdgeTypes.references);
807
848
  if (bundle) {
849
+ // @ts-expect-error TS2322
808
850
  resolved = potential.find(a => a.type === bundle.type);
809
851
  }
810
852
  resolved ||= potential[0];
@@ -859,13 +901,14 @@ class BundleGraph {
859
901
  return;
860
902
  }
861
903
  visitedBundles.add(descendant);
862
- if (descendant.type !== bundle.type || descendant.env.context !== bundle.env.context) {
904
+ if (descendant.type !== bundle.type || (0, _EnvironmentManager.fromEnvironmentId)(descendant.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) {
863
905
  actions.skipChildren();
864
906
  return;
865
907
  }
866
908
  if (bundleHasReference(descendant)) {
867
909
  isReferenced = true;
868
910
  actions.stop();
911
+ return;
869
912
  }
870
913
  }, referencer);
871
914
  return isReferenced;
@@ -887,7 +930,7 @@ class BundleGraph {
887
930
  isAssetReachableFromBundle(asset, bundle) {
888
931
  // If a bundle's environment is isolated, it can't access assets present
889
932
  // in any ancestor bundles. Don't consider any assets reachable.
890
- if (_Environment.ISOLATED_ENVS.has(bundle.env.context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline) {
933
+ if (_Environment.ISOLATED_ENVS.has((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline || bundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
891
934
  return false;
892
935
  }
893
936
 
@@ -897,7 +940,7 @@ class BundleGraph {
897
940
  return bundleGroups.every(bundleGroup => {
898
941
  // If the asset is in any sibling bundles of the original bundle, it is reachable.
899
942
  let bundles = this.getBundlesInBundleGroup(bundleGroup);
900
- if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
943
+ if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
901
944
  return true;
902
945
  }
903
946
 
@@ -907,7 +950,7 @@ class BundleGraph {
907
950
  // Check that every parent bundle has a bundle group in its ancestry that contains the asset.
908
951
  return parentBundleNodes.every(bundleNodeId => {
909
952
  let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
910
- if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline) {
953
+ if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline || bundleNode.value.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
911
954
  return false;
912
955
  }
913
956
  let isReachable = true;
@@ -915,15 +958,16 @@ class BundleGraph {
915
958
  let node = (0, _nullthrows().default)(this._graph.getNode(nodeId));
916
959
  // If we've reached the root or a context change without
917
960
  // finding this asset in the ancestry, it is not reachable.
918
- if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || node.value.env.context !== bundle.env.context)) {
961
+ if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context)) {
919
962
  isReachable = false;
920
963
  actions.stop();
921
964
  return;
922
965
  }
923
966
  if (node.type === 'bundle_group') {
924
967
  let childBundles = this.getBundlesInBundleGroup(node.value);
925
- if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
968
+ if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
926
969
  actions.skipChildren();
970
+ return;
927
971
  }
928
972
  }
929
973
  }, [bundleGraphEdgeTypes.references, bundleGraphEdgeTypes.bundle]);
@@ -958,7 +1002,9 @@ class BundleGraph {
958
1002
  startNodeId: startAsset ? this._graph.getNodeIdByContentKey(startAsset.id) : bundleNodeId,
959
1003
  getChildren: nodeId => {
960
1004
  let children = this._graph.getNodeIdsConnectedFrom(nodeId).map(id => [id, (0, _nullthrows().default)(this._graph.getNode(id))]);
961
- let sorted = entries && bundle.entryAssetIds.length > 0 ? children.sort(([, a], [, b]) => {
1005
+ let sorted = entries && bundle.entryAssetIds.length > 0 ?
1006
+ // @ts-expect-error TS2345
1007
+ children.sort(([, a], [, b]) => {
962
1008
  let aIndex = bundle.entryAssetIds.indexOf(a.id);
963
1009
  let bIndex = bundle.entryAssetIds.indexOf(b.id);
964
1010
  if (aIndex === bIndex) {
@@ -973,6 +1019,7 @@ class BundleGraph {
973
1019
  return aIndex - bIndex;
974
1020
  }) : children;
975
1021
  entries = false;
1022
+ // @ts-expect-error TS2345
976
1023
  return sorted.map(([id]) => id);
977
1024
  }
978
1025
  });
@@ -1010,7 +1057,7 @@ class BundleGraph {
1010
1057
  getBundles(opts) {
1011
1058
  let bundles = [];
1012
1059
  this.traverseBundles(bundle => {
1013
- if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
1060
+ if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1014
1061
  bundles.push(bundle);
1015
1062
  }
1016
1063
  });
@@ -1061,7 +1108,7 @@ class BundleGraph {
1061
1108
  let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
1062
1109
  (0, _assert().default)(bundleNode.type === 'bundle');
1063
1110
  let bundle = bundleNode.value;
1064
- if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
1111
+ if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1065
1112
  bundles.add(bundle);
1066
1113
  }
1067
1114
  for (let referencedBundle of this.getReferencedBundles(bundle, {
@@ -1085,7 +1132,7 @@ class BundleGraph {
1085
1132
  if (node.value.id === bundle.id) {
1086
1133
  return;
1087
1134
  }
1088
- if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline) {
1135
+ if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline && node.value.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1089
1136
  referencedBundles.add(node.value);
1090
1137
  }
1091
1138
  if (!recursive) {
@@ -1099,6 +1146,8 @@ class BundleGraph {
1099
1146
  // TODO: Should this be the case?
1100
1147
  this._graph.getNodeIdsConnectedFrom(nodeId, bundleGraphEdgeTypes.references)
1101
1148
  });
1149
+
1150
+ // @ts-expect-error TS2322
1102
1151
  return [...referencedBundles];
1103
1152
  }
1104
1153
  getIncomingDependencies(asset) {
@@ -1118,7 +1167,9 @@ class BundleGraph {
1118
1167
  }
1119
1168
  let res = null;
1120
1169
  let count = 0;
1121
- this._graph.forEachNodeIdConnectedTo(this._graph.getNodeIdByContentKey(dep.id), node => {
1170
+ this._graph.forEachNodeIdConnectedTo(this._graph.getNodeIdByContentKey(dep.id),
1171
+ // @ts-expect-error TS2345
1172
+ node => {
1122
1173
  res = node;
1123
1174
  count += 1;
1124
1175
  if (count > 1) {
@@ -1282,11 +1333,13 @@ class BundleGraph {
1282
1333
  let result = identifier;
1283
1334
  if (skipped) {
1284
1335
  // ... and it was excluded (by symbol propagation) or deferred.
1336
+ // @ts-expect-error TS2322
1285
1337
  result = false;
1286
1338
  } else {
1287
1339
  // ... and there is no single reexport, but it might still be exported:
1288
1340
  if (found) {
1289
1341
  // Fallback to namespace access, because of a bundle boundary.
1342
+ // @ts-expect-error TS2322
1290
1343
  result = null;
1291
1344
  } else if (result === undefined) {
1292
1345
  var _asset$symbols5;
@@ -1294,6 +1347,7 @@ class BundleGraph {
1294
1347
  if (nonStaticDependency || (_asset$symbols5 = asset.symbols) !== null && _asset$symbols5 !== void 0 && _asset$symbols5.has('*')) {
1295
1348
  // ... and if there are non-statically analyzable dependencies or it's a CJS asset,
1296
1349
  // fallback to namespace access.
1350
+ // @ts-expect-error TS2322
1297
1351
  result = null;
1298
1352
  }
1299
1353
  // (It shouldn't be possible for the symbol to be in a reexport-all and to end up here).
@@ -1381,7 +1435,7 @@ class BundleGraph {
1381
1435
  includeInline: true
1382
1436
  });
1383
1437
  for (let referenced of referencedBundles) {
1384
- if (referenced.bundleBehavior === _types.BundleBehavior.inline) {
1438
+ if (referenced.bundleBehavior === _types.BundleBehavior.inline || referenced.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
1385
1439
  bundles.push(referenced);
1386
1440
  addReferencedBundles(referenced);
1387
1441
  }
@@ -1389,7 +1443,7 @@ class BundleGraph {
1389
1443
  };
1390
1444
  addReferencedBundles(bundle);
1391
1445
  this.traverseBundles((childBundle, _, traversal) => {
1392
- if (childBundle.bundleBehavior === _types.BundleBehavior.inline) {
1446
+ if (childBundle.bundleBehavior === _types.BundleBehavior.inline || childBundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
1393
1447
  bundles.push(childBundle);
1394
1448
  } else if (childBundle.id !== bundle.id) {
1395
1449
  traversal.skipChildren();
@@ -1410,7 +1464,7 @@ class BundleGraph {
1410
1464
  for (let referencedBundle of this.getReferencedBundles(bundle)) {
1411
1465
  hash.writeString(referencedBundle.id);
1412
1466
  }
1413
- hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)(bundle.env)));
1467
+ hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)((0, _EnvironmentManager.fromEnvironmentId)(bundle.env))));
1414
1468
  return hash.finish();
1415
1469
  }
1416
1470
  getBundleGraphHash() {
@@ -1469,6 +1523,8 @@ class BundleGraph {
1469
1523
  otherGraphIdToThisNodeId.set(otherNodeId, updateNodeId);
1470
1524
  }
1471
1525
  }
1526
+
1527
+ // @ts-expect-error TS2488
1472
1528
  for (let edge of other._graph.getAllEdges()) {
1473
1529
  this._graph.addEdge((0, _nullthrows().default)(otherGraphIdToThisNodeId.get(edge.from)), (0, _nullthrows().default)(otherGraphIdToThisNodeId.get(edge.to)), edge.type);
1474
1530
  }
@@ -1521,6 +1577,8 @@ class BundleGraph {
1521
1577
  startNodeId: this._graph.getNodeIdByContentKey(bundle.id),
1522
1578
  getChildren: nodeId => this._graph.getNodeIdsConnectedFrom(nodeId, bundleGraphEdgeTypes.conditional)
1523
1579
  });
1580
+
1581
+ // @ts-expect-error TS2322
1524
1582
  return [...referencedBundles];
1525
1583
  }
1526
1584
  }
@@ -74,6 +74,7 @@ class CommittedAsset {
74
74
  if (typeof content === 'string' || content instanceof Buffer) {
75
75
  return content.toString();
76
76
  } else if (content != null) {
77
+ // @ts-expect-error TS2345
77
78
  this.content = (0, _utils().bufferStream)(content);
78
79
  return (await this.content).toString();
79
80
  }
@@ -86,7 +87,10 @@ class CommittedAsset {
86
87
  } else if (typeof content === 'string' || content instanceof Buffer) {
87
88
  return Buffer.from(content);
88
89
  }
90
+
91
+ // @ts-expect-error TS2345
89
92
  this.content = (0, _utils().bufferStream)(content);
93
+ // @ts-expect-error TS2322
90
94
  return this.content;
91
95
  }
92
96
  getStream() {
@@ -125,6 +129,8 @@ class CommittedAsset {
125
129
  }
126
130
  })();
127
131
  }
132
+
133
+ // @ts-expect-error TS2322
128
134
  return this.mapBuffer ?? Promise.resolve();
129
135
  }
130
136
  getMap() {
package/lib/Dependency.js CHANGED
@@ -24,6 +24,7 @@ function _assert() {
24
24
  return data;
25
25
  }
26
26
  var _IdentifierRegistry = require("./IdentifierRegistry");
27
+ var _EnvironmentManager = require("./EnvironmentManager");
27
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
29
  function createDependencyId({
29
30
  sourceAssetId,
@@ -41,8 +42,11 @@ function createDependencyId({
41
42
  const params = {
42
43
  sourceAssetId,
43
44
  specifier,
44
- environmentId: env.id,
45
- target,
45
+ environmentId: (0, _EnvironmentManager.toEnvironmentId)(env),
46
+ target: target != null ? {
47
+ ...target,
48
+ env: (0, _EnvironmentManager.fromEnvironmentId)(target.env)
49
+ } : null,
46
50
  pipeline,
47
51
  specifierType: _types.SpecifierType[specifierType],
48
52
  bundleBehavior,
@@ -121,7 +125,9 @@ function convertConditions(conditions, dep) {
121
125
  let packageConditions = 0;
122
126
  let customConditions = [];
123
127
  for (let condition of conditions) {
128
+ // @ts-expect-error TS7053
124
129
  if (_types.ExportsCondition[condition]) {
130
+ // @ts-expect-error TS7053
125
131
  packageConditions |= _types.ExportsCondition[condition];
126
132
  } else {
127
133
  customConditions.push(condition);
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createEnvironment = createEnvironment;
7
+ exports.getEnvironmentHash = getEnvironmentHash;
7
8
  exports.mergeEnvironments = mergeEnvironments;
8
9
  function _rust() {
9
10
  const data = require("@atlaspack/rust");
@@ -15,6 +16,7 @@ function _rust() {
15
16
  var _utils = require("./utils");
16
17
  var _Environment = _interopRequireWildcard(require("./public/Environment"));
17
18
  var _IdentifierRegistry = require("./IdentifierRegistry");
19
+ var _EnvironmentManager = require("./EnvironmentManager");
18
20
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
21
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
22
  const DEFAULT_ENGINES = {
@@ -32,7 +34,8 @@ function createEnvironment({
32
34
  shouldScopeHoist = false,
33
35
  sourceMap,
34
36
  unstableSingleFileOutput = false,
35
- loc
37
+ loc,
38
+ customEnv
36
39
  } = {
37
40
  /*::...null*/
38
41
  }) {
@@ -57,8 +60,10 @@ function createEnvironment({
57
60
  case 'browser':
58
61
  case 'web-worker':
59
62
  case 'service-worker':
63
+ case 'tesseract':
60
64
  case 'electron-renderer':
61
65
  engines = {
66
+ // @ts-expect-error TS2322
62
67
  browsers: DEFAULT_ENGINES.browsers
63
68
  };
64
69
  break;
@@ -76,6 +81,7 @@ function createEnvironment({
76
81
  case 'browser':
77
82
  case 'web-worker':
78
83
  case 'service-worker':
84
+ case 'tesseract':
79
85
  default:
80
86
  includeNodeModules = true;
81
87
  break;
@@ -96,6 +102,7 @@ function createEnvironment({
96
102
  let res = {
97
103
  id: '',
98
104
  context,
105
+ // @ts-expect-error TS2322
99
106
  engines,
100
107
  includeNodeModules,
101
108
  outputFormat,
@@ -105,21 +112,20 @@ function createEnvironment({
105
112
  shouldScopeHoist,
106
113
  sourceMap,
107
114
  unstableSingleFileOutput,
108
- loc
115
+ loc,
116
+ customEnv
109
117
  };
110
118
  res.id = getEnvironmentHash(res);
111
- return Object.freeze(res);
119
+ return (0, _EnvironmentManager.toEnvironmentRef)(Object.freeze(res));
112
120
  }
113
121
  function mergeEnvironments(projectRoot, a, b) {
114
122
  // If merging the same object, avoid copying.
115
123
  if (a === b || !b) {
116
- return a;
124
+ return (0, _EnvironmentManager.toEnvironmentRef)(a);
117
125
  }
118
126
  if (b instanceof _Environment.default) {
119
- return (0, _Environment.environmentToInternalEnvironment)(b);
127
+ return (0, _EnvironmentManager.toEnvironmentRef)((0, _Environment.environmentToInternalEnvironment)(b));
120
128
  }
121
-
122
- // $FlowFixMe - ignore the `id` that is already on a
123
129
  return createEnvironment({
124
130
  ...a,
125
131
  ...b,
@@ -136,7 +142,8 @@ function getEnvironmentHash(env) {
136
142
  isLibrary: env.isLibrary,
137
143
  shouldOptimize: env.shouldOptimize,
138
144
  shouldScopeHoist: env.shouldScopeHoist,
139
- sourceMap: env.sourceMap
145
+ sourceMap: env.sourceMap,
146
+ customEnv: env.customEnv
140
147
  };
141
148
  const id = (0, _rust().createEnvironmentId)(data);
142
149
  _IdentifierRegistry.identifierRegistry.addIdentifier('environment', id, data);
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fromEnvironmentId = fromEnvironmentId;
7
+ exports.loadEnvironmentsFromCache = loadEnvironmentsFromCache;
8
+ exports.toEnvironmentId = toEnvironmentId;
9
+ exports.toEnvironmentRef = toEnvironmentRef;
10
+ exports.writeEnvironmentsToCache = writeEnvironmentsToCache;
11
+ function _rust() {
12
+ const data = require("@atlaspack/rust");
13
+ _rust = function () {
14
+ return data;
15
+ };
16
+ return data;
17
+ }
18
+ function _featureFlags() {
19
+ const data = require("@atlaspack/feature-flags");
20
+ _featureFlags = function () {
21
+ return data;
22
+ };
23
+ return data;
24
+ }
25
+ function _logger() {
26
+ const data = require("@atlaspack/logger");
27
+ _logger = function () {
28
+ return data;
29
+ };
30
+ return data;
31
+ }
32
+ var _constants = require("./constants");
33
+ /*!
34
+ * At the moment we're doing this change for `CoreEnvironment`,
35
+ * but the same change must be made for `TypesEnvironment` in @atlaspack/types.
36
+ */
37
+
38
+ const localEnvironmentCache = new Map();
39
+
40
+ /**
41
+ * When deduplication is cleaned-up this will always be a string.
42
+ */
43
+
44
+ /**
45
+ * Convert environment to a ref.
46
+ * This is what we should be using to store environments.
47
+ */
48
+ function toEnvironmentRef(env) {
49
+ if (!(0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
50
+ return env;
51
+ }
52
+ const id = toEnvironmentId(env);
53
+ return id;
54
+ }
55
+
56
+ /**
57
+ * Convert environment to a string ID
58
+ */
59
+ function toEnvironmentId(
60
+ /**
61
+ * Redundant type during roll-out
62
+ */
63
+ env) {
64
+ if (!(0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
65
+ return typeof env === 'string' ? env : env.id;
66
+ }
67
+ if (typeof env === 'string') {
68
+ return env;
69
+ }
70
+ (0, _rust().addEnvironment)(env);
71
+ return env.id;
72
+ }
73
+ function fromEnvironmentId(id) {
74
+ if (!(0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
75
+ if (typeof id === 'string') {
76
+ throw new Error('This should never happen when environmentDeduplication feature-flag is off');
77
+ } else {
78
+ return id;
79
+ }
80
+ }
81
+ if (typeof id !== 'string') {
82
+ return id;
83
+ }
84
+ const localEnv = localEnvironmentCache.get(id);
85
+ if (localEnv) {
86
+ return localEnv;
87
+ }
88
+ const env = Object.freeze((0, _rust().getEnvironment)(id));
89
+ // @ts-expect-error TS2345
90
+ localEnvironmentCache.set(id, env);
91
+ // @ts-expect-error TS2322
92
+ return env;
93
+ }
94
+
95
+ /**
96
+ * Writes all environments and their IDs to the cache
97
+ * @param {Cache} cache
98
+ * @returns {Promise<void>}
99
+ */
100
+ async function writeEnvironmentsToCache(cache) {
101
+ const environments = (0, _rust().getAllEnvironments)();
102
+ const environmentIds = new Set();
103
+
104
+ // Store each environment individually
105
+ for (const env of environments) {
106
+ // @ts-expect-error TS18046
107
+ environmentIds.add(env.id);
108
+ // @ts-expect-error TS18046
109
+ const envKey = `Environment/${_constants.ATLASPACK_VERSION}/${env.id}`;
110
+ await (0, _logger().instrument)(`RequestTracker::writeToCache::cache.put(${envKey})`, async () => {
111
+ await cache.set(envKey, env);
112
+ });
113
+ }
114
+
115
+ // Store the list of environment IDs
116
+ await (0, _logger().instrument)(`RequestTracker::writeToCache::cache.put(${`EnvironmentManager/${_constants.ATLASPACK_VERSION}`})`, async () => {
117
+ await cache.set(`EnvironmentManager/${_constants.ATLASPACK_VERSION}`, Array.from(environmentIds));
118
+ });
119
+ }
120
+
121
+ /**
122
+ * Loads all environments and their IDs from the cache
123
+ * @param {Cache} cache
124
+ * @returns {Promise<void>}
125
+ */
126
+ async function loadEnvironmentsFromCache(cache) {
127
+ const cachedEnvIds = await cache.get(`EnvironmentManager/${_constants.ATLASPACK_VERSION}`);
128
+ if (cachedEnvIds == null) {
129
+ return;
130
+ }
131
+ const environments = [];
132
+ // @ts-expect-error TS2488
133
+ for (const envId of cachedEnvIds) {
134
+ const envKey = `Environment/${_constants.ATLASPACK_VERSION}/${envId}`;
135
+ const cachedEnv = await cache.get(envKey);
136
+ if (cachedEnv != null) {
137
+ environments.push(cachedEnv);
138
+ }
139
+ }
140
+ if (environments.length > 0) {
141
+ (0, _rust().setAllEnvironments)(environments);
142
+ }
143
+ }