@atlaspack/core 2.16.2-canary.137 → 2.16.2-canary.139

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 (266) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/lib/AssetGraph.d.ts +80 -0
  3. package/lib/AssetGraph.js +25 -10
  4. package/lib/Atlaspack.d.ts +52 -0
  5. package/lib/Atlaspack.js +47 -7
  6. package/lib/AtlaspackConfig.d.ts +65 -0
  7. package/lib/AtlaspackConfig.js +24 -6
  8. package/lib/AtlaspackConfig.schema.d.ts +46 -0
  9. package/lib/AtlaspackConfig.schema.js +0 -4
  10. package/lib/BundleGraph.d.ts +182 -0
  11. package/lib/BundleGraph.js +78 -17
  12. package/lib/CommittedAsset.d.ts +23 -0
  13. package/lib/CommittedAsset.js +6 -0
  14. package/lib/Dependency.d.ts +44 -0
  15. package/lib/Dependency.js +2 -0
  16. package/lib/Environment.d.ts +10 -0
  17. package/lib/Environment.js +2 -2
  18. package/lib/EnvironmentManager.d.ts +37 -0
  19. package/lib/EnvironmentManager.js +6 -0
  20. package/lib/IdentifierRegistry.d.ts +6 -0
  21. package/lib/IdentifierRegistry.js +1 -3
  22. package/lib/InternalConfig.d.ts +24 -0
  23. package/lib/PackagerRunner.d.ts +80 -0
  24. package/lib/PackagerRunner.js +10 -5
  25. package/lib/ReporterRunner.d.ts +25 -0
  26. package/lib/ReporterRunner.js +6 -9
  27. package/lib/RequestTracker.d.ts +385 -0
  28. package/lib/RequestTracker.js +28 -11
  29. package/lib/SymbolPropagation.d.ts +11 -0
  30. package/lib/SymbolPropagation.js +52 -7
  31. package/lib/TargetDescriptor.schema.d.ts +5 -0
  32. package/lib/Transformation.d.ts +72 -0
  33. package/lib/Transformation.js +15 -7
  34. package/lib/UncommittedAsset.d.ts +61 -0
  35. package/lib/UncommittedAsset.js +10 -7
  36. package/lib/Validation.d.ts +37 -0
  37. package/lib/Validation.js +18 -2
  38. package/lib/applyRuntimes.d.ts +25 -0
  39. package/lib/applyRuntimes.js +5 -0
  40. package/lib/assetUtils.d.ts +42 -0
  41. package/lib/assetUtils.js +5 -3
  42. package/lib/atlaspack-v3/AtlaspackV3.d.ts +26 -0
  43. package/lib/atlaspack-v3/AtlaspackV3.js +10 -2
  44. package/lib/atlaspack-v3/NapiWorkerPool.d.ts +12 -0
  45. package/lib/atlaspack-v3/NapiWorkerPool.js +3 -0
  46. package/lib/atlaspack-v3/fs.d.ts +12 -0
  47. package/lib/atlaspack-v3/fs.js +3 -1
  48. package/lib/atlaspack-v3/index.d.ts +5 -0
  49. package/lib/atlaspack-v3/index.js +28 -1
  50. package/lib/atlaspack-v3/jsCallable.d.ts +1 -0
  51. package/lib/atlaspack-v3/jsCallable.js +0 -2
  52. package/lib/atlaspack-v3/worker/compat/asset-symbols.d.ts +51 -0
  53. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +5 -3
  54. package/lib/atlaspack-v3/worker/compat/bitflags.d.ts +15 -0
  55. package/lib/atlaspack-v3/worker/compat/bitflags.js +5 -5
  56. package/lib/atlaspack-v3/worker/compat/dependency.d.ts +25 -0
  57. package/lib/atlaspack-v3/worker/compat/dependency.js +3 -0
  58. package/lib/atlaspack-v3/worker/compat/environment.d.ts +25 -0
  59. package/lib/atlaspack-v3/worker/compat/environment.js +2 -3
  60. package/{src/atlaspack-v3/worker/compat/index.js → lib/atlaspack-v3/worker/compat/index.d.ts} +0 -1
  61. package/lib/atlaspack-v3/worker/compat/mutable-asset.d.ts +49 -0
  62. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +8 -3
  63. package/lib/atlaspack-v3/worker/compat/plugin-config.d.ts +37 -0
  64. package/lib/atlaspack-v3/worker/compat/plugin-config.js +3 -5
  65. package/lib/atlaspack-v3/worker/compat/plugin-logger.d.ts +9 -0
  66. package/lib/atlaspack-v3/worker/compat/plugin-options.d.ts +22 -0
  67. package/lib/atlaspack-v3/worker/compat/plugin-options.js +1 -0
  68. package/lib/atlaspack-v3/worker/compat/plugin-tracer.d.ts +5 -0
  69. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
  70. package/lib/atlaspack-v3/worker/compat/target.d.ts +11 -0
  71. package/lib/atlaspack-v3/worker/compat/target.js +2 -0
  72. package/lib/atlaspack-v3/worker/worker.d.ts +58 -0
  73. package/lib/atlaspack-v3/worker/worker.js +18 -5
  74. package/lib/constants.d.ts +13 -0
  75. package/lib/constants.js +0 -1
  76. package/lib/dumpGraphToGraphViz.d.ts +10 -0
  77. package/lib/dumpGraphToGraphViz.js +70 -15
  78. package/lib/index.d.ts +8 -0
  79. package/lib/index.js +17 -1
  80. package/lib/loadAtlaspackPlugin.d.ts +8 -0
  81. package/lib/loadAtlaspackPlugin.js +3 -0
  82. package/lib/loadDotEnv.d.ts +3 -0
  83. package/lib/loadDotEnv.js +4 -1
  84. package/lib/projectPath.d.ts +19 -0
  85. package/lib/projectPath.js +5 -0
  86. package/lib/public/Asset.d.ts +74 -0
  87. package/lib/public/Asset.js +14 -2
  88. package/lib/public/Bundle.d.ts +45 -0
  89. package/lib/public/Bundle.js +3 -3
  90. package/lib/public/BundleGraph.d.ts +70 -0
  91. package/lib/public/BundleGraph.js +7 -2
  92. package/lib/public/BundleGroup.d.ts +12 -0
  93. package/lib/public/BundleGroup.js +2 -2
  94. package/lib/public/Config.d.ts +75 -0
  95. package/lib/public/Config.js +27 -13
  96. package/lib/public/Dependency.d.ts +32 -0
  97. package/lib/public/Dependency.js +4 -2
  98. package/lib/public/Environment.d.ts +32 -0
  99. package/lib/public/Environment.js +2 -2
  100. package/lib/public/MutableBundleGraph.d.ts +26 -0
  101. package/lib/public/MutableBundleGraph.js +29 -6
  102. package/lib/public/PluginOptions.d.ts +25 -0
  103. package/lib/public/PluginOptions.js +1 -0
  104. package/lib/public/Symbols.d.ts +81 -0
  105. package/lib/public/Symbols.js +63 -14
  106. package/lib/public/Target.d.ts +16 -0
  107. package/lib/public/Target.js +3 -2
  108. package/lib/registerCoreWithSerializer.d.ts +2 -0
  109. package/lib/registerCoreWithSerializer.js +5 -3
  110. package/lib/requests/AssetGraphRequest.d.ts +74 -0
  111. package/lib/requests/AssetGraphRequest.js +15 -3
  112. package/lib/requests/AssetGraphRequestRust.d.ts +21 -0
  113. package/lib/requests/AssetGraphRequestRust.js +7 -4
  114. package/lib/requests/AssetRequest.d.ts +16 -0
  115. package/lib/requests/AssetRequest.js +21 -5
  116. package/lib/requests/AtlaspackBuildRequest.d.ts +29 -0
  117. package/lib/requests/AtlaspackBuildRequest.js +6 -2
  118. package/lib/requests/AtlaspackConfigRequest.d.ts +45 -0
  119. package/lib/requests/AtlaspackConfigRequest.js +15 -11
  120. package/lib/requests/BundleGraphRequest.d.ts +28 -0
  121. package/lib/requests/BundleGraphRequest.js +6 -6
  122. package/lib/requests/ConfigRequest.d.ts +59 -0
  123. package/lib/requests/ConfigRequest.js +1 -0
  124. package/lib/requests/DevDepRequest.d.ts +30 -0
  125. package/lib/requests/DevDepRequest.js +20 -4
  126. package/lib/requests/EntryRequest.d.ts +36 -0
  127. package/lib/requests/EntryRequest.js +9 -0
  128. package/lib/requests/PackageRequest.d.ts +27 -0
  129. package/lib/requests/PackageRequest.js +7 -2
  130. package/lib/requests/PathRequest.d.ts +48 -0
  131. package/lib/requests/PathRequest.js +20 -5
  132. package/lib/requests/TargetRequest.d.ts +48 -0
  133. package/lib/requests/TargetRequest.js +72 -40
  134. package/lib/requests/ValidationRequest.d.ts +20 -0
  135. package/lib/requests/ValidationRequest.js +5 -1
  136. package/lib/requests/WriteBundleRequest.d.ts +28 -0
  137. package/lib/requests/WriteBundleRequest.js +24 -8
  138. package/lib/requests/WriteBundlesRequest.d.ts +26 -0
  139. package/lib/requests/WriteBundlesRequest.js +26 -6
  140. package/lib/requests/asset-graph-diff.d.ts +1 -0
  141. package/lib/requests/asset-graph-diff.js +8 -3
  142. package/lib/requests/asset-graph-dot.d.ts +9 -0
  143. package/lib/requests/asset-graph-dot.js +1 -7
  144. package/lib/resolveOptions.d.ts +3 -0
  145. package/lib/rustWorkerThreadDylibHack.d.ts +9 -0
  146. package/lib/rustWorkerThreadDylibHack.js +0 -1
  147. package/lib/serializerCore.browser.d.ts +3 -0
  148. package/lib/summarizeRequest.d.ts +10 -0
  149. package/lib/types.d.ts +490 -0
  150. package/lib/types.js +6 -0
  151. package/lib/utils.d.ts +23 -0
  152. package/lib/utils.js +17 -2
  153. package/lib/worker.d.ts +44 -0
  154. package/lib/worker.js +12 -6
  155. package/package.json +23 -22
  156. package/src/{AssetGraph.js → AssetGraph.ts} +53 -47
  157. package/src/{Atlaspack.js → Atlaspack.ts} +75 -38
  158. package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +16 -19
  159. package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +81 -54
  160. package/src/{BundleGraph.js → BundleGraph.ts} +189 -121
  161. package/src/{CommittedAsset.js → CommittedAsset.ts} +14 -12
  162. package/src/{Dependency.js → Dependency.ts} +48 -39
  163. package/src/{Environment.js → Environment.ts} +8 -9
  164. package/src/{EnvironmentManager.js → EnvironmentManager.ts} +14 -5
  165. package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
  166. package/src/{InternalConfig.js → InternalConfig.ts} +18 -20
  167. package/src/{PackagerRunner.js → PackagerRunner.ts} +67 -59
  168. package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
  169. package/src/{RequestTracker.js → RequestTracker.ts} +255 -206
  170. package/src/{SymbolPropagation.js → SymbolPropagation.ts} +157 -44
  171. package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +0 -1
  172. package/src/{Transformation.js → Transformation.ts} +67 -61
  173. package/src/{UncommittedAsset.js → UncommittedAsset.ts} +34 -33
  174. package/src/{Validation.js → Validation.ts} +32 -17
  175. package/src/{applyRuntimes.js → applyRuntimes.ts} +27 -25
  176. package/src/{assetUtils.js → assetUtils.ts} +44 -33
  177. package/src/atlaspack-v3/{AtlaspackV3.js → AtlaspackV3.ts} +20 -15
  178. package/src/atlaspack-v3/{NapiWorkerPool.js → NapiWorkerPool.ts} +10 -5
  179. package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
  180. package/src/atlaspack-v3/{index.js → index.ts} +2 -4
  181. package/src/atlaspack-v3/jsCallable.ts +14 -0
  182. package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +52 -49
  183. package/src/atlaspack-v3/worker/compat/{bitflags.js → bitflags.ts} +8 -10
  184. package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +12 -12
  185. package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +4 -8
  186. package/src/atlaspack-v3/worker/compat/index.ts +9 -0
  187. package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +20 -19
  188. package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +26 -29
  189. package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
  190. package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +4 -5
  191. package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
  192. package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
  193. package/src/atlaspack-v3/worker/{worker.js → worker.ts} +78 -64
  194. package/src/{constants.js → constants.ts} +0 -3
  195. package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
  196. package/src/{index.js → index.ts} +2 -1
  197. package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +11 -9
  198. package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
  199. package/src/{projectPath.js → projectPath.ts} +20 -9
  200. package/src/public/{Asset.js → Asset.ts} +29 -23
  201. package/src/public/{Bundle.js → Bundle.ts} +17 -19
  202. package/src/public/{BundleGraph.js → BundleGraph.ts} +71 -48
  203. package/src/public/{BundleGroup.js → BundleGroup.ts} +5 -8
  204. package/src/public/{Config.js → Config.ts} +63 -39
  205. package/src/public/{Dependency.js → Dependency.ts} +16 -14
  206. package/src/public/{Environment.js → Environment.ts} +11 -14
  207. package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +37 -21
  208. package/src/public/{PluginOptions.js → PluginOptions.ts} +5 -5
  209. package/src/public/{Symbols.js → Symbols.ts} +109 -36
  210. package/src/public/{Target.js → Target.ts} +6 -5
  211. package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +9 -7
  212. package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +51 -45
  213. package/src/requests/{AssetGraphRequestRust.js → AssetGraphRequestRust.ts} +18 -19
  214. package/src/requests/{AssetRequest.js → AssetRequest.ts} +22 -17
  215. package/src/requests/{AtlaspackBuildRequest.js → AtlaspackBuildRequest.ts} +30 -31
  216. package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +61 -51
  217. package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +38 -41
  218. package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +40 -43
  219. package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +42 -30
  220. package/src/requests/{EntryRequest.js → EntryRequest.ts} +43 -31
  221. package/src/requests/{PackageRequest.js → PackageRequest.ts} +21 -21
  222. package/src/requests/{PathRequest.js → PathRequest.ts} +45 -37
  223. package/src/requests/{TargetRequest.js → TargetRequest.ts} +196 -153
  224. package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
  225. package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +63 -41
  226. package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +38 -27
  227. package/src/requests/{asset-graph-diff.js → asset-graph-diff.ts} +14 -14
  228. package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
  229. package/src/{resolveOptions.js → resolveOptions.ts} +6 -8
  230. package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
  231. package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
  232. package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
  233. package/src/types.ts +644 -0
  234. package/src/{utils.js → utils.ts} +52 -21
  235. package/src/{worker.js → worker.ts} +51 -35
  236. package/test/{AssetGraph.test.js → AssetGraph.test.ts} +4 -8
  237. package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
  238. package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
  239. package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +3 -15
  240. package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
  241. package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
  242. package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
  243. package/test/{Environment.test.js → Environment.test.ts} +2 -5
  244. package/test/{EnvironmentManager.test.js → EnvironmentManager.test.ts} +7 -9
  245. package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
  246. package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
  247. package/test/PackagerRunner.test.ts +0 -0
  248. package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
  249. package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
  250. package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
  251. package/test/{PublicEnvironment.test.js → PublicEnvironment.test.ts} +0 -2
  252. package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
  253. package/test/{RequestTracker.test.js → RequestTracker.test.ts} +26 -36
  254. package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
  255. package/test/{TargetRequest.test.js → TargetRequest.test.ts} +3 -17
  256. package/test/public/{Config.test.js → Config.test.ts} +7 -11
  257. package/test/requests/{AssetGraphRequestRust.test.js → AssetGraphRequestRust.test.ts} +0 -1
  258. package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +19 -22
  259. package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
  260. package/test/{test-utils.js → test-utils.ts} +0 -2
  261. package/test/{utils.test.js → utils.test.ts} +1 -3
  262. package/tsconfig.json +4 -0
  263. package/index.d.ts +0 -34
  264. package/src/atlaspack-v3/jsCallable.js +0 -18
  265. package/src/types.js +0 -603
  266. package/test/PackagerRunner.test.js +0 -27
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # @atlaspack/core
2
2
 
3
+ ## 2.20.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#721](https://github.com/atlassian-labs/atlaspack/pull/721) [`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd) Thanks [@benjervis](https://github.com/benjervis)! - Add support for bundle merging based on `webpackChunkName` comments.
8
+
9
+ Adding a `webpackChunkName` comment to an import will allow the bundler to merge multiple imports into a single bundle.
10
+
11
+ e.g.:
12
+
13
+ ```ts
14
+ import(/* webpackChunkName: "my-chunk" */ './my-module');
15
+ import(/* webpackChunkName: "my-chunk" */ './another-module');
16
+ ```
17
+
18
+ This can be enabled with the feature flag `supportWebpackChunkName`.
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
23
+ - @atlaspack/feature-flags@2.20.0
24
+ - @atlaspack/fs@2.15.16
25
+ - @atlaspack/profiler@2.14.18
26
+ - @atlaspack/types@2.15.11
27
+ - @atlaspack/workers@2.14.21
28
+ - @atlaspack/cache@3.2.16
29
+ - @atlaspack/graph@3.5.10
30
+ - @atlaspack/utils@2.17.3
31
+ - @atlaspack/package-manager@2.14.21
32
+ - @atlaspack/plugin@2.14.21
33
+
3
34
  ## 2.19.2
4
35
 
5
36
  ### Patch Changes
@@ -0,0 +1,80 @@
1
+ import type { GraphVisitor } from '@atlaspack/types';
2
+ import type { ContentGraphOpts, ContentKey, NodeId, SerializedContentGraph } from '@atlaspack/graph';
3
+ import type { Asset, AssetGraphNode, AssetGroup, AssetGroupNode, AssetNode, Dependency, DependencyNode, Entry, EntryFileNode, EntrySpecifierNode, Environment, Target } from './types';
4
+ import { ContentGraph } from '@atlaspack/graph';
5
+ import { ProjectPath } from './projectPath';
6
+ type InitOpts = {
7
+ entries?: Array<ProjectPath>;
8
+ targets?: Array<Target>;
9
+ assetGroups?: Array<AssetGroup>;
10
+ };
11
+ type AssetGraphOpts = ContentGraphOpts<AssetGraphNode> & {
12
+ bundlingVersion?: number;
13
+ disableIncrementalBundling?: boolean;
14
+ hash?: string | null | undefined;
15
+ };
16
+ type SerializedAssetGraph = SerializedContentGraph<AssetGraphNode> & {
17
+ bundlingVersion: number;
18
+ disableIncrementalBundling: boolean;
19
+ hash?: string | null | undefined;
20
+ };
21
+ export declare function nodeFromDep(dep: Dependency): DependencyNode;
22
+ export declare function nodeFromAssetGroup(assetGroup: AssetGroup): AssetGroupNode;
23
+ export declare function nodeFromAsset(asset: Asset): AssetNode;
24
+ export declare function nodeFromEntrySpecifier(entry: ProjectPath): EntrySpecifierNode;
25
+ export declare function nodeFromEntryFile(entry: Entry): EntryFileNode;
26
+ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
27
+ #private;
28
+ onNodeRemoved: ((nodeId: NodeId) => unknown) | null | undefined;
29
+ hash: string | null | undefined;
30
+ envCache: Map<string, Environment>;
31
+ /**
32
+ * @deprecated
33
+ */
34
+ safeToIncrementallyBundle: boolean;
35
+ undeferredDependencies: Set<Dependency>;
36
+ constructor(opts?: AssetGraphOpts | null);
37
+ static deserialize(opts: AssetGraphOpts): AssetGraph;
38
+ serialize(): SerializedAssetGraph;
39
+ /**
40
+ * Force incremental bundling to be disabled.
41
+ */
42
+ setDisableIncrementalBundling(disable: boolean): void;
43
+ testing_getDisableIncrementalBundling(): boolean;
44
+ /**
45
+ * Make sure this asset graph is marked as needing a full bundling pass.
46
+ */
47
+ setNeedsBundling(): void;
48
+ /**
49
+ * Get the current bundling version.
50
+ *
51
+ * Each bundle pass should keep this version around. Whenever an asset graph has a new version,
52
+ * bundling should be re-run.
53
+ */
54
+ getBundlingVersion(): number;
55
+ /**
56
+ * If the `bundlingVersion` has not changed since the last bundling pass,
57
+ * we can incrementally bundle, which will not require a full bundling pass
58
+ * but just update assets into the bundle graph output.
59
+ */
60
+ canIncrementallyBundle(lastVersion: number): boolean;
61
+ normalizeEnvironment(input: Asset | Dependency | AssetGroup): void;
62
+ setRootConnections({ entries, assetGroups }: InitOpts): void;
63
+ addNode(node: AssetGraphNode): NodeId;
64
+ removeNode(nodeId: NodeId): void;
65
+ resolveEntry(entry: ProjectPath, resolved: Array<Entry>, correspondingRequest: ContentKey): void;
66
+ resolveTargets(entry: Entry, targets: Array<Target>, correspondingRequest: string): void;
67
+ resolveDependency(dependency: Dependency, assetGroup: AssetGroup | null | undefined, correspondingRequest: string): void;
68
+ shouldVisitChild(nodeId: NodeId, childNodeId: NodeId): boolean;
69
+ markParentsWithHasDeferred(nodeId: NodeId): void;
70
+ unmarkParentsWithHasDeferred(nodeId: NodeId): void;
71
+ shouldDeferDependency(dependency: Dependency, sideEffects: boolean | null | undefined, canDefer: boolean): boolean;
72
+ resolveAssetGroup(assetGroup: AssetGroup, assets: Array<Asset>, correspondingRequest: ContentKey): void;
73
+ resolveAsset(assetNode: AssetNode, dependentAssets: Array<Asset>): void;
74
+ getIncomingDependencies(asset: Asset): Array<Dependency>;
75
+ traverseAssets<TContext>(visit: GraphVisitor<Asset, TContext>, startNodeId?: NodeId | null): TContext | null | undefined;
76
+ getEntryAssetGroupNodes(): Array<AssetGroupNode>;
77
+ getEntryAssets(): Array<Asset>;
78
+ getHash(): string;
79
+ }
80
+ export {};
package/lib/AssetGraph.js CHANGED
@@ -71,7 +71,11 @@ function nodeFromDep(dep) {
71
71
  }
72
72
  function nodeFromAssetGroup(assetGroup) {
73
73
  return {
74
- id: (0, _rust().hashString)((0, _projectPath.fromProjectPathRelative)(assetGroup.filePath) + (0, _EnvironmentManager.toEnvironmentId)(assetGroup.env) + String(assetGroup.isSource) + String(assetGroup.sideEffects) + (assetGroup.code ?? '') + ':' + (assetGroup.pipeline ?? '') + ':' + (assetGroup.query ?? '')),
74
+ id: (0, _rust().hashString)(
75
+ // @ts-expect-error TS2345
76
+ (0, _projectPath.fromProjectPathRelative)(assetGroup.filePath) +
77
+ // @ts-expect-error TS2345
78
+ (0, _EnvironmentManager.toEnvironmentId)(assetGroup.env) + String(assetGroup.isSource) + String(assetGroup.sideEffects) + (assetGroup.code ?? '') + ':' + (assetGroup.pipeline ?? '') + ':' + (assetGroup.query ?? '')),
75
79
  type: 'asset_group',
76
80
  value: assetGroup,
77
81
  usedSymbolsDownDirty: true
@@ -101,6 +105,8 @@ function nodeFromEntryFile(entry) {
101
105
  value: entry
102
106
  };
103
107
  }
108
+
109
+ // @ts-expect-error TS2417
104
110
  class AssetGraph extends _graph().ContentGraph {
105
111
  /**
106
112
  * Incremented when the asset graph is modified such that it requires a bundling pass.
@@ -138,13 +144,9 @@ class AssetGraph extends _graph().ContentGraph {
138
144
  this.undeferredDependencies = new Set();
139
145
  this.envCache = new Map();
140
146
  }
141
-
142
- // $FlowFixMe[prop-missing]
143
147
  static deserialize(opts) {
144
148
  return new AssetGraph(opts);
145
149
  }
146
-
147
- // $FlowFixMe[prop-missing]
148
150
  serialize() {
149
151
  return {
150
152
  ...super.serialize(),
@@ -206,6 +208,8 @@ class AssetGraph extends _graph().ContentGraph {
206
208
  if ((0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
207
209
  return;
208
210
  }
211
+
212
+ // @ts-expect-error TS2345
209
213
  let {
210
214
  id,
211
215
  context
@@ -215,6 +219,7 @@ class AssetGraph extends _graph().ContentGraph {
215
219
  if (env) {
216
220
  input.env = (0, _EnvironmentManager.toEnvironmentRef)(env);
217
221
  } else {
222
+ // @ts-expect-error TS2345
218
223
  this.envCache.set(idAndContext, (0, _EnvironmentManager.fromEnvironmentId)(input.env));
219
224
  }
220
225
  }
@@ -242,8 +247,6 @@ class AssetGraph extends _graph().ContentGraph {
242
247
  let existing = this.getNodeByContentKey(node.id);
243
248
  if (existing != null) {
244
249
  (0, _assert().default)(existing.type === node.type);
245
- // $FlowFixMe[incompatible-type] Checked above
246
- // $FlowFixMe[prop-missing]
247
250
  existing.value = node.value;
248
251
  let existingId = this.getNodeIdByContentKey(node.id);
249
252
  this.updateNode(existingId, existing);
@@ -275,6 +278,7 @@ class AssetGraph extends _graph().ContentGraph {
275
278
  env: target.env,
276
279
  isEntry: true,
277
280
  needsStableName: true,
281
+ // @ts-expect-error TS2322
278
282
  symbols: (0, _EnvironmentManager.fromEnvironmentId)(target.env).isLibrary ? new Map([['*', {
279
283
  local: '*',
280
284
  isWeak: true,
@@ -283,7 +287,9 @@ class AssetGraph extends _graph().ContentGraph {
283
287
  }));
284
288
  if ((0, _EnvironmentManager.fromEnvironmentId)(node.value.env).isLibrary) {
285
289
  // in library mode, all of the entry's symbols are "used"
290
+ // @ts-expect-error TS2345
286
291
  node.usedSymbolsDown.add('*');
292
+ // @ts-expect-error TS2345
287
293
  node.usedSymbolsUp.set('*', undefined);
288
294
  }
289
295
  return node;
@@ -361,7 +367,10 @@ class AssetGraph extends _graph().ContentGraph {
361
367
  if (traversedNode.type === 'asset') {
362
368
  let hasDeferred = this.getNodeIdsConnectedFrom(traversedNodeId).some(childNodeId => {
363
369
  let childNode = (0, _nullthrows().default)(this.getNode(childNodeId));
364
- return childNode.hasDeferred == null ? false : childNode.hasDeferred;
370
+ // @ts-expect-error TS2339
371
+ return childNode.hasDeferred == null ? false :
372
+ // @ts-expect-error TS2339
373
+ childNode.hasDeferred;
365
374
  });
366
375
  if (!hasDeferred) {
367
376
  delete traversedNode.hasDeferred;
@@ -370,6 +379,7 @@ class AssetGraph extends _graph().ContentGraph {
370
379
  hasDeferred
371
380
  };
372
381
  } else if (traversedNode.type === 'asset_group' && nodeId !== traversedNodeId) {
382
+ // @ts-expect-error TS2339
373
383
  if (!(ctx !== null && ctx !== void 0 && ctx.hasDeferred)) {
374
384
  this.safeToIncrementallyBundle = false;
375
385
  this.setNeedsBundling();
@@ -400,7 +410,9 @@ class AssetGraph extends _graph().ContentGraph {
400
410
  }
401
411
  let isDeferrable = [...dependencySymbols].every(([, {
402
412
  isWeak
403
- }]) => isWeak) && sideEffects === false && canDefer && !dependencySymbols.has('*');
413
+ }]) => isWeak) && sideEffects === false && canDefer &&
414
+ // @ts-expect-error TS2345
415
+ !dependencySymbols.has('*');
404
416
  if (!isDeferrable) {
405
417
  return false;
406
418
  }
@@ -426,7 +438,9 @@ class AssetGraph extends _graph().ContentGraph {
426
438
  if (this.undeferredDependencies.has(d)) {
427
439
  return false;
428
440
  }
429
- let depIsDeferrable = d.symbols && !((0, _EnvironmentManager.fromEnvironmentId)(d.env).isLibrary && d.isEntry) && !d.symbols.has('*') && ![...d.symbols.keys()].some(symbol => {
441
+ let depIsDeferrable = d.symbols && !((0, _EnvironmentManager.fromEnvironmentId)(d.env).isLibrary && d.isEntry) &&
442
+ // @ts-expect-error TS2345
443
+ !d.symbols.has('*') && ![...d.symbols.keys()].some(symbol => {
430
444
  var _resolvedAsset$symbol;
431
445
  let assetSymbol = (_resolvedAsset$symbol = resolvedAsset.symbols) === null || _resolvedAsset$symbol === void 0 || (_resolvedAsset$symbol = _resolvedAsset$symbol.get(symbol)) === null || _resolvedAsset$symbol === void 0 ? void 0 : _resolvedAsset$symbol.local;
432
446
  return assetSymbol != null && symbols.has(assetSymbol);
@@ -441,6 +455,7 @@ class AssetGraph extends _graph().ContentGraph {
441
455
  resolveAssetGroup(assetGroup, assets, correspondingRequest) {
442
456
  this.normalizeEnvironment(assetGroup);
443
457
  let assetGroupNode = nodeFromAssetGroup(assetGroup);
458
+ // @ts-expect-error TS2322
444
459
  assetGroupNode = this.getNodeByContentKey(assetGroupNode.id);
445
460
  if (!assetGroupNode) {
446
461
  return;
@@ -0,0 +1,52 @@
1
+ import type { Asset, AsyncSubscription, BuildEvent, BuildSuccessEvent, InitialAtlaspackOptions, AtlaspackTransformOptions, AtlaspackResolveOptions, AtlaspackResolveResult } from '@atlaspack/types';
2
+ import type { AtlaspackOptions } from './types';
3
+ import type { FarmOptions } from '@atlaspack/workers';
4
+ import type { Diagnostic } from '@atlaspack/diagnostic';
5
+ import ThrowableDiagnostic from '@atlaspack/diagnostic';
6
+ import WorkerFarm from '@atlaspack/workers';
7
+ import { AtlaspackV3 } from './atlaspack-v3';
8
+ import type { AssetGraphRequestResult } from './requests/AssetGraphRequest';
9
+ export declare const INTERNAL_TRANSFORM: symbol;
10
+ export declare const INTERNAL_RESOLVE: symbol;
11
+ export declare let WORKER_PATH: string;
12
+ export default class Atlaspack {
13
+ #private;
14
+ rustAtlaspack: AtlaspackV3 | null | undefined;
15
+ isProfiling: boolean;
16
+ constructor(options: InitialAtlaspackOptions);
17
+ _init(): Promise<void>;
18
+ run(): Promise<BuildSuccessEvent>;
19
+ _end(): Promise<void>;
20
+ writeRequestTrackerToCache(): Promise<void>;
21
+ _startNextBuild(): Promise<BuildEvent | null | undefined>;
22
+ watch(cb?: (err?: Error | null | undefined, buildEvent?: BuildEvent) => unknown): Promise<AsyncSubscription>;
23
+ _build({ signal, startTime, }?: {
24
+ signal?: AbortSignal;
25
+ startTime?: number;
26
+ }): Promise<BuildEvent>;
27
+ _getWatcherSubscription(): Promise<AsyncSubscription>;
28
+ _getResolvedAtlaspackOptions(): AtlaspackOptions;
29
+ startProfiling(): Promise<void>;
30
+ stopProfiling(): Promise<void>;
31
+ takeHeapSnapshot(): Promise<void>;
32
+ /**
33
+ * Must be called between builds otherwise there is global state that will
34
+ * break things unexpectedly.
35
+ */
36
+ clearBuildCaches(): Promise<void>;
37
+ unstable_invalidate(): Promise<void>;
38
+ /**
39
+ * Build the asset graph
40
+ */
41
+ unstable_buildAssetGraph(writeToCache?: boolean): Promise<AssetGraphRequestResult>;
42
+ /**
43
+ * Copy the cache to a new directory and compact it.
44
+ */
45
+ unstable_compactCache(): Promise<void>;
46
+ unstable_transform(options: AtlaspackTransformOptions): Promise<Array<Asset>>;
47
+ unstable_resolve(request: AtlaspackResolveOptions): Promise<AtlaspackResolveResult | null | undefined>;
48
+ }
49
+ export declare class BuildError extends ThrowableDiagnostic {
50
+ constructor(diagnostic: Array<Diagnostic> | Diagnostic);
51
+ }
52
+ export declare function createWorkerFarm(options?: Partial<FarmOptions>): WorkerFarm;
package/lib/Atlaspack.js CHANGED
@@ -123,28 +123,43 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
123
123
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
124
124
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
125
125
  // eslint-disable-next-line no-unused-vars
126
+
126
127
  (0, _registerCoreWithSerializer.registerCoreWithSerializer)();
127
128
  const INTERNAL_TRANSFORM = exports.INTERNAL_TRANSFORM = Symbol('internal_transform');
128
129
  const INTERNAL_RESOLVE = exports.INTERNAL_RESOLVE = Symbol('internal_resolve');
129
- const WORKER_PATH = exports.WORKER_PATH = _path().default.join(__dirname, 'worker.js');
130
+ let WORKER_PATH = exports.WORKER_PATH = _path().default.join(__dirname, 'worker.js');
131
+ if (process.env.ATLASPACK_REGISTER_USE_SRC === 'true') {
132
+ exports.WORKER_PATH = WORKER_PATH = _path().default.join(__dirname, 'worker.ts');
133
+ }
130
134
  class Atlaspack {
135
+ // @ts-expect-error TS2564
131
136
  #requestTracker;
137
+ // @ts-expect-error TS2564
132
138
  #config;
139
+ // @ts-expect-error TS2564
133
140
  #farm;
134
141
  #initialized = false;
142
+ // @ts-expect-error TS2564
135
143
  #disposable;
136
144
  #initialOptions;
145
+ // @ts-expect-error TS2564
137
146
  #reporterRunner;
138
147
  #resolvedOptions = null;
148
+ // @ts-expect-error TS2564
139
149
  #optionsRef;
150
+ // @ts-expect-error TS2564
140
151
  #watchAbortController;
141
152
  #watchQueue = new (_utils2().PromiseQueue)({
142
153
  maxConcurrent: 1
143
154
  });
155
+ // @ts-expect-error TS2564
144
156
  #watchEvents;
145
157
  #watcherSubscription;
146
158
  #watcherCount = 0;
147
159
  #requestedAssetIds = new Set();
160
+
161
+ // @ts-expect-error TS2564
162
+
148
163
  constructor(options) {
149
164
  this.#initialOptions = options;
150
165
  }
@@ -194,8 +209,6 @@ class Atlaspack {
194
209
  throw new Error('Atlaspack v3 must be run with lmdb lite cache');
195
210
  }
196
211
  const lmdb = resolvedOptions.cache.getNativeRef();
197
-
198
- // $FlowFixMe
199
212
  const version = require('../package.json').version;
200
213
  await lmdb.put('current_session_version', Buffer.from(version));
201
214
  let threads = undefined;
@@ -206,12 +219,12 @@ class Atlaspack {
206
219
  }
207
220
  rustAtlaspack = await _atlaspackV.AtlaspackV3.create({
208
221
  ...options,
222
+ // @ts-expect-error TS2353
209
223
  corePath: _path().default.join(__dirname, '..'),
210
224
  threads,
211
225
  entries: Array.isArray(entries) ? entries : entries == null ? undefined : [entries],
212
226
  env: resolvedOptions.env,
213
227
  fs: inputFS && new _atlaspackV.FileSystemV3(inputFS),
214
- // $FlowFixMe ProjectPath is a string
215
228
  defaultTargetOptions: resolvedOptions.defaultTargetOptions,
216
229
  lmdb
217
230
  });
@@ -221,6 +234,7 @@ class Atlaspack {
221
234
  });
222
235
  }
223
236
  }
237
+ // @ts-expect-error TS2454
224
238
  this.rustAtlaspack = rustAtlaspack;
225
239
  let {
226
240
  config
@@ -266,6 +280,7 @@ class Atlaspack {
266
280
  this.#requestTracker = await _RequestTracker.default.init({
267
281
  farm: this.#farm,
268
282
  options: resolvedOptions,
283
+ // @ts-expect-error TS2454
269
284
  rustAtlaspack
270
285
  });
271
286
  this.#initialized = true;
@@ -332,6 +347,8 @@ class Atlaspack {
332
347
  if (!this.#initialized) {
333
348
  await this._init();
334
349
  }
350
+
351
+ // @ts-expect-error TS7034
335
352
  let watchEventsDisposable;
336
353
  if (cb) {
337
354
  watchEventsDisposable = this.#watchEvents.addListener(({
@@ -351,8 +368,11 @@ class Atlaspack {
351
368
  this.#watchQueue.run();
352
369
  }
353
370
  this.#watcherCount++;
371
+
372
+ // @ts-expect-error TS7034
354
373
  let unsubscribePromise;
355
374
  const unsubscribe = async () => {
375
+ // @ts-expect-error TS7005
356
376
  if (watchEventsDisposable) {
357
377
  watchEventsDisposable.dispose();
358
378
  }
@@ -370,9 +390,12 @@ class Atlaspack {
370
390
  };
371
391
  return {
372
392
  unsubscribe() {
393
+ // @ts-expect-error TS7005
373
394
  if (unsubscribePromise == null) {
374
395
  unsubscribePromise = unsubscribe();
375
396
  }
397
+
398
+ // @ts-expect-error TS7005
376
399
  return unsubscribePromise;
377
400
  }
378
401
  };
@@ -415,13 +438,14 @@ class Atlaspack {
415
438
  });
416
439
  this.#requestedAssetIds.clear();
417
440
  await (0, _dumpGraphToGraphViz.default)(
418
- // $FlowFixMe
441
+ // @ts-expect-error TS2345
419
442
  this.#requestTracker.graph, 'RequestGraph', _RequestTracker.requestGraphEdgeTypes);
420
443
  let event = {
421
444
  type: 'buildSuccess',
422
445
  changedAssets: new Map(Array.from(changedAssets).map(([id, asset]) => [id, (0, _Asset.assetFromValue)(asset, options)])),
423
446
  bundleGraph: new _BundleGraph.default(bundleGraph, (bundle, bundleGraph, options) => _Bundle.PackagedBundle.getWithInfo(bundle, bundleGraph, options, bundleInfo.get(bundle.id)), options),
424
447
  buildTime: Date.now() - startTime,
448
+ // @ts-expect-error TS7006
425
449
  requestBundle: async bundle => {
426
450
  let bundleNode = bundleGraph._graph.getNodeByContentKey(bundle.id);
427
451
  (0, _assert().default)((bundleNode === null || bundleNode === void 0 ? void 0 : bundleNode.type) === 'bundle', 'Bundle does not exist');
@@ -447,15 +471,21 @@ class Atlaspack {
447
471
  }
448
472
  let results = await this.#watchQueue.run();
449
473
  let result = results.filter(Boolean).pop();
474
+ // @ts-expect-error TS18049
450
475
  if (result.type === 'buildFailure') {
476
+ // @ts-expect-error TS18049
451
477
  throw new BuildError(result.diagnostics);
452
478
  }
453
479
  return result;
454
480
  },
455
481
  unstable_requestStats: this.#requestTracker.flushStats()
456
482
  };
483
+
484
+ // @ts-expect-error TS2345
457
485
  await this.#reporterRunner.report(event);
458
- await this.#requestTracker.runRequest((0, _ValidationRequest.default)({
486
+ await this.#requestTracker.runRequest(
487
+ // @ts-expect-error TS2345
488
+ (0, _ValidationRequest.default)({
459
489
  optionsRef: this.#optionsRef,
460
490
  assetRequests
461
491
  }), {
@@ -464,6 +494,8 @@ class Atlaspack {
464
494
  if (this.#reporterRunner.errors.length) {
465
495
  throw this.#reporterRunner.errors;
466
496
  }
497
+
498
+ // @ts-expect-error TS2322
467
499
  return event;
468
500
  } catch (e) {
469
501
  if (e instanceof _utils.BuildAbortError) {
@@ -475,7 +507,10 @@ class Atlaspack {
475
507
  diagnostics: Array.isArray(diagnostic) ? diagnostic : [diagnostic],
476
508
  unstable_requestStats: this.#requestTracker.flushStats()
477
509
  };
510
+
511
+ // @ts-expect-error TS2345
478
512
  await this.#reporterRunner.report(event);
513
+ // @ts-expect-error TS2322
479
514
  return event;
480
515
  } finally {
481
516
  if (this.isProfiling) {
@@ -588,7 +623,11 @@ class Atlaspack {
588
623
  requestedAssetIds: this.#requestedAssetIds
589
624
  };
590
625
  const start = Date.now();
591
- const result = await this.#requestTracker.runRequest(this.rustAtlaspack != null ? (0, _AssetGraphRequestRust.createAssetGraphRequestRust)(this.rustAtlaspack)(input) : (0, _AssetGraphRequest.default)(input), {
626
+ const result = await this.#requestTracker.runRequest(this.rustAtlaspack != null ?
627
+ // @ts-expect-error TS2345
628
+ (0, _AssetGraphRequestRust.createAssetGraphRequestRust)(this.rustAtlaspack)(input) :
629
+ // @ts-expect-error TS2345
630
+ (0, _AssetGraphRequest.default)(input), {
592
631
  force: true
593
632
  });
594
633
  const duration = Date.now() - start;
@@ -675,6 +714,7 @@ class Atlaspack {
675
714
  return null;
676
715
  }
677
716
  return {
717
+ // @ts-expect-error TS2322
678
718
  filePath: (0, _projectPath.fromProjectPath)(projectRoot, res.filePath),
679
719
  code: res.code,
680
720
  query: res.query,
@@ -0,0 +1,65 @@
1
+ import type { Glob, Transformer, Resolver, Bundler, Namer, Runtime, PackageName, Optimizer, Compressor, Packager, Reporter, Semver, Validator, FilePath } from '@atlaspack/types';
2
+ import type { ProcessedAtlaspackConfig, AtlaspackPluginNode, PureAtlaspackConfigPipeline, ExtendableAtlaspackConfigPipeline, AtlaspackOptions } from './types';
3
+ import ThrowableDiagnostic from '@atlaspack/diagnostic';
4
+ import { ProjectPath } from './projectPath';
5
+ type GlobMap<T> = Partial<Record<Glob, T>>;
6
+ type SerializedAtlaspackConfig = {
7
+ $$raw: boolean;
8
+ config: ProcessedAtlaspackConfig;
9
+ options: AtlaspackOptions;
10
+ };
11
+ export type LoadedPlugin<T> = {
12
+ name: string;
13
+ version: Semver;
14
+ plugin: T;
15
+ resolveFrom: ProjectPath;
16
+ keyPath?: string;
17
+ };
18
+ export declare class AtlaspackConfig {
19
+ options: AtlaspackOptions;
20
+ filePath: ProjectPath;
21
+ resolvers: PureAtlaspackConfigPipeline;
22
+ transformers: GlobMap<ExtendableAtlaspackConfigPipeline>;
23
+ bundler: AtlaspackPluginNode | null | undefined;
24
+ namers: PureAtlaspackConfigPipeline;
25
+ runtimes: PureAtlaspackConfigPipeline;
26
+ packagers: GlobMap<AtlaspackPluginNode>;
27
+ validators: GlobMap<ExtendableAtlaspackConfigPipeline>;
28
+ optimizers: GlobMap<ExtendableAtlaspackConfigPipeline>;
29
+ compressors: GlobMap<ExtendableAtlaspackConfigPipeline>;
30
+ reporters: PureAtlaspackConfigPipeline;
31
+ pluginCache: Map<PackageName, any>;
32
+ regexCache: Map<string, RegExp>;
33
+ constructor(config: ProcessedAtlaspackConfig, options: AtlaspackOptions);
34
+ static deserialize(serialized: SerializedAtlaspackConfig): AtlaspackConfig;
35
+ getConfig(): ProcessedAtlaspackConfig;
36
+ serialize(): SerializedAtlaspackConfig;
37
+ _loadPlugin<T>(node: AtlaspackPluginNode): Promise<{
38
+ plugin: T;
39
+ version: Semver;
40
+ resolveFrom: ProjectPath;
41
+ }>;
42
+ loadPlugin<T>(node: AtlaspackPluginNode): Promise<LoadedPlugin<T>>;
43
+ invalidatePlugin(packageName: PackageName): void;
44
+ loadPlugins<T>(plugins: PureAtlaspackConfigPipeline): Promise<Array<LoadedPlugin<T>>>;
45
+ getResolvers(): Promise<Array<LoadedPlugin<Resolver<unknown>>>>;
46
+ _getValidatorNodes(filePath: ProjectPath): ReadonlyArray<AtlaspackPluginNode>;
47
+ getValidatorNames(filePath: ProjectPath): Array<string>;
48
+ getValidators(filePath: ProjectPath): Promise<Array<LoadedPlugin<Validator>>>;
49
+ getNamedPipelines(): ReadonlyArray<string>;
50
+ getTransformers(filePath: ProjectPath, pipeline?: string | null, allowEmpty?: boolean): Promise<Array<LoadedPlugin<Transformer<unknown>>>>;
51
+ getBundler(): Promise<LoadedPlugin<Bundler<unknown>>>;
52
+ getNamers(): Promise<Array<LoadedPlugin<Namer<unknown>>>>;
53
+ getRuntimes(): Promise<Array<LoadedPlugin<Runtime<unknown>>>>;
54
+ getPackager(filePath: FilePath): Promise<LoadedPlugin<Packager<unknown, unknown>>>;
55
+ _getOptimizerNodes(filePath: FilePath, pipeline?: string | null): PureAtlaspackConfigPipeline;
56
+ getOptimizerNames(filePath: FilePath, pipeline?: string | null): Array<string>;
57
+ getOptimizers(filePath: FilePath, pipeline?: string | null): Promise<Array<LoadedPlugin<Optimizer<unknown, unknown>>>>;
58
+ getCompressors(filePath: FilePath): Promise<Array<LoadedPlugin<Compressor>>>;
59
+ getReporters(): Promise<Array<LoadedPlugin<Reporter>>>;
60
+ isGlobMatch(projectPath: ProjectPath, pattern: Glob, pipeline?: string | null): boolean;
61
+ matchGlobMap<T>(filePath: ProjectPath, globMap: Partial<Record<Glob, T>>): T | null | undefined;
62
+ matchGlobMapPipelines(filePath: ProjectPath, globMap: Partial<Record<Glob, ExtendableAtlaspackConfigPipeline>>, pipeline?: string | null): PureAtlaspackConfigPipeline;
63
+ missingPluginError(plugins: GlobMap<ExtendableAtlaspackConfigPipeline> | GlobMap<AtlaspackPluginNode> | PureAtlaspackConfigPipeline, message: string, key: string): Promise<ThrowableDiagnostic>;
64
+ }
65
+ export {};
@@ -90,6 +90,7 @@ class AtlaspackConfig {
90
90
  }
91
91
  async loadPlugin(node) {
92
92
  let plugin = await this._loadPlugin(node);
93
+ // @ts-expect-error TS2322
93
94
  return {
94
95
  ...plugin,
95
96
  name: node.packageName,
@@ -129,7 +130,9 @@ class AtlaspackConfig {
129
130
  if (allowEmpty) {
130
131
  return [];
131
132
  }
132
- throw await this.missingPluginError(this.transformers, (0, _diagnostic().md)`No transformers found for __${(0, _projectPath.fromProjectPathRelative)(filePath)}__` + (pipeline != null ? ` with pipeline: '${pipeline}'` : '') + '.', '/transformers');
133
+ throw await this.missingPluginError(this.transformers,
134
+ // @ts-expect-error TS2345
135
+ (0, _diagnostic().md)`No transformers found for __${(0, _projectPath.fromProjectPathRelative)(filePath)}__` + (pipeline != null ? ` with pipeline: '${pipeline}'` : '') + '.', '/transformers');
133
136
  }
134
137
  return this.loadPlugins(transformers);
135
138
  }
@@ -154,7 +157,9 @@ class AtlaspackConfig {
154
157
  async getPackager(filePath) {
155
158
  let packager = this.matchGlobMap((0, _projectPath.toProjectPathUnsafe)(filePath), this.packagers);
156
159
  if (!packager) {
157
- throw await this.missingPluginError(this.packagers, (0, _diagnostic().md)`No packager found for __${filePath}__.`, '/packagers');
160
+ throw await this.missingPluginError(this.packagers,
161
+ // @ts-expect-error TS2345
162
+ (0, _diagnostic().md)`No packager found for __${filePath}__.`, '/packagers');
158
163
  }
159
164
  return this.loadPlugin(packager);
160
165
  }
@@ -183,7 +188,9 @@ class AtlaspackConfig {
183
188
  async getCompressors(filePath) {
184
189
  let compressors = this.matchGlobMapPipelines((0, _projectPath.toProjectPathUnsafe)(filePath), this.compressors) ?? [];
185
190
  if (compressors.length === 0) {
186
- throw await this.missingPluginError(this.compressors, (0, _diagnostic().md)`No compressors found for __${filePath}__.`, '/compressors');
191
+ throw await this.missingPluginError(this.compressors,
192
+ // @ts-expect-error TS2345
193
+ (0, _diagnostic().md)`No compressors found for __${filePath}__.`, '/compressors');
187
194
  }
188
195
  return this.loadPlugins(compressors);
189
196
  }
@@ -196,6 +203,7 @@ class AtlaspackConfig {
196
203
  let [patternPipeline, patternGlob] = pattern.split(':');
197
204
  if (!patternGlob) {
198
205
  patternGlob = patternPipeline;
206
+ // @ts-expect-error TS2322
199
207
  patternPipeline = null;
200
208
  }
201
209
  let re = this.regexCache.get(patternGlob);
@@ -235,6 +243,7 @@ class AtlaspackConfig {
235
243
  }
236
244
  for (let pattern in globMap) {
237
245
  if (this.isGlobMatch(filePath, pattern)) {
246
+ // @ts-expect-error TS2345
238
247
  matches.push(globMap[pattern]);
239
248
  }
240
249
  }
@@ -250,7 +259,7 @@ class AtlaspackConfig {
250
259
  return pipeline;
251
260
  };
252
261
  let res = flatten();
253
- // $FlowFixMe afaik this should work
262
+ // @ts-expect-error TS2322
254
263
  return res;
255
264
  }
256
265
  async missingPluginError(plugins, message, key) {
@@ -258,7 +267,13 @@ class AtlaspackConfig {
258
267
  if (Array.isArray(plugins)) {
259
268
  configsWithPlugin = new Set(getConfigPaths(this.options, plugins));
260
269
  } else {
261
- configsWithPlugin = new Set(Object.keys(plugins).flatMap(k => Array.isArray(plugins[k]) ? getConfigPaths(this.options, plugins[k]) : [getConfigPath(this.options, plugins[k])]));
270
+ configsWithPlugin = new Set(Object.keys(plugins).flatMap(k =>
271
+ // @ts-expect-error TS7053
272
+ Array.isArray(plugins[k]) ?
273
+ // @ts-expect-error TS7053
274
+ getConfigPaths(this.options, plugins[k]) :
275
+ // @ts-expect-error TS7053
276
+ [getConfigPath(this.options, plugins[k])]));
262
277
  }
263
278
  if (configsWithPlugin.size === 0) {
264
279
  configsWithPlugin.add((0, _projectPath.fromProjectPath)(this.options.projectRoot, this.filePath));
@@ -291,8 +306,11 @@ class AtlaspackConfig {
291
306
  }
292
307
  exports.AtlaspackConfig = AtlaspackConfig;
293
308
  function getConfigPaths(options, nodes) {
294
- return nodes.map(node => node !== '...' ? getConfigPath(options, node) : null).filter(Boolean);
309
+ return nodes
310
+ // @ts-expect-error TS2339
311
+ .map(node => node !== '...' ? getConfigPath(options, node) : null).filter(Boolean);
295
312
  }
296
313
  function getConfigPath(options, node) {
314
+ // @ts-expect-error TS2339
297
315
  return (0, _projectPath.fromProjectPath)(options.projectRoot, node.resolveFrom);
298
316
  }