@atlaspack/core 2.19.1 → 2.19.3-typescript-08dcc1c9b.0

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 (182) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +201 -0
  3. package/lib/AssetGraph.js +92 -10
  4. package/lib/Atlaspack.js +47 -7
  5. package/lib/AtlaspackConfig.js +24 -6
  6. package/lib/AtlaspackConfig.schema.js +0 -4
  7. package/lib/BundleGraph.js +78 -17
  8. package/lib/CommittedAsset.js +6 -0
  9. package/lib/Dependency.js +2 -0
  10. package/lib/Environment.js +2 -2
  11. package/lib/EnvironmentManager.js +6 -0
  12. package/lib/IdentifierRegistry.js +1 -3
  13. package/lib/PackagerRunner.js +10 -5
  14. package/lib/ReporterRunner.js +6 -9
  15. package/lib/RequestTracker.js +28 -11
  16. package/lib/SymbolPropagation.js +52 -7
  17. package/lib/Transformation.js +15 -7
  18. package/lib/UncommittedAsset.js +10 -7
  19. package/lib/Validation.js +18 -2
  20. package/lib/applyRuntimes.js +5 -0
  21. package/lib/assetUtils.js +5 -3
  22. package/lib/atlaspack-v3/AtlaspackV3.js +10 -2
  23. package/lib/atlaspack-v3/NapiWorkerPool.js +3 -0
  24. package/lib/atlaspack-v3/fs.js +3 -1
  25. package/lib/atlaspack-v3/index.js +28 -1
  26. package/lib/atlaspack-v3/jsCallable.js +0 -2
  27. package/lib/atlaspack-v3/worker/compat/asset-symbols.js +5 -3
  28. package/lib/atlaspack-v3/worker/compat/bitflags.js +5 -5
  29. package/lib/atlaspack-v3/worker/compat/dependency.js +3 -0
  30. package/lib/atlaspack-v3/worker/compat/environment.js +2 -3
  31. package/lib/atlaspack-v3/worker/compat/mutable-asset.js +8 -3
  32. package/lib/atlaspack-v3/worker/compat/plugin-config.js +3 -5
  33. package/lib/atlaspack-v3/worker/compat/plugin-options.js +1 -0
  34. package/lib/atlaspack-v3/worker/compat/plugin-tracer.js +3 -0
  35. package/lib/atlaspack-v3/worker/compat/target.js +2 -0
  36. package/lib/atlaspack-v3/worker/worker.js +18 -5
  37. package/lib/constants.js +0 -1
  38. package/lib/dumpGraphToGraphViz.js +70 -15
  39. package/lib/index.js +17 -1
  40. package/lib/loadAtlaspackPlugin.js +3 -0
  41. package/lib/loadDotEnv.js +4 -1
  42. package/lib/projectPath.js +5 -0
  43. package/lib/public/Asset.js +14 -2
  44. package/lib/public/Bundle.js +3 -3
  45. package/lib/public/BundleGraph.js +7 -2
  46. package/lib/public/BundleGroup.js +2 -2
  47. package/lib/public/Config.js +27 -13
  48. package/lib/public/Dependency.js +4 -2
  49. package/lib/public/Environment.js +2 -2
  50. package/lib/public/MutableBundleGraph.js +33 -7
  51. package/lib/public/PluginOptions.js +1 -0
  52. package/lib/public/Symbols.js +63 -14
  53. package/lib/public/Target.js +3 -2
  54. package/lib/registerCoreWithSerializer.js +2 -3
  55. package/lib/requests/AssetGraphRequest.js +20 -3
  56. package/lib/requests/AssetGraphRequestRust.js +7 -4
  57. package/lib/requests/AssetRequest.js +21 -5
  58. package/lib/requests/AtlaspackBuildRequest.js +6 -2
  59. package/lib/requests/AtlaspackConfigRequest.js +15 -11
  60. package/lib/requests/BundleGraphRequest.js +16 -17
  61. package/lib/requests/ConfigRequest.js +1 -0
  62. package/lib/requests/DevDepRequest.js +20 -4
  63. package/lib/requests/EntryRequest.js +9 -0
  64. package/lib/requests/PackageRequest.js +7 -2
  65. package/lib/requests/PathRequest.js +20 -5
  66. package/lib/requests/TargetRequest.js +72 -40
  67. package/lib/requests/ValidationRequest.js +5 -1
  68. package/lib/requests/WriteBundleRequest.js +24 -8
  69. package/lib/requests/WriteBundlesRequest.js +26 -6
  70. package/lib/requests/asset-graph-dot.js +1 -7
  71. package/lib/rustWorkerThreadDylibHack.js +0 -1
  72. package/lib/types.js +2 -0
  73. package/lib/utils.js +13 -2
  74. package/lib/worker.js +9 -6
  75. package/package.json +24 -23
  76. package/src/{AssetGraph.js → AssetGraph.ts} +126 -42
  77. package/src/{Atlaspack.js → Atlaspack.ts} +75 -38
  78. package/src/{AtlaspackConfig.schema.js → AtlaspackConfig.schema.ts} +16 -19
  79. package/src/{AtlaspackConfig.js → AtlaspackConfig.ts} +81 -54
  80. package/src/{BundleGraph.js → BundleGraph.ts} +188 -120
  81. package/src/{CommittedAsset.js → CommittedAsset.ts} +14 -12
  82. package/src/{Dependency.js → Dependency.ts} +48 -39
  83. package/src/{Environment.js → Environment.ts} +8 -9
  84. package/src/{EnvironmentManager.js → EnvironmentManager.ts} +14 -5
  85. package/src/{IdentifierRegistry.js → IdentifierRegistry.ts} +1 -4
  86. package/src/{InternalConfig.js → InternalConfig.ts} +18 -20
  87. package/src/{PackagerRunner.js → PackagerRunner.ts} +67 -59
  88. package/src/{ReporterRunner.js → ReporterRunner.ts} +13 -18
  89. package/src/{RequestTracker.js → RequestTracker.ts} +255 -206
  90. package/src/{SymbolPropagation.js → SymbolPropagation.ts} +157 -44
  91. package/src/{TargetDescriptor.schema.js → TargetDescriptor.schema.ts} +0 -1
  92. package/src/{Transformation.js → Transformation.ts} +67 -61
  93. package/src/{UncommittedAsset.js → UncommittedAsset.ts} +34 -33
  94. package/src/{Validation.js → Validation.ts} +32 -17
  95. package/src/{applyRuntimes.js → applyRuntimes.ts} +27 -25
  96. package/src/{assetUtils.js → assetUtils.ts} +44 -33
  97. package/src/atlaspack-v3/{AtlaspackV3.js → AtlaspackV3.ts} +20 -15
  98. package/src/atlaspack-v3/{NapiWorkerPool.js → NapiWorkerPool.ts} +10 -5
  99. package/src/atlaspack-v3/{fs.js → fs.ts} +3 -4
  100. package/src/atlaspack-v3/{index.js → index.ts} +2 -4
  101. package/src/atlaspack-v3/jsCallable.ts +14 -0
  102. package/src/atlaspack-v3/worker/compat/{asset-symbols.js → asset-symbols.ts} +52 -49
  103. package/src/atlaspack-v3/worker/compat/{bitflags.js → bitflags.ts} +8 -10
  104. package/src/atlaspack-v3/worker/compat/{dependency.js → dependency.ts} +12 -12
  105. package/src/atlaspack-v3/worker/compat/{environment.js → environment.ts} +4 -8
  106. package/src/atlaspack-v3/worker/compat/{index.js → index.ts} +0 -1
  107. package/src/atlaspack-v3/worker/compat/{mutable-asset.js → mutable-asset.ts} +20 -19
  108. package/src/atlaspack-v3/worker/compat/{plugin-config.js → plugin-config.ts} +26 -29
  109. package/src/atlaspack-v3/worker/compat/{plugin-logger.js → plugin-logger.ts} +0 -2
  110. package/src/atlaspack-v3/worker/compat/{plugin-options.js → plugin-options.ts} +4 -5
  111. package/src/atlaspack-v3/worker/compat/{plugin-tracer.js → plugin-tracer.ts} +2 -2
  112. package/src/atlaspack-v3/worker/compat/{target.js → target.ts} +3 -4
  113. package/src/atlaspack-v3/worker/{worker.js → worker.ts} +78 -64
  114. package/src/{constants.js → constants.ts} +0 -3
  115. package/src/{dumpGraphToGraphViz.js → dumpGraphToGraphViz.ts} +73 -28
  116. package/src/{index.js → index.ts} +2 -1
  117. package/src/{loadAtlaspackPlugin.js → loadAtlaspackPlugin.ts} +11 -9
  118. package/src/{loadDotEnv.js → loadDotEnv.ts} +2 -2
  119. package/src/{projectPath.js → projectPath.ts} +20 -9
  120. package/src/public/{Asset.js → Asset.ts} +29 -23
  121. package/src/public/{Bundle.js → Bundle.ts} +17 -19
  122. package/src/public/{BundleGraph.js → BundleGraph.ts} +71 -48
  123. package/src/public/{BundleGroup.js → BundleGroup.ts} +5 -8
  124. package/src/public/{Config.js → Config.ts} +63 -39
  125. package/src/public/{Dependency.js → Dependency.ts} +16 -14
  126. package/src/public/{Environment.js → Environment.ts} +11 -14
  127. package/src/public/{MutableBundleGraph.js → MutableBundleGraph.ts} +33 -17
  128. package/src/public/{PluginOptions.js → PluginOptions.ts} +5 -5
  129. package/src/public/{Symbols.js → Symbols.ts} +109 -36
  130. package/src/public/{Target.js → Target.ts} +6 -5
  131. package/src/{registerCoreWithSerializer.js → registerCoreWithSerializer.ts} +6 -6
  132. package/src/requests/{AssetGraphRequest.js → AssetGraphRequest.ts} +60 -45
  133. package/src/requests/{AssetGraphRequestRust.js → AssetGraphRequestRust.ts} +18 -19
  134. package/src/requests/{AssetRequest.js → AssetRequest.ts} +22 -17
  135. package/src/requests/{AtlaspackBuildRequest.js → AtlaspackBuildRequest.ts} +30 -31
  136. package/src/requests/{AtlaspackConfigRequest.js → AtlaspackConfigRequest.ts} +61 -51
  137. package/src/requests/{BundleGraphRequest.js → BundleGraphRequest.ts} +53 -54
  138. package/src/requests/{ConfigRequest.js → ConfigRequest.ts} +40 -43
  139. package/src/requests/{DevDepRequest.js → DevDepRequest.ts} +42 -30
  140. package/src/requests/{EntryRequest.js → EntryRequest.ts} +43 -31
  141. package/src/requests/{PackageRequest.js → PackageRequest.ts} +21 -21
  142. package/src/requests/{PathRequest.js → PathRequest.ts} +45 -37
  143. package/src/requests/{TargetRequest.js → TargetRequest.ts} +196 -153
  144. package/src/requests/{ValidationRequest.js → ValidationRequest.ts} +18 -17
  145. package/src/requests/{WriteBundleRequest.js → WriteBundleRequest.ts} +63 -41
  146. package/src/requests/{WriteBundlesRequest.js → WriteBundlesRequest.ts} +38 -27
  147. package/src/requests/{asset-graph-dot.js → asset-graph-dot.ts} +8 -12
  148. package/src/{resolveOptions.js → resolveOptions.ts} +6 -8
  149. package/src/{rustWorkerThreadDylibHack.js → rustWorkerThreadDylibHack.ts} +1 -4
  150. package/src/{serializerCore.browser.js → serializerCore.browser.ts} +2 -3
  151. package/src/{summarizeRequest.js → summarizeRequest.ts} +17 -5
  152. package/src/types.ts +637 -0
  153. package/src/{utils.js → utils.ts} +45 -20
  154. package/src/{worker.js → worker.ts} +44 -34
  155. package/test/{AssetGraph.test.js → AssetGraph.test.ts} +37 -8
  156. package/test/{Atlaspack.test.js → Atlaspack.test.ts} +5 -10
  157. package/test/{AtlaspackConfig.test.js → AtlaspackConfig.test.ts} +0 -5
  158. package/test/{AtlaspackConfigRequest.test.js → AtlaspackConfigRequest.test.ts} +3 -15
  159. package/test/{BundleGraph.test.js → BundleGraph.test.ts} +8 -13
  160. package/test/{Dependency.test.js → Dependency.test.ts} +2 -3
  161. package/test/{EntryRequest.test.js → EntryRequest.test.ts} +1 -6
  162. package/test/{Environment.test.js → Environment.test.ts} +2 -5
  163. package/test/{EnvironmentManager.test.js → EnvironmentManager.test.ts} +7 -9
  164. package/test/{IdentifierRegistry.test.js → IdentifierRegistry.test.ts} +2 -4
  165. package/test/{InternalAsset.test.js → InternalAsset.test.ts} +2 -7
  166. package/test/{PublicAsset.test.js → PublicAsset.test.ts} +2 -7
  167. package/test/{PublicBundle.test.js → PublicBundle.test.ts} +1 -2
  168. package/test/{PublicDependency.test.js → PublicDependency.test.ts} +0 -2
  169. package/test/{PublicEnvironment.test.js → PublicEnvironment.test.ts} +0 -2
  170. package/test/{PublicMutableBundleGraph.test.js → PublicMutableBundleGraph.test.ts} +6 -11
  171. package/test/{RequestTracker.test.js → RequestTracker.test.ts} +194 -34
  172. package/test/{SymbolPropagation.test.js → SymbolPropagation.test.ts} +124 -74
  173. package/test/{TargetRequest.test.js → TargetRequest.test.ts} +3 -17
  174. package/test/public/{Config.test.js → Config.test.ts} +7 -11
  175. package/test/requests/{AssetGraphRequestRust.test.js → AssetGraphRequestRust.test.ts} +0 -1
  176. package/test/requests/{ConfigRequest.test.js → ConfigRequest.test.ts} +19 -22
  177. package/test/requests/{DevDepRequest.test.js → DevDepRequest.test.ts} +0 -2
  178. package/test/{test-utils.js → test-utils.ts} +0 -2
  179. package/test/{utils.test.js → utils.test.ts} +1 -3
  180. package/tsconfig.json +4 -0
  181. package/src/atlaspack-v3/jsCallable.js +0 -18
  182. package/src/types.js +0 -603
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaspack/core
2
2
 
3
+ ## 2.19.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#707](https://github.com/atlassian-labs/atlaspack/pull/707) [`a0b959f`](https://github.com/atlassian-labs/atlaspack/commit/a0b959fbf61fc3f820ff03c7e8988945fe40a91a) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix content key not found exceptions when bundling is aborted after a unsafe to incrementally bundle asset graph request
8
+
9
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa), [`1c7865a`](https://github.com/atlassian-labs/atlaspack/commit/1c7865a64451116d94015e248302435839d347c0), [`a0b959f`](https://github.com/atlassian-labs/atlaspack/commit/a0b959fbf61fc3f820ff03c7e8988945fe40a91a)]:
10
+ - @atlaspack/plugin@2.14.20
11
+ - @atlaspack/feature-flags@2.19.2
12
+ - @atlaspack/cache@3.2.15
13
+ - @atlaspack/fs@2.15.15
14
+ - @atlaspack/graph@3.5.9
15
+ - @atlaspack/utils@2.17.2
16
+ - @atlaspack/package-manager@2.14.20
17
+ - @atlaspack/profiler@2.14.17
18
+ - @atlaspack/types@2.15.10
19
+ - @atlaspack/workers@2.14.20
20
+
3
21
  ## 2.19.1
4
22
 
5
23
  ### Patch Changes
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (c) 2024 Atlassian US., Inc.
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
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,16 +105,34 @@ function nodeFromEntryFile(entry) {
101
105
  value: entry
102
106
  };
103
107
  }
108
+
109
+ // @ts-expect-error TS2417
104
110
  class AssetGraph extends _graph().ContentGraph {
111
+ /**
112
+ * Incremented when the asset graph is modified such that it requires a bundling pass.
113
+ */
114
+ #bundlingVersion = 0;
115
+ /**
116
+ * Force incremental bundling to be disabled.
117
+ */
118
+ #disableIncrementalBundling = false;
119
+
120
+ /**
121
+ * @deprecated
122
+ */
105
123
  safeToIncrementallyBundle = true;
106
124
  constructor(opts) {
107
125
  if (opts) {
108
126
  let {
109
127
  hash,
128
+ bundlingVersion,
129
+ disableIncrementalBundling,
110
130
  ...rest
111
131
  } = opts;
112
132
  super(rest);
113
133
  this.hash = hash;
134
+ this.#bundlingVersion = bundlingVersion ?? 0;
135
+ this.#disableIncrementalBundling = disableIncrementalBundling ?? false;
114
136
  } else {
115
137
  super();
116
138
  this.setRootNodeId(this.addNode({
@@ -122,25 +144,72 @@ class AssetGraph extends _graph().ContentGraph {
122
144
  this.undeferredDependencies = new Set();
123
145
  this.envCache = new Map();
124
146
  }
125
-
126
- // $FlowFixMe[prop-missing]
127
147
  static deserialize(opts) {
128
148
  return new AssetGraph(opts);
129
149
  }
130
-
131
- // $FlowFixMe[prop-missing]
132
150
  serialize() {
133
151
  return {
134
152
  ...super.serialize(),
153
+ bundlingVersion: this.#bundlingVersion,
154
+ disableIncrementalBundling: this.#disableIncrementalBundling,
135
155
  hash: this.hash
136
156
  };
137
157
  }
138
158
 
159
+ /**
160
+ * Force incremental bundling to be disabled.
161
+ */
162
+ setDisableIncrementalBundling(disable) {
163
+ this.#disableIncrementalBundling = disable;
164
+ }
165
+ testing_getDisableIncrementalBundling() {
166
+ return this.#disableIncrementalBundling;
167
+ }
168
+
169
+ /**
170
+ * Make sure this asset graph is marked as needing a full bundling pass.
171
+ */
172
+ setNeedsBundling() {
173
+ if (!(0, _featureFlags().getFeatureFlag)('incrementalBundlingVersioning')) {
174
+ // In legacy mode, we rely solely on safeToIncrementallyBundle to
175
+ // invalidate incremental bundling, so we skip bumping the version.
176
+ return;
177
+ }
178
+ this.#bundlingVersion += 1;
179
+ }
180
+
181
+ /**
182
+ * Get the current bundling version.
183
+ *
184
+ * Each bundle pass should keep this version around. Whenever an asset graph has a new version,
185
+ * bundling should be re-run.
186
+ */
187
+ getBundlingVersion() {
188
+ if (!(0, _featureFlags().getFeatureFlag)('incrementalBundlingVersioning')) {
189
+ return 0;
190
+ }
191
+ return this.#bundlingVersion;
192
+ }
193
+
194
+ /**
195
+ * If the `bundlingVersion` has not changed since the last bundling pass,
196
+ * we can incrementally bundle, which will not require a full bundling pass
197
+ * but just update assets into the bundle graph output.
198
+ */
199
+ canIncrementallyBundle(lastVersion) {
200
+ if (!(0, _featureFlags().getFeatureFlag)('incrementalBundlingVersioning')) {
201
+ return this.safeToIncrementallyBundle && !this.#disableIncrementalBundling;
202
+ }
203
+ return this.safeToIncrementallyBundle && this.#bundlingVersion === lastVersion && !this.#disableIncrementalBundling;
204
+ }
205
+
139
206
  // Deduplicates Environments by making them referentially equal
140
207
  normalizeEnvironment(input) {
141
208
  if ((0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
142
209
  return;
143
210
  }
211
+
212
+ // @ts-expect-error TS2345
144
213
  let {
145
214
  id,
146
215
  context
@@ -150,6 +219,7 @@ class AssetGraph extends _graph().ContentGraph {
150
219
  if (env) {
151
220
  input.env = (0, _EnvironmentManager.toEnvironmentRef)(env);
152
221
  } else {
222
+ // @ts-expect-error TS2345
153
223
  this.envCache.set(idAndContext, (0, _EnvironmentManager.fromEnvironmentId)(input.env));
154
224
  }
155
225
  }
@@ -177,8 +247,6 @@ class AssetGraph extends _graph().ContentGraph {
177
247
  let existing = this.getNodeByContentKey(node.id);
178
248
  if (existing != null) {
179
249
  (0, _assert().default)(existing.type === node.type);
180
- // $FlowFixMe[incompatible-type] Checked above
181
- // $FlowFixMe[prop-missing]
182
250
  existing.value = node.value;
183
251
  let existingId = this.getNodeIdByContentKey(node.id);
184
252
  this.updateNode(existingId, existing);
@@ -210,6 +278,7 @@ class AssetGraph extends _graph().ContentGraph {
210
278
  env: target.env,
211
279
  isEntry: true,
212
280
  needsStableName: true,
281
+ // @ts-expect-error TS2322
213
282
  symbols: (0, _EnvironmentManager.fromEnvironmentId)(target.env).isLibrary ? new Map([['*', {
214
283
  local: '*',
215
284
  isWeak: true,
@@ -218,7 +287,9 @@ class AssetGraph extends _graph().ContentGraph {
218
287
  }));
219
288
  if ((0, _EnvironmentManager.fromEnvironmentId)(node.value.env).isLibrary) {
220
289
  // in library mode, all of the entry's symbols are "used"
290
+ // @ts-expect-error TS2345
221
291
  node.usedSymbolsDown.add('*');
292
+ // @ts-expect-error TS2345
222
293
  node.usedSymbolsUp.set('*', undefined);
223
294
  }
224
295
  return node;
@@ -296,7 +367,10 @@ class AssetGraph extends _graph().ContentGraph {
296
367
  if (traversedNode.type === 'asset') {
297
368
  let hasDeferred = this.getNodeIdsConnectedFrom(traversedNodeId).some(childNodeId => {
298
369
  let childNode = (0, _nullthrows().default)(this.getNode(childNodeId));
299
- 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;
300
374
  });
301
375
  if (!hasDeferred) {
302
376
  delete traversedNode.hasDeferred;
@@ -305,13 +379,16 @@ class AssetGraph extends _graph().ContentGraph {
305
379
  hasDeferred
306
380
  };
307
381
  } else if (traversedNode.type === 'asset_group' && nodeId !== traversedNodeId) {
382
+ // @ts-expect-error TS2339
308
383
  if (!(ctx !== null && ctx !== void 0 && ctx.hasDeferred)) {
309
384
  this.safeToIncrementallyBundle = false;
385
+ this.setNeedsBundling();
310
386
  delete traversedNode.hasDeferred;
311
387
  }
312
388
  actions.skipChildren();
313
389
  } else if (traversedNode.type === 'dependency') {
314
390
  this.safeToIncrementallyBundle = false;
391
+ this.setNeedsBundling();
315
392
  traversedNode.hasDeferred = false;
316
393
  } else if (nodeId !== traversedNodeId) {
317
394
  actions.skipChildren();
@@ -333,7 +410,9 @@ class AssetGraph extends _graph().ContentGraph {
333
410
  }
334
411
  let isDeferrable = [...dependencySymbols].every(([, {
335
412
  isWeak
336
- }]) => isWeak) && sideEffects === false && canDefer && !dependencySymbols.has('*');
413
+ }]) => isWeak) && sideEffects === false && canDefer &&
414
+ // @ts-expect-error TS2345
415
+ !dependencySymbols.has('*');
337
416
  if (!isDeferrable) {
338
417
  return false;
339
418
  }
@@ -359,7 +438,9 @@ class AssetGraph extends _graph().ContentGraph {
359
438
  if (this.undeferredDependencies.has(d)) {
360
439
  return false;
361
440
  }
362
- 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 => {
363
444
  var _resolvedAsset$symbol;
364
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;
365
446
  return assetSymbol != null && symbols.has(assetSymbol);
@@ -374,6 +455,7 @@ class AssetGraph extends _graph().ContentGraph {
374
455
  resolveAssetGroup(assetGroup, assets, correspondingRequest) {
375
456
  this.normalizeEnvironment(assetGroup);
376
457
  let assetGroupNode = nodeFromAssetGroup(assetGroup);
458
+ // @ts-expect-error TS2322
377
459
  assetGroupNode = this.getNodeByContentKey(assetGroupNode.id);
378
460
  if (!assetGroupNode) {
379
461
  return;
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,