@atlaspack/core 2.16.2-canary.48 → 2.16.2-canary.481

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