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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (355) hide show
  1. package/CHANGELOG.md +561 -0
  2. package/dist/AssetGraph.js +591 -0
  3. package/dist/Atlaspack.js +656 -0
  4. package/dist/AtlaspackConfig.js +324 -0
  5. package/dist/AtlaspackConfig.schema.js +108 -0
  6. package/dist/BundleGraph.js +1628 -0
  7. package/dist/CommittedAsset.js +142 -0
  8. package/dist/Dependency.js +125 -0
  9. package/dist/Environment.js +132 -0
  10. package/dist/EnvironmentManager.js +108 -0
  11. package/dist/IdentifierRegistry.js +38 -0
  12. package/dist/InternalConfig.js +37 -0
  13. package/dist/PackagerRunner.js +531 -0
  14. package/dist/ReporterRunner.js +151 -0
  15. package/dist/RequestTracker.js +1368 -0
  16. package/dist/SymbolPropagation.js +617 -0
  17. package/dist/TargetDescriptor.schema.js +143 -0
  18. package/dist/Transformation.js +487 -0
  19. package/dist/UncommittedAsset.js +315 -0
  20. package/dist/Validation.js +196 -0
  21. package/dist/applyRuntimes.js +305 -0
  22. package/dist/assetUtils.js +168 -0
  23. package/dist/atlaspack-v3/AtlaspackV3.js +70 -0
  24. package/dist/atlaspack-v3/NapiWorkerPool.js +57 -0
  25. package/dist/atlaspack-v3/fs.js +52 -0
  26. package/dist/atlaspack-v3/index.js +25 -0
  27. package/dist/atlaspack-v3/jsCallable.js +16 -0
  28. package/dist/atlaspack-v3/worker/compat/asset-symbols.js +190 -0
  29. package/dist/atlaspack-v3/worker/compat/bitflags.js +94 -0
  30. package/dist/atlaspack-v3/worker/compat/dependency.js +43 -0
  31. package/dist/atlaspack-v3/worker/compat/environment.js +57 -0
  32. package/dist/atlaspack-v3/worker/compat/index.js +25 -0
  33. package/dist/atlaspack-v3/worker/compat/mutable-asset.js +152 -0
  34. package/dist/atlaspack-v3/worker/compat/plugin-config.js +76 -0
  35. package/dist/atlaspack-v3/worker/compat/plugin-logger.js +26 -0
  36. package/dist/atlaspack-v3/worker/compat/plugin-options.js +122 -0
  37. package/dist/atlaspack-v3/worker/compat/plugin-tracer.js +10 -0
  38. package/dist/atlaspack-v3/worker/compat/target.js +14 -0
  39. package/dist/atlaspack-v3/worker/worker.js +292 -0
  40. package/dist/constants.js +17 -0
  41. package/dist/dumpGraphToGraphViz.js +281 -0
  42. package/dist/index.js +62 -0
  43. package/dist/loadAtlaspackPlugin.js +128 -0
  44. package/dist/loadDotEnv.js +41 -0
  45. package/dist/projectPath.js +83 -0
  46. package/dist/public/Asset.js +279 -0
  47. package/dist/public/Bundle.js +224 -0
  48. package/dist/public/BundleGraph.js +359 -0
  49. package/dist/public/BundleGroup.js +53 -0
  50. package/dist/public/Config.js +286 -0
  51. package/dist/public/Dependency.js +138 -0
  52. package/dist/public/Environment.js +278 -0
  53. package/dist/public/MutableBundleGraph.js +277 -0
  54. package/dist/public/PluginOptions.js +80 -0
  55. package/dist/public/Symbols.js +248 -0
  56. package/dist/public/Target.js +69 -0
  57. package/dist/registerCoreWithSerializer.js +38 -0
  58. package/dist/requests/AssetGraphRequest.js +429 -0
  59. package/dist/requests/AssetGraphRequestRust.js +246 -0
  60. package/dist/requests/AssetRequest.js +130 -0
  61. package/dist/requests/AtlaspackBuildRequest.js +60 -0
  62. package/dist/requests/AtlaspackConfigRequest.js +490 -0
  63. package/dist/requests/BundleGraphRequest.js +441 -0
  64. package/dist/requests/ConfigRequest.js +222 -0
  65. package/dist/requests/DevDepRequest.js +204 -0
  66. package/dist/requests/EntryRequest.js +314 -0
  67. package/dist/requests/PackageRequest.js +65 -0
  68. package/dist/requests/PathRequest.js +349 -0
  69. package/dist/requests/TargetRequest.js +1310 -0
  70. package/dist/requests/ValidationRequest.js +49 -0
  71. package/dist/requests/WriteBundleRequest.js +254 -0
  72. package/dist/requests/WriteBundlesRequest.js +165 -0
  73. package/dist/requests/asset-graph-diff.js +126 -0
  74. package/dist/requests/asset-graph-dot.js +131 -0
  75. package/dist/resolveOptions.js +268 -0
  76. package/dist/rustWorkerThreadDylibHack.js +19 -0
  77. package/dist/serializerCore.browser.js +43 -0
  78. package/dist/summarizeRequest.js +39 -0
  79. package/dist/types.js +31 -0
  80. package/dist/utils.js +172 -0
  81. package/dist/worker.js +123 -0
  82. package/lib/AssetGraph.js +111 -14
  83. package/lib/Atlaspack.js +82 -35
  84. package/lib/AtlaspackConfig.js +15 -3
  85. package/lib/AtlaspackConfig.schema.js +7 -5
  86. package/lib/BundleGraph.js +83 -30
  87. package/lib/CommittedAsset.js +6 -0
  88. package/lib/Dependency.js +8 -2
  89. package/lib/Environment.js +15 -8
  90. package/lib/EnvironmentManager.js +143 -0
  91. package/lib/IdentifierRegistry.js +1 -3
  92. package/lib/InternalConfig.js +3 -2
  93. package/lib/PackagerRunner.js +66 -23
  94. package/lib/ReporterRunner.js +6 -9
  95. package/lib/RequestTracker.js +256 -139
  96. package/lib/SymbolPropagation.js +22 -3
  97. package/lib/TargetDescriptor.schema.js +7 -1
  98. package/lib/Transformation.js +16 -9
  99. package/lib/UncommittedAsset.js +30 -9
  100. package/lib/Validation.js +18 -2
  101. package/lib/applyRuntimes.js +9 -1
  102. package/lib/assetUtils.js +7 -4
  103. package/lib/atlaspack-v3/AtlaspackV3.js +32 -7
  104. package/lib/atlaspack-v3/NapiWorkerPool.js +3 -0
  105. package/lib/atlaspack-v3/fs.js +3 -1
  106. package/lib/atlaspack-v3/index.js +28 -1
  107. package/lib/atlaspack-v3/jsCallable.js +0 -2
  108. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +7 -4
  109. package/lib/atlaspack-v3/worker/compat/bitflags.js +7 -6
  110. package/lib/atlaspack-v3/worker/compat/dependency.js +3 -0
  111. package/lib/atlaspack-v3/worker/compat/environment.js +10 -7
  112. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +14 -9
  113. package/lib/atlaspack-v3/worker/compat/plugin-config.js +8 -10
  114. package/lib/atlaspack-v3/worker/compat/plugin-options.js +1 -0
  115. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
  116. package/lib/atlaspack-v3/worker/compat/target.js +2 -0
  117. package/lib/atlaspack-v3/worker/index.js +3 -0
  118. package/lib/atlaspack-v3/worker/worker.js +34 -6
  119. package/lib/constants.js +0 -1
  120. package/lib/dumpGraphToGraphViz.js +71 -16
  121. package/lib/index.js +45 -1
  122. package/lib/loadDotEnv.js +4 -1
  123. package/lib/projectPath.js +5 -0
  124. package/lib/public/Asset.js +21 -11
  125. package/lib/public/Bundle.js +15 -16
  126. package/lib/public/BundleGraph.js +10 -4
  127. package/lib/public/BundleGroup.js +4 -5
  128. package/lib/public/Config.js +118 -17
  129. package/lib/public/Dependency.js +8 -6
  130. package/lib/public/Environment.js +12 -7
  131. package/lib/public/MutableBundleGraph.js +54 -12
  132. package/lib/public/PluginOptions.js +2 -2
  133. package/lib/public/Symbols.js +11 -11
  134. package/lib/public/Target.js +7 -6
  135. package/lib/registerCoreWithSerializer.js +5 -3
  136. package/lib/requests/AssetGraphRequest.js +41 -4
  137. package/lib/requests/AssetGraphRequestRust.js +29 -14
  138. package/lib/requests/AssetRequest.js +23 -6
  139. package/lib/requests/AtlaspackBuildRequest.js +6 -2
  140. package/lib/requests/AtlaspackConfigRequest.js +12 -11
  141. package/lib/requests/BundleGraphRequest.js +29 -18
  142. package/lib/requests/ConfigRequest.js +28 -4
  143. package/lib/requests/DevDepRequest.js +31 -5
  144. package/lib/requests/EntryRequest.js +2 -0
  145. package/lib/requests/PackageRequest.js +7 -2
  146. package/lib/requests/PathRequest.js +24 -3
  147. package/lib/requests/TargetRequest.js +120 -56
  148. package/lib/requests/ValidationRequest.js +5 -1
  149. package/lib/requests/WriteBundleRequest.js +39 -11
  150. package/lib/requests/WriteBundlesRequest.js +24 -2
  151. package/lib/requests/asset-graph-diff.js +8 -3
  152. package/lib/requests/asset-graph-dot.js +1 -7
  153. package/lib/resolveOptions.js +36 -10
  154. package/lib/rustWorkerThreadDylibHack.js +0 -1
  155. package/lib/types/AssetGraph.d.ts +80 -0
  156. package/lib/types/Atlaspack.d.ts +52 -0
  157. package/lib/types/AtlaspackConfig.d.ts +65 -0
  158. package/lib/types/AtlaspackConfig.schema.d.ts +46 -0
  159. package/lib/types/BundleGraph.d.ts +182 -0
  160. package/lib/types/CommittedAsset.d.ts +23 -0
  161. package/lib/types/Dependency.d.ts +44 -0
  162. package/lib/types/Environment.d.ts +11 -0
  163. package/lib/types/EnvironmentManager.d.ts +37 -0
  164. package/lib/types/IdentifierRegistry.d.ts +6 -0
  165. package/lib/types/InternalConfig.d.ts +24 -0
  166. package/lib/types/PackagerRunner.d.ts +80 -0
  167. package/lib/types/ReporterRunner.d.ts +25 -0
  168. package/lib/types/RequestTracker.d.ts +385 -0
  169. package/lib/types/SymbolPropagation.d.ts +11 -0
  170. package/lib/types/TargetDescriptor.schema.d.ts +5 -0
  171. package/lib/types/Transformation.d.ts +72 -0
  172. package/lib/types/UncommittedAsset.d.ts +61 -0
  173. package/lib/types/Validation.d.ts +37 -0
  174. package/lib/types/applyRuntimes.d.ts +25 -0
  175. package/lib/types/assetUtils.d.ts +42 -0
  176. package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +26 -0
  177. package/lib/types/atlaspack-v3/NapiWorkerPool.d.ts +12 -0
  178. package/lib/types/atlaspack-v3/fs.d.ts +12 -0
  179. package/lib/types/atlaspack-v3/index.d.ts +5 -0
  180. package/lib/types/atlaspack-v3/jsCallable.d.ts +1 -0
  181. package/lib/types/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
  182. package/lib/types/atlaspack-v3/worker/compat/bitflags.d.ts +15 -0
  183. package/lib/types/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
  184. package/lib/types/atlaspack-v3/worker/compat/environment.d.ts +27 -0
  185. package/{src/atlaspack-v3/worker/compat/index.js → lib/types/atlaspack-v3/worker/compat/index.d.ts} +0 -1
  186. package/lib/types/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
  187. package/lib/types/atlaspack-v3/worker/compat/plugin-config.d.ts +37 -0
  188. package/lib/types/atlaspack-v3/worker/compat/plugin-logger.d.ts +9 -0
  189. package/lib/types/atlaspack-v3/worker/compat/plugin-options.d.ts +22 -0
  190. package/lib/types/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
  191. package/lib/types/atlaspack-v3/worker/compat/target.d.ts +11 -0
  192. package/lib/types/atlaspack-v3/worker/worker.d.ts +58 -0
  193. package/lib/types/constants.d.ts +13 -0
  194. package/lib/types/dumpGraphToGraphViz.d.ts +10 -0
  195. package/lib/types/index.d.ts +8 -0
  196. package/lib/types/loadAtlaspackPlugin.d.ts +8 -0
  197. package/lib/types/loadDotEnv.d.ts +3 -0
  198. package/lib/types/projectPath.d.ts +19 -0
  199. package/lib/types/public/Asset.d.ts +74 -0
  200. package/lib/types/public/Bundle.d.ts +45 -0
  201. package/lib/types/public/BundleGraph.d.ts +70 -0
  202. package/lib/types/public/BundleGroup.d.ts +12 -0
  203. package/lib/types/public/Config.d.ts +75 -0
  204. package/lib/types/public/Dependency.d.ts +32 -0
  205. package/lib/types/public/Environment.d.ts +34 -0
  206. package/lib/types/public/MutableBundleGraph.d.ts +26 -0
  207. package/lib/types/public/PluginOptions.d.ts +25 -0
  208. package/lib/types/public/Symbols.d.ts +81 -0
  209. package/lib/types/public/Target.d.ts +16 -0
  210. package/lib/types/registerCoreWithSerializer.d.ts +2 -0
  211. package/lib/types/requests/AssetGraphRequest.d.ts +74 -0
  212. package/lib/types/requests/AssetGraphRequestRust.d.ts +21 -0
  213. package/lib/types/requests/AssetRequest.d.ts +16 -0
  214. package/lib/types/requests/AtlaspackBuildRequest.d.ts +29 -0
  215. package/lib/types/requests/AtlaspackConfigRequest.d.ts +45 -0
  216. package/lib/types/requests/BundleGraphRequest.d.ts +28 -0
  217. package/lib/types/requests/ConfigRequest.d.ts +59 -0
  218. package/lib/types/requests/DevDepRequest.d.ts +30 -0
  219. package/lib/types/requests/EntryRequest.d.ts +36 -0
  220. package/lib/types/requests/PackageRequest.d.ts +27 -0
  221. package/lib/types/requests/PathRequest.d.ts +48 -0
  222. package/lib/types/requests/TargetRequest.d.ts +48 -0
  223. package/lib/types/requests/ValidationRequest.d.ts +20 -0
  224. package/lib/types/requests/WriteBundleRequest.d.ts +28 -0
  225. package/lib/types/requests/WriteBundlesRequest.d.ts +26 -0
  226. package/lib/types/requests/asset-graph-diff.d.ts +1 -0
  227. package/lib/types/requests/asset-graph-dot.d.ts +9 -0
  228. package/lib/types/resolveOptions.d.ts +3 -0
  229. package/lib/types/rustWorkerThreadDylibHack.d.ts +9 -0
  230. package/lib/types/serializerCore.browser.d.ts +3 -0
  231. package/lib/types/summarizeRequest.d.ts +10 -0
  232. package/lib/types/types.d.ts +493 -0
  233. package/lib/types/utils.d.ts +23 -0
  234. package/lib/types/worker.d.ts +44 -0
  235. package/lib/types.js +8 -1
  236. package/lib/utils.js +17 -2
  237. package/lib/worker.js +29 -13
  238. package/package.json +24 -34
  239. package/src/{AssetGraph.js → AssetGraph.ts} +156 -52
  240. package/src/{Atlaspack.js → Atlaspack.ts} +113 -60
  241. package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +16 -19
  242. package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +78 -54
  243. package/src/{BundleGraph.js → BundleGraph.ts} +213 -133
  244. package/src/{CommittedAsset.js → CommittedAsset.ts} +14 -12
  245. package/src/{Dependency.js → Dependency.ts} +59 -42
  246. package/src/{Environment.js → Environment.ts} +24 -15
  247. package/src/EnvironmentManager.ts +154 -0
  248. package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
  249. package/src/{InternalConfig.js → InternalConfig.ts} +22 -23
  250. package/src/{PackagerRunner.js → PackagerRunner.ts} +149 -81
  251. package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
  252. package/src/{RequestTracker.js → RequestTracker.ts} +558 -336
  253. package/src/{SymbolPropagation.js → SymbolPropagation.ts} +137 -39
  254. package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +7 -1
  255. package/src/{Transformation.js → Transformation.ts} +67 -61
  256. package/src/{UncommittedAsset.js → UncommittedAsset.ts} +57 -36
  257. package/src/{Validation.js → Validation.ts} +32 -17
  258. package/src/{applyRuntimes.js → applyRuntimes.ts} +35 -26
  259. package/src/{assetUtils.js → assetUtils.ts} +47 -35
  260. package/src/atlaspack-v3/AtlaspackV3.ts +122 -0
  261. package/src/atlaspack-v3/{NapiWorkerPool.js → NapiWorkerPool.ts} +10 -5
  262. package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
  263. package/src/atlaspack-v3/{index.js → index.ts} +2 -4
  264. package/src/atlaspack-v3/jsCallable.ts +14 -0
  265. package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +40 -30
  266. package/src/atlaspack-v3/worker/compat/{bitflags.js → bitflags.ts} +9 -10
  267. package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +12 -12
  268. package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +13 -9
  269. package/src/atlaspack-v3/worker/compat/index.ts +9 -0
  270. package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +20 -19
  271. package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +27 -26
  272. package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
  273. package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +4 -5
  274. package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
  275. package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
  276. package/src/atlaspack-v3/worker/index.js +2 -1
  277. package/src/atlaspack-v3/worker/{worker.js → worker.ts} +94 -65
  278. package/src/{constants.js → constants.ts} +0 -3
  279. package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
  280. package/src/index.ts +18 -0
  281. package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +8 -9
  282. package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
  283. package/src/{projectPath.js → projectPath.ts} +20 -9
  284. package/src/public/{Asset.js → Asset.ts} +40 -27
  285. package/src/public/{Bundle.js → Bundle.ts} +28 -29
  286. package/src/public/{BundleGraph.js → BundleGraph.ts} +81 -50
  287. package/src/public/{BundleGroup.js → BundleGroup.ts} +7 -10
  288. package/src/public/{Config.js → Config.ts} +171 -33
  289. package/src/public/{Dependency.js → Dependency.ts} +20 -17
  290. package/src/public/{Environment.js → Environment.ts} +28 -17
  291. package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +55 -24
  292. package/src/public/{PluginOptions.js → PluginOptions.ts} +6 -6
  293. package/src/public/{Symbols.js → Symbols.ts} +75 -36
  294. package/src/public/{Target.js → Target.ts} +10 -8
  295. package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
  296. package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +83 -48
  297. package/src/requests/{AssetGraphRequestRust.js → AssetGraphRequestRust.ts} +36 -29
  298. package/src/requests/{AssetRequest.js → AssetRequest.ts} +24 -18
  299. package/src/requests/{AtlaspackBuildRequest.js → AtlaspackBuildRequest.ts} +30 -31
  300. package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +58 -51
  301. package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +66 -57
  302. package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +71 -50
  303. package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +60 -35
  304. package/src/requests/{EntryRequest.js → EntryRequest.ts} +36 -31
  305. package/src/requests/{PackageRequest.js → PackageRequest.ts} +21 -21
  306. package/src/requests/{PathRequest.js → PathRequest.ts} +47 -37
  307. package/src/requests/{TargetRequest.js → TargetRequest.ts} +259 -179
  308. package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
  309. package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +77 -49
  310. package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +77 -34
  311. package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +14 -14
  312. package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
  313. package/src/{resolveOptions.js → resolveOptions.ts} +56 -24
  314. package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
  315. package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
  316. package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
  317. package/src/types.ts +647 -0
  318. package/src/{utils.js → utils.ts} +52 -21
  319. package/src/{worker.js → worker.ts} +49 -41
  320. package/test/{AssetGraph.test.js → AssetGraph.test.ts} +37 -8
  321. package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
  322. package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
  323. package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +3 -15
  324. package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
  325. package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
  326. package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
  327. package/test/Environment.test.ts +153 -0
  328. package/test/EnvironmentManager.test.ts +188 -0
  329. package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
  330. package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
  331. package/test/PackagerRunner.test.ts +0 -0
  332. package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
  333. package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
  334. package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
  335. package/test/PublicEnvironment.test.ts +49 -0
  336. package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
  337. package/test/{RequestTracker.test.js → RequestTracker.test.ts} +314 -59
  338. package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
  339. package/test/{TargetRequest.test.js → TargetRequest.test.ts} +54 -92
  340. package/test/public/Config.test.ts +104 -0
  341. package/test/requests/{AssetGraphRequestRust.test.js → AssetGraphRequestRust.test.ts} +163 -134
  342. package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +202 -13
  343. package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
  344. package/test/{test-utils.js → test-utils.ts} +4 -11
  345. package/test/{utils.test.js → utils.test.ts} +1 -3
  346. package/tsconfig.json +57 -0
  347. package/tsconfig.tsbuildinfo +1 -0
  348. package/index.d.ts +0 -30
  349. package/src/atlaspack-v3/AtlaspackV3.js +0 -87
  350. package/src/atlaspack-v3/jsCallable.js +0 -18
  351. package/src/index.js +0 -13
  352. package/src/types.js +0 -600
  353. package/test/Environment.test.js +0 -119
  354. package/test/PackagerRunner.test.js +0 -27
  355. package/test/PublicEnvironment.test.js +0 -27
@@ -1,5 +1,3 @@
1
- // @flow strict-local
2
-
3
1
  import type {Diagnostic} from '@atlaspack/diagnostic';
4
2
  import type {FileSystem} from '@atlaspack/fs';
5
3
  import type {
@@ -34,7 +32,6 @@ import {createEnvironment} from '../Environment';
34
32
  import createAtlaspackConfigRequest, {
35
33
  getCachedAtlaspackConfig,
36
34
  } from './AtlaspackConfigRequest';
37
- // $FlowFixMe
38
35
  import browserslist from 'browserslist';
39
36
  import {parse} from '@mischnic/json-sourcemap';
40
37
  import invariant from 'assert';
@@ -49,11 +46,12 @@ import {BROWSER_ENVS} from '../public/Environment';
49
46
  import {optionsProxy, toInternalSourceLocation} from '../utils';
50
47
  import {fromProjectPath, toProjectPath, joinProjectPath} from '../projectPath';
51
48
  import {requestTypes} from '../RequestTracker';
49
+ import {fromEnvironmentId} from '../EnvironmentManager';
50
+ import {getFeatureFlag} from '@atlaspack/feature-flags';
52
51
 
53
- type RunOpts<TResult> = {|
54
- input: Entry,
55
- ...StaticRunOpts<TResult>,
56
- |};
52
+ type RunOpts<TResult> = {
53
+ input: Entry;
54
+ } & StaticRunOpts<TResult>;
57
55
 
58
56
  const DEFAULT_DIST_DIRNAME = 'dist';
59
57
  const JS_RE = /\.[mc]?js$/;
@@ -76,7 +74,7 @@ const COMMON_TARGETS = {
76
74
  match: /\.d\.ts$/,
77
75
  extensions: ['.d.ts'],
78
76
  },
79
- };
77
+ } as const;
80
78
 
81
79
  const DEFAULT_ENGINES = {
82
80
  node: 'current',
@@ -86,14 +84,14 @@ const DEFAULT_ENGINES = {
86
84
  'last 1 Firefox version',
87
85
  'last 1 Edge version',
88
86
  ],
89
- };
87
+ } as const;
90
88
 
91
- export type TargetRequest = {|
92
- id: string,
93
- +type: typeof requestTypes.target_request,
94
- run: (RunOpts<TargetRequestResult>) => Async<TargetRequestResult>,
95
- input: Entry,
96
- |};
89
+ export type TargetRequest = {
90
+ id: string;
91
+ readonly type: typeof requestTypes.target_request;
92
+ run: (arg1: RunOpts<TargetRequestResult>) => Async<TargetRequestResult>;
93
+ input: Entry;
94
+ };
97
95
 
98
96
  export type TargetRequestResult = Target[];
99
97
 
@@ -122,7 +120,7 @@ export function skipTarget(
122
120
  : targetName !== exclusiveTarget;
123
121
  }
124
122
 
125
- async function run({input, api, options}) {
123
+ async function run({input, api, options}: RunOpts<TargetRequestResult>) {
126
124
  let targetResolver = new TargetResolver(
127
125
  api,
128
126
  optionsProxy(options, api.invalidateOnOptionChange),
@@ -132,6 +130,47 @@ async function run({input, api, options}) {
132
130
  input.target,
133
131
  );
134
132
 
133
+ // Filter targets based on allowExplicitTargetEntries feature flag
134
+ if (
135
+ getFeatureFlag('allowExplicitTargetEntries') &&
136
+ options.targets &&
137
+ // Only explicit targets are allowed (i.e. an object of targets)
138
+ !Array.isArray(options.targets)
139
+ ) {
140
+ // Check if ALL targets have sources - only apply new behavior if they do
141
+ const allTargetsHaveSources = targets.every((t) => t.source);
142
+ if (allTargetsHaveSources) {
143
+ // Get the current entry file path relative to project root
144
+ const currentEntryPath = input.filePath;
145
+
146
+ // Filter targets to only include those whose source matches the current entry
147
+ targets = targets.filter((target) => {
148
+ // Handle both string and array sources
149
+ const sources = Array.isArray(target.source)
150
+ ? target.source
151
+ : [target.source];
152
+
153
+ // Check if current entry matches any of the target sources
154
+ return sources.some((source) => {
155
+ const targetSourcePath = toProjectPath(
156
+ options.projectRoot,
157
+ path.resolve(
158
+ fromProjectPath(options.projectRoot, input.packagePath),
159
+ nullthrows(
160
+ source,
161
+ 'Source must be not be undefined when specified',
162
+ ),
163
+ ),
164
+ );
165
+ return targetSourcePath === currentEntryPath;
166
+ });
167
+ });
168
+ } else {
169
+ // If not all targets have sources, fall back to old behavior (skip targets with sources)
170
+ targets = targets.filter((target) => !target.source);
171
+ }
172
+ }
173
+
135
174
  assertTargetsAreNotEntries(targets, input, options);
136
175
 
137
176
  let configResult = nullthrows(
@@ -161,30 +200,30 @@ async function run({input, api, options}) {
161
200
  return targets;
162
201
  }
163
202
 
164
- type TargetInfo = {|
165
- output: TargetKeyInfo,
166
- engines: TargetKeyInfo,
167
- context: TargetKeyInfo,
168
- includeNodeModules: TargetKeyInfo,
169
- outputFormat: TargetKeyInfo,
170
- isLibrary: TargetKeyInfo,
171
- shouldOptimize: TargetKeyInfo,
172
- shouldScopeHoist: TargetKeyInfo,
173
- |};
203
+ type TargetInfo = {
204
+ output: TargetKeyInfo;
205
+ engines: TargetKeyInfo;
206
+ context: TargetKeyInfo;
207
+ includeNodeModules: TargetKeyInfo;
208
+ outputFormat: TargetKeyInfo;
209
+ isLibrary: TargetKeyInfo;
210
+ shouldOptimize: TargetKeyInfo;
211
+ shouldScopeHoist: TargetKeyInfo;
212
+ };
174
213
 
175
214
  type TargetKeyInfo =
176
- | {|
177
- path: string,
178
- type?: 'key' | 'value',
179
- |}
180
- | {|
181
- inferred: string,
182
- type?: 'key' | 'value',
183
- message: string,
184
- |}
185
- | {|
186
- message: string,
187
- |};
215
+ | {
216
+ path: string;
217
+ type?: 'key' | 'value';
218
+ }
219
+ | {
220
+ inferred: string;
221
+ type?: 'key' | 'value';
222
+ message: string;
223
+ }
224
+ | {
225
+ message: string;
226
+ };
188
227
 
189
228
  export class TargetResolver {
190
229
  fs: FileSystem;
@@ -231,6 +270,7 @@ export class TargetResolver {
231
270
 
232
271
  // If an array of strings is passed, it's a filter on the resolved package
233
272
  // targets. Load them, and find the matching targets.
273
+ // @ts-expect-error TS2322
234
274
  targets = optionTargets
235
275
  .map((target) => {
236
276
  // null means skipped.
@@ -249,7 +289,7 @@ export class TargetResolver {
249
289
  // Otherwise, it's an object map of target descriptors (similar to those
250
290
  // in package.json). Adapt them to native targets.
251
291
  targets = Object.entries(optionTargets)
252
- .map(([name, _descriptor]) => {
292
+ .map(([name, _descriptor]: [any, any]) => {
253
293
  let {distDir, ...descriptor} = parseDescriptor(
254
294
  name,
255
295
  _descriptor,
@@ -314,6 +354,7 @@ export class TargetResolver {
314
354
  ),
315
355
  unstableSingleFileOutput:
316
356
  descriptor.__unstable_singleFileOutput,
357
+ customEnv: descriptor.env,
317
358
  }),
318
359
  };
319
360
 
@@ -329,8 +370,21 @@ export class TargetResolver {
329
370
  })
330
371
  .filter(
331
372
  (target) =>
373
+ (getFeatureFlag('allowExplicitTargetEntries') &&
374
+ this.options.entries.length !== 0) ||
332
375
  !skipTarget(target.name, exclusiveTarget, target.source),
333
376
  );
377
+
378
+ // Apply allowExplicitTargetEntries filtering logic
379
+ if (getFeatureFlag('allowExplicitTargetEntries')) {
380
+ // Check if ALL targets have sources - only apply new behavior if they do
381
+ const allTargetsHaveSources = targets.every((t) => t.source);
382
+
383
+ if (!allTargetsHaveSources) {
384
+ // If not all targets have sources, fall back to old behavior (skip targets with sources)
385
+ targets = targets.filter((target) => !target.source);
386
+ }
387
+ }
334
388
  }
335
389
 
336
390
  let serve = this.options.serveOptions;
@@ -345,7 +399,7 @@ export class TargetResolver {
345
399
  },
346
400
  });
347
401
  }
348
- if (!BROWSER_ENVS.has(targets[0].env.context)) {
402
+ if (!BROWSER_ENVS.has(fromEnvironmentId(targets[0].env).context)) {
349
403
  throw new ThrowableDiagnostic({
350
404
  diagnostic: {
351
405
  message: `Only browser targets are supported in serve mode`,
@@ -375,6 +429,7 @@ export class TargetResolver {
375
429
  env: createEnvironment({
376
430
  context: 'browser',
377
431
  engines: {
432
+ // @ts-expect-error TS2322
378
433
  browsers: DEFAULT_ENGINES.browsers,
379
434
  },
380
435
  shouldOptimize: this.options.defaultTargetOptions.shouldOptimize,
@@ -388,6 +443,7 @@ export class TargetResolver {
388
443
  },
389
444
  ];
390
445
  } else {
446
+ // @ts-expect-error TS2322
391
447
  targets = Array.from(packageTargets.values())
392
448
  .filter(Boolean)
393
449
  .filter((descriptor) => {
@@ -424,11 +480,11 @@ export class TargetResolver {
424
480
 
425
481
  let pkg;
426
482
  let pkgContents;
427
- let pkgFilePath: ?FilePath;
483
+ let pkgFilePath: FilePath | null | undefined;
428
484
  let pkgDir: FilePath;
429
485
  let pkgMap;
430
486
  if (conf) {
431
- pkg = (conf.config: PackageJSON);
487
+ pkg = conf.config as PackageJSON;
432
488
  let pkgFile = conf.files[0];
433
489
  if (pkgFile == null) {
434
490
  throw new ThrowableDiagnostic({
@@ -512,6 +568,7 @@ export class TargetResolver {
512
568
  };
513
569
 
514
570
  browsersLoc = {
571
+ // @ts-expect-error TS2353
515
572
  message: `(defined in ${path.relative(
516
573
  process.cwd(),
517
574
  browserslistConfig,
@@ -533,25 +590,28 @@ export class TargetResolver {
533
590
  let browsers = pkgEngines.browsers;
534
591
 
535
592
  let defaultEngines = this.options.defaultTargetOptions.engines;
536
- let context = browsers ?? node == null ? 'browser' : 'node';
593
+ let context = (browsers ?? node == null) ? 'browser' : 'node';
537
594
  if (context === 'browser' && pkgEngines.browsers == null) {
538
595
  pkgEngines = {
539
596
  ...pkgEngines,
597
+ // @ts-expect-error TS2322
540
598
  browsers: defaultEngines?.browsers ?? DEFAULT_ENGINES.browsers,
541
599
  };
600
+ // @ts-expect-error TS2353
542
601
  browsersLoc = {message: '(default)'};
543
602
  } else if (context === 'node' && pkgEngines.node == null) {
544
603
  pkgEngines = {
545
604
  ...pkgEngines,
546
605
  node: defaultEngines?.node ?? DEFAULT_ENGINES.node,
547
606
  };
607
+ // @ts-expect-error TS2353
548
608
  nodeLoc = {message: '(default)'};
549
609
  }
550
610
 
551
611
  // If there is a separate `browser` target, or an `engines.node` field but no browser targets, then
552
612
  // the `main` and `module` targets refer to node, otherwise browser.
553
613
  let mainContext =
554
- pkg.browser ?? pkgTargets.browser ?? (node != null && browsers == null)
614
+ (pkg.browser ?? pkgTargets.browser ?? (node != null && browsers == null))
555
615
  ? 'node'
556
616
  : 'browser';
557
617
  let mainContextLoc: TargetKeyInfo =
@@ -562,22 +622,22 @@ export class TargetResolver {
562
622
  type: 'key',
563
623
  }
564
624
  : pkgTargets.browser
565
- ? {
566
- inferred: '/targets/browser',
567
- message: '(because a browser target also exists)',
568
- type: 'key',
569
- }
570
- : node != null && browsers == null
571
- ? nodeLoc.path
572
625
  ? {
573
- inferred: nodeLoc.path,
574
- message: '(because node engines were defined)',
626
+ inferred: '/targets/browser',
627
+ message: '(because a browser target also exists)',
575
628
  type: 'key',
576
629
  }
577
- : nodeLoc
578
- : {message: '(default)'};
630
+ : node != null && browsers == null
631
+ ? nodeLoc.path
632
+ ? {
633
+ inferred: nodeLoc.path,
634
+ message: '(because node engines were defined)',
635
+ type: 'key',
636
+ }
637
+ : nodeLoc
638
+ : {message: '(default)'};
579
639
  let moduleContext =
580
- pkg.browser ?? pkgTargets.browser ? 'browser' : mainContext;
640
+ (pkg.browser ?? pkgTargets.browser) ? 'browser' : mainContext;
581
641
  let moduleContextLoc: TargetKeyInfo =
582
642
  pkg.browser != null
583
643
  ? {
@@ -586,14 +646,17 @@ export class TargetResolver {
586
646
  type: 'key',
587
647
  }
588
648
  : pkgTargets.browser
589
- ? {
590
- inferred: '/targets/browser',
591
- message: '(becausea browser target also exists)',
592
- type: 'key',
593
- }
594
- : mainContextLoc;
649
+ ? {
650
+ inferred: '/targets/browser',
651
+ message: '(becausea browser target also exists)',
652
+ type: 'key',
653
+ }
654
+ : mainContextLoc;
595
655
 
596
- let getEnginesLoc = (targetName, descriptor): TargetKeyInfo => {
656
+ let getEnginesLoc = (
657
+ targetName: string,
658
+ descriptor: PackageTargetDescriptor,
659
+ ): TargetKeyInfo => {
597
660
  let enginesLoc = `/targets/${targetName}/engines`;
598
661
  switch (context) {
599
662
  case 'browser':
@@ -639,6 +702,7 @@ export class TargetResolver {
639
702
  _targetDist = pkg[targetName][pkg.name];
640
703
  pointer = `/${targetName}/${encodeJSONKeyComponent(pkg.name)}`;
641
704
  } else {
705
+ // @ts-expect-error TS7053
642
706
  _targetDist = pkg[targetName];
643
707
  pointer = `/${targetName}`;
644
708
  }
@@ -652,7 +716,7 @@ export class TargetResolver {
652
716
 
653
717
  invariant(pkgMap != null);
654
718
 
655
- let _descriptor: mixed = pkgTargets[targetName] ?? {};
719
+ let _descriptor: unknown = pkgTargets[targetName] ?? {};
656
720
  if (typeof targetDist === 'string') {
657
721
  distDir = toProjectPath(
658
722
  this.options.projectRoot,
@@ -690,16 +754,16 @@ export class TargetResolver {
690
754
 
691
755
  if (
692
756
  distEntry != null &&
757
+ // @ts-expect-error TS7053
693
758
  !COMMON_TARGETS[targetName].match.test(distEntry)
694
759
  ) {
695
760
  let contents: string =
696
761
  typeof pkgContents === 'string'
697
762
  ? pkgContents
698
- : // $FlowFixMe
699
- JSON.stringify(pkgContents, null, '\t');
700
- // $FlowFixMe
763
+ : JSON.stringify(pkgContents, null, '\t');
701
764
  let listFormat = new Intl.ListFormat('en-US', {type: 'disjunction'});
702
765
  let extensions = listFormat.format(
766
+ // @ts-expect-error TS7053
703
767
  COMMON_TARGETS[targetName].extensions,
704
768
  );
705
769
  let ext = path.extname(distEntry);
@@ -734,8 +798,7 @@ export class TargetResolver {
734
798
  let contents: string =
735
799
  typeof pkgContents === 'string'
736
800
  ? pkgContents
737
- : // $FlowFixMe
738
- JSON.stringify(pkgContents, null, '\t');
801
+ : JSON.stringify(pkgContents, null, '\t');
739
802
  throw new ThrowableDiagnostic({
740
803
  diagnostic: {
741
804
  message: md`The "global" output format is not supported in the "${targetName}" target.`,
@@ -767,6 +830,7 @@ export class TargetResolver {
767
830
  distEntry,
768
831
  descriptor,
769
832
  targetName,
833
+ // @ts-expect-error TS2345
770
834
  pkg,
771
835
  pkgFilePath,
772
836
  pkgContents,
@@ -787,8 +851,7 @@ export class TargetResolver {
787
851
  let contents: string =
788
852
  typeof pkgContents === 'string'
789
853
  ? pkgContents
790
- : // $FlowFixMe
791
- JSON.stringify(pkgContents, null, '\t');
854
+ : JSON.stringify(pkgContents, null, '\t');
792
855
  throw new ThrowableDiagnostic({
793
856
  diagnostic: {
794
857
  // prettier-ignore
@@ -826,8 +889,7 @@ export class TargetResolver {
826
889
  let contents: string =
827
890
  typeof pkgContents === 'string'
828
891
  ? pkgContents
829
- : // $FlowFixMe
830
- JSON.stringify(pkgContents, null, '\t');
892
+ : JSON.stringify(pkgContents, null, '\t');
831
893
  throw new ThrowableDiagnostic({
832
894
  diagnostic: {
833
895
  message: 'Scope hoisting cannot be disabled for library targets.',
@@ -859,8 +921,8 @@ export class TargetResolver {
859
921
  (targetName === 'browser'
860
922
  ? 'browser'
861
923
  : isModule
862
- ? moduleContext
863
- : mainContext);
924
+ ? moduleContext
925
+ : mainContext);
864
926
 
865
927
  targets.set(targetName, {
866
928
  name: targetName,
@@ -870,6 +932,7 @@ export class TargetResolver {
870
932
  descriptor.publicUrl ?? this.options.defaultTargetOptions.publicUrl,
871
933
  env: createEnvironment({
872
934
  engines: descriptor.engines ?? pkgEngines,
935
+ // @ts-expect-error TS2322
873
936
  context,
874
937
  includeNodeModules: descriptor.includeNodeModules ?? false,
875
938
  outputFormat,
@@ -889,30 +952,30 @@ export class TargetResolver {
889
952
  context: descriptor.context
890
953
  ? {path: `/targets/${targetName}/context`}
891
954
  : targetName === 'browser'
892
- ? {
893
- message: '(inferred from target name)',
894
- inferred: pointer,
895
- type: 'key',
896
- }
897
- : isModule
898
- ? moduleContextLoc
899
- : mainContextLoc,
955
+ ? {
956
+ message: '(inferred from target name)',
957
+ inferred: pointer,
958
+ type: 'key',
959
+ }
960
+ : isModule
961
+ ? moduleContextLoc
962
+ : mainContextLoc,
900
963
  includeNodeModules: descriptor.includeNodeModules
901
964
  ? {path: `/targets/${targetName}/includeNodeModules`, type: 'key'}
902
965
  : {message: '(default)'},
903
966
  outputFormat: descriptor.outputFormat
904
967
  ? {path: `/targets/${targetName}/outputFormat`}
905
968
  : inferredOutputFormatField === '/type'
906
- ? {
907
- message: `(inferred from package.json#type)`,
908
- inferred: inferredOutputFormatField,
909
- }
910
- : inferredOutputFormatField != null
911
- ? {
912
- message: `(inferred from file extension)`,
913
- inferred: inferredOutputFormatField,
914
- }
915
- : {message: '(default)'},
969
+ ? {
970
+ message: `(inferred from package.json#type)`,
971
+ inferred: inferredOutputFormatField,
972
+ }
973
+ : inferredOutputFormatField != null
974
+ ? {
975
+ message: `(inferred from file extension)`,
976
+ inferred: inferredOutputFormatField,
977
+ }
978
+ : {message: '(default)'},
916
979
  isLibrary: {message: '(default)'},
917
980
  shouldOptimize: descriptor.optimize
918
981
  ? {path: `/targets/${targetName}/optimize`}
@@ -922,13 +985,15 @@ export class TargetResolver {
922
985
  }
923
986
  }
924
987
 
925
- let customTargets = (Object.keys(pkgTargets): Array<string>).filter(
988
+ let customTargets = (Object.keys(pkgTargets) as Array<string>).filter(
989
+ // @ts-expect-error TS7053
926
990
  (targetName) => !COMMON_TARGETS[targetName],
927
991
  );
928
992
 
929
993
  // Custom targets
930
994
  for (let targetName of customTargets) {
931
- let distPath: mixed = pkg[targetName];
995
+ // @ts-expect-error TS7053
996
+ let distPath: unknown = pkg[targetName];
932
997
  let distDir;
933
998
  let distEntry;
934
999
  let loc;
@@ -956,8 +1021,7 @@ export class TargetResolver {
956
1021
  let contents: string =
957
1022
  typeof pkgContents === 'string'
958
1023
  ? pkgContents
959
- : // $FlowFixMe
960
- JSON.stringify(pkgContents, null, '\t');
1024
+ : JSON.stringify(pkgContents, null, '\t');
961
1025
  throw new ThrowableDiagnostic({
962
1026
  diagnostic: {
963
1027
  message: md`Invalid distPath for target "${targetName}"`,
@@ -1009,6 +1073,7 @@ export class TargetResolver {
1009
1073
  distEntry,
1010
1074
  descriptor,
1011
1075
  targetName,
1076
+ // @ts-expect-error TS2345
1012
1077
  pkg,
1013
1078
  pkgFilePath,
1014
1079
  pkgContents,
@@ -1018,8 +1083,7 @@ export class TargetResolver {
1018
1083
  let contents: string =
1019
1084
  typeof pkgContents === 'string'
1020
1085
  ? pkgContents
1021
- : // $FlowFixMe
1022
- JSON.stringify(pkgContents, null, '\t');
1086
+ : JSON.stringify(pkgContents, null, '\t');
1023
1087
  throw new ThrowableDiagnostic({
1024
1088
  diagnostic: {
1025
1089
  message: 'Scope hoisting cannot be disabled for library targets.',
@@ -1103,16 +1167,16 @@ export class TargetResolver {
1103
1167
  outputFormat: descriptor.outputFormat
1104
1168
  ? {path: `/targets/${targetName}/outputFormat`}
1105
1169
  : inferredOutputFormatField === '/type'
1106
- ? {
1107
- message: `(inferred from package.json#type)`,
1108
- inferred: inferredOutputFormatField,
1109
- }
1110
- : inferredOutputFormatField != null
1111
- ? {
1112
- message: `(inferred from file extension)`,
1113
- inferred: inferredOutputFormatField,
1114
- }
1115
- : {message: '(default)'},
1170
+ ? {
1171
+ message: `(inferred from package.json#type)`,
1172
+ inferred: inferredOutputFormatField,
1173
+ }
1174
+ : inferredOutputFormatField != null
1175
+ ? {
1176
+ message: `(inferred from file extension)`,
1177
+ inferred: inferredOutputFormatField,
1178
+ }
1179
+ : {message: '(default)'},
1116
1180
  isLibrary:
1117
1181
  descriptor.isLibrary != null
1118
1182
  ? {path: `/targets/${targetName}/isLibrary`}
@@ -1142,6 +1206,7 @@ export class TargetResolver {
1142
1206
  publicUrl: this.options.defaultTargetOptions.publicUrl,
1143
1207
  env: createEnvironment({
1144
1208
  engines: pkgEngines,
1209
+ // @ts-expect-error TS2322
1145
1210
  context,
1146
1211
  outputFormat: this.options.defaultTargetOptions.outputFormat,
1147
1212
  isLibrary: this.options.defaultTargetOptions.isLibrary,
@@ -1163,13 +1228,13 @@ export class TargetResolver {
1163
1228
  }
1164
1229
 
1165
1230
  inferOutputFormat(
1166
- distEntry: ?FilePath,
1231
+ distEntry: FilePath | null | undefined,
1167
1232
  descriptor: PackageTargetDescriptor,
1168
1233
  targetName: string,
1169
1234
  pkg: PackageJSON,
1170
- pkgFilePath: ?FilePath,
1171
- pkgContents: ?string,
1172
- ): [?OutputFormat, ?string] {
1235
+ pkgFilePath?: FilePath | null,
1236
+ pkgContents?: string | null,
1237
+ ): [OutputFormat | null | undefined, string | null | undefined] {
1173
1238
  // Infer the outputFormat based on package.json properties.
1174
1239
  // If the extension is .mjs it's always a module.
1175
1240
  // If the extension is .cjs, it's always commonjs.
@@ -1201,8 +1266,7 @@ export class TargetResolver {
1201
1266
  let contents: string =
1202
1267
  typeof pkgContents === 'string'
1203
1268
  ? pkgContents
1204
- : // $FlowFixMe
1205
- JSON.stringify(pkgContents, null, '\t');
1269
+ : JSON.stringify(pkgContents, null, '\t');
1206
1270
  let expectedExtensions;
1207
1271
  switch (descriptor.outputFormat) {
1208
1272
  case 'esmodule':
@@ -1215,7 +1279,6 @@ export class TargetResolver {
1215
1279
  expectedExtensions = ['.js'];
1216
1280
  break;
1217
1281
  }
1218
- // $FlowFixMe
1219
1282
  let listFormat = new Intl.ListFormat('en-US', {type: 'disjunction'});
1220
1283
  throw new ThrowableDiagnostic({
1221
1284
  diagnostic: {
@@ -1253,14 +1316,15 @@ export class TargetResolver {
1253
1316
  });
1254
1317
  }
1255
1318
 
1319
+ // @ts-expect-error TS2322
1256
1320
  return [inferredOutputFormat, inferredOutputFormatField];
1257
1321
  }
1258
1322
  }
1259
1323
 
1260
1324
  function parseEngines(
1261
- engines: mixed,
1262
- pkgPath: ?FilePath,
1263
- pkgContents: ?string,
1325
+ engines: unknown,
1326
+ pkgPath: FilePath | null | undefined,
1327
+ pkgContents: string | null | undefined,
1264
1328
  prependKey: string,
1265
1329
  message: string,
1266
1330
  ): Engines | typeof undefined {
@@ -1273,16 +1337,16 @@ function parseEngines(
1273
1337
  '@atlaspack/core',
1274
1338
  message,
1275
1339
  );
1276
- // $FlowFixMe we just verified this
1340
+ // @ts-expect-error TS2322
1277
1341
  return engines;
1278
1342
  }
1279
1343
  }
1280
1344
 
1281
1345
  function parseDescriptor(
1282
1346
  targetName: string,
1283
- descriptor: mixed,
1284
- pkgPath: ?FilePath,
1285
- pkgContents: ?string,
1347
+ descriptor: unknown,
1348
+ pkgPath?: FilePath | null,
1349
+ pkgContents?: string | null,
1286
1350
  ): TargetDescriptor {
1287
1351
  validateSchema.diagnostic(
1288
1352
  DESCRIPTOR_SCHEMA,
@@ -1296,15 +1360,15 @@ function parseDescriptor(
1296
1360
  `Invalid target descriptor for target "${targetName}"`,
1297
1361
  );
1298
1362
 
1299
- // $FlowFixMe we just verified this
1363
+ // @ts-expect-error TS2322
1300
1364
  return descriptor;
1301
1365
  }
1302
1366
 
1303
1367
  function parsePackageDescriptor(
1304
1368
  targetName: string,
1305
- descriptor: mixed,
1306
- pkgPath: ?FilePath,
1307
- pkgContents: ?string,
1369
+ descriptor: unknown,
1370
+ pkgPath?: FilePath | null,
1371
+ pkgContents?: string | null,
1308
1372
  ): PackageTargetDescriptor {
1309
1373
  validateSchema.diagnostic(
1310
1374
  PACKAGE_DESCRIPTOR_SCHEMA,
@@ -1317,15 +1381,15 @@ function parsePackageDescriptor(
1317
1381
  '@atlaspack/core',
1318
1382
  `Invalid target descriptor for target "${targetName}"`,
1319
1383
  );
1320
- // $FlowFixMe we just verified this
1384
+ // @ts-expect-error TS2322
1321
1385
  return descriptor;
1322
1386
  }
1323
1387
 
1324
1388
  function parseCommonTargetDescriptor(
1325
1389
  targetName: string,
1326
- descriptor: mixed,
1327
- pkgPath: ?FilePath,
1328
- pkgContents: ?string,
1390
+ descriptor: unknown,
1391
+ pkgPath?: FilePath | null,
1392
+ pkgContents?: string | null,
1329
1393
  ): PackageTargetDescriptor {
1330
1394
  validateSchema.diagnostic(
1331
1395
  COMMON_TARGET_DESCRIPTOR_SCHEMA,
@@ -1339,11 +1403,16 @@ function parseCommonTargetDescriptor(
1339
1403
  `Invalid target descriptor for target "${targetName}"`,
1340
1404
  );
1341
1405
 
1342
- // $FlowFixMe we just verified this
1406
+ // @ts-expect-error TS2322
1343
1407
  return descriptor;
1344
1408
  }
1345
1409
 
1346
- function assertNoDuplicateTargets(options, targets, pkgFilePath, pkgContents) {
1410
+ function assertNoDuplicateTargets(
1411
+ options: AtlaspackOptions,
1412
+ targets: Map<string, Target | null>,
1413
+ pkgFilePath: FilePath | null | undefined,
1414
+ pkgContents: undefined | string,
1415
+ ) {
1347
1416
  // Detect duplicate targets by destination path and provide a nice error.
1348
1417
  // Without this, an assertion is thrown much later after naming the bundles and finding duplicates.
1349
1418
  let targetsByPath: Map<string, Array<string>> = new Map();
@@ -1404,7 +1473,11 @@ function assertNoDuplicateTargets(options, targets, pkgFilePath, pkgContents) {
1404
1473
  }
1405
1474
  }
1406
1475
 
1407
- function normalizeSourceMap(options: AtlaspackOptions, sourceMap) {
1476
+ function normalizeSourceMap(
1477
+ options: AtlaspackOptions,
1478
+ // @ts-expect-error TS2304
1479
+ sourceMap: undefined | TargetSourceMapOptions | boolean,
1480
+ ) {
1408
1481
  if (options.defaultTargetOptions.sourceMaps) {
1409
1482
  if (typeof sourceMap === 'boolean') {
1410
1483
  return sourceMap ? {} : undefined;
@@ -1431,7 +1504,8 @@ function assertTargetsAreNotEntries(
1431
1504
  process.cwd(),
1432
1505
  fromProjectPath(options.projectRoot, input.filePath),
1433
1506
  );
1434
- let codeFrames = [];
1507
+ // @ts-expect-error TS2304
1508
+ let codeFrames: Array<DiagnosticCodeFrame> = [];
1435
1509
  if (loc) {
1436
1510
  codeFrames.push({
1437
1511
  filePath: fromProjectPath(options.projectRoot, loc.filePath),
@@ -1464,6 +1538,7 @@ function assertTargetsAreNotEntries(
1464
1538
  message: `Target "${target.name}" is configured to overwrite entry "${relativeEntry}".`,
1465
1539
  codeFrames,
1466
1540
  hints: [
1541
+ // @ts-expect-error TS7053
1467
1542
  (COMMON_TARGETS[target.name]
1468
1543
  ? `The "${target.name}" field is an _output_ file path so that your build can be consumed by other tools. `
1469
1544
  : '') +
@@ -1476,7 +1551,12 @@ function assertTargetsAreNotEntries(
1476
1551
  }
1477
1552
  }
1478
1553
 
1479
- async function debugResolvedTargets(input, targets, targetInfo, options) {
1554
+ async function debugResolvedTargets(
1555
+ input: Entry,
1556
+ targets: TargetRequestResult,
1557
+ targetInfo: Map<string, TargetInfo>,
1558
+ options: AtlaspackOptions,
1559
+ ) {
1480
1560
  for (let target of targets) {
1481
1561
  let info = targetInfo.get(target.name);
1482
1562
  let loc = target.loc;
@@ -1491,25 +1571,27 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1491
1571
 
1492
1572
  // Resolve relevant engines for context.
1493
1573
  let engines;
1494
- switch (target.env.context) {
1574
+ const env = fromEnvironmentId(target.env);
1575
+ switch (env.context) {
1495
1576
  case 'browser':
1496
1577
  case 'web-worker':
1497
1578
  case 'service-worker':
1498
1579
  case 'worklet': {
1499
- let browsers = target.env.engines.browsers;
1580
+ let browsers = env.engines.browsers;
1500
1581
  engines = Array.isArray(browsers) ? browsers.join(', ') : browsers;
1501
1582
  break;
1502
1583
  }
1503
1584
  case 'node':
1504
- engines = target.env.engines.node;
1585
+ engines = env.engines.node;
1505
1586
  break;
1506
1587
  case 'electron-main':
1507
1588
  case 'electron-renderer':
1508
- engines = target.env.engines.electron;
1589
+ engines = env.engines.electron;
1509
1590
  break;
1510
1591
  }
1511
1592
 
1512
- let highlights = [];
1593
+ // @ts-expect-error TS2304
1594
+ let highlights: Array<DiagnosticCodeHighlight> = [];
1513
1595
  if (input.loc) {
1514
1596
  highlights.push(
1515
1597
  convertSourceLocationToHighlight(input.loc, 'entry defined here'),
@@ -1523,6 +1605,7 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1523
1605
  // Builds up map of code highlights for each defined/inferred path in the package.json.
1524
1606
  let jsonHighlights = new Map();
1525
1607
  for (let key in info) {
1608
+ // @ts-expect-error TS7053
1526
1609
  let keyInfo = info[key];
1527
1610
  let path = keyInfo.path || keyInfo.inferred;
1528
1611
  if (!path) {
@@ -1547,29 +1630,29 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1547
1630
  }
1548
1631
 
1549
1632
  if (keyInfo.inferred) {
1550
- highlight.inferred.push(
1551
- md`${key} to be ${JSON.stringify(target.env[key])}`,
1552
- );
1633
+ // @ts-expect-error TS2345
1634
+ highlight.inferred.push(md`${key} to be ${JSON.stringify(env[key])}`);
1553
1635
  }
1554
1636
  }
1555
1637
 
1556
- // $FlowFixMe
1557
1638
  let listFormat = new Intl.ListFormat('en-US');
1558
1639
 
1559
1640
  // Generate human friendly messages for each field.
1560
- let highlightsWithMessages = [...jsonHighlights].map(([k, v]) => {
1561
- let message = v.defined;
1562
- if (v.inferred.length > 0) {
1563
- message += (message ? ', ' : '') + 'caused ';
1564
- message += listFormat.format(v.inferred);
1565
- }
1641
+ let highlightsWithMessages = [...jsonHighlights].map(
1642
+ ([k, v]: [any, any]) => {
1643
+ let message = v.defined;
1644
+ if (v.inferred.length > 0) {
1645
+ message += (message ? ', ' : '') + 'caused ';
1646
+ message += listFormat.format(v.inferred);
1647
+ }
1566
1648
 
1567
- return {
1568
- key: k,
1569
- type: v.type,
1570
- message,
1571
- };
1572
- });
1649
+ return {
1650
+ key: k,
1651
+ type: v.type,
1652
+ message,
1653
+ };
1654
+ },
1655
+ );
1573
1656
 
1574
1657
  // Get code highlights from JSON paths.
1575
1658
  highlights.push(
@@ -1578,28 +1661,29 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1578
1661
 
1579
1662
  // Format includeNodeModules to be human readable.
1580
1663
  let includeNodeModules;
1581
- if (typeof target.env.includeNodeModules === 'boolean') {
1582
- includeNodeModules = String(target.env.includeNodeModules);
1583
- } else if (Array.isArray(target.env.includeNodeModules)) {
1664
+ if (typeof env.includeNodeModules === 'boolean') {
1665
+ includeNodeModules = String(env.includeNodeModules);
1666
+ } else if (Array.isArray(env.includeNodeModules)) {
1584
1667
  includeNodeModules =
1585
1668
  'only ' +
1586
- listFormat.format(
1587
- target.env.includeNodeModules.map((m) => JSON.stringify(m)),
1588
- );
1669
+ listFormat.format(env.includeNodeModules.map((m) => JSON.stringify(m)));
1589
1670
  } else if (
1590
- target.env.includeNodeModules &&
1591
- typeof target.env.includeNodeModules === 'object'
1671
+ env.includeNodeModules &&
1672
+ typeof env.includeNodeModules === 'object'
1592
1673
  ) {
1593
1674
  includeNodeModules =
1594
1675
  'all except ' +
1595
1676
  listFormat.format(
1596
- Object.entries(target.env.includeNodeModules)
1597
- .filter(([, v]) => v === false)
1598
- .map(([k]) => JSON.stringify(k)),
1677
+ Object.entries(env.includeNodeModules)
1678
+ .filter(([, v]: [any, any]) => v === false)
1679
+ // @ts-expect-error TS2345
1680
+ .map(([k]: [any]) => JSON.stringify(k)),
1599
1681
  );
1600
1682
  }
1601
1683
 
1602
- let format = (v) => (v.message != null ? md.italic(v.message) : '');
1684
+ let format = (v: TargetKeyInfo) =>
1685
+ // @ts-expect-error TS2339
1686
+ v.message != null ? md.italic(v.message) : '';
1603
1687
  logger.verbose({
1604
1688
  origin: '@atlaspack/core',
1605
1689
  message: md`**Target** "${target.name}"
@@ -1609,20 +1693,16 @@ async function debugResolvedTargets(input, targets, targetInfo, options) {
1609
1693
  fromProjectPath(options.projectRoot, input.filePath),
1610
1694
  )}
1611
1695
  **Output**: ${path.relative(process.cwd(), output)}
1612
- **Format**: ${target.env.outputFormat} ${format(
1613
- info.outputFormat,
1614
- )}
1615
- **Context**: ${target.env.context} ${format(info.context)}
1696
+ **Format**: ${env.outputFormat} ${format(info.outputFormat)}
1697
+ **Context**: ${env.context} ${format(info.context)}
1616
1698
  **Engines**: ${engines || ''} ${format(info.engines)}
1617
- **Library Mode**: ${String(target.env.isLibrary)} ${format(
1618
- info.isLibrary,
1619
- )}
1699
+ **Library Mode**: ${String(env.isLibrary)} ${format(info.isLibrary)}
1620
1700
  **Include Node Modules**: ${includeNodeModules} ${format(
1621
1701
  info.includeNodeModules,
1622
1702
  )}
1623
- **Optimize**: ${String(target.env.shouldOptimize)} ${format(
1624
- info.shouldOptimize,
1625
- )}`,
1703
+ **Optimize**: ${String(env.shouldOptimize)} ${format(
1704
+ info.shouldOptimize,
1705
+ )}`,
1626
1706
  codeFrames: target.loc
1627
1707
  ? [
1628
1708
  {