@atlaspack/core 2.14.1-dev.144 → 2.14.1-dev.146

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 (67) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/lib/AssetGraph.js +17 -6
  3. package/lib/Atlaspack.js +24 -5
  4. package/lib/BundleGraph.js +6 -5
  5. package/lib/Dependency.js +6 -2
  6. package/lib/Environment.js +4 -3
  7. package/lib/EnvironmentManager.js +137 -0
  8. package/lib/InternalConfig.js +3 -2
  9. package/lib/PackagerRunner.js +52 -15
  10. package/lib/RequestTracker.js +337 -82
  11. package/lib/UncommittedAsset.js +20 -2
  12. package/lib/applyRuntimes.js +2 -1
  13. package/lib/assetUtils.js +2 -1
  14. package/lib/atlaspack-v3/worker/worker.js +8 -0
  15. package/lib/public/Asset.js +3 -2
  16. package/lib/public/Bundle.js +2 -1
  17. package/lib/public/BundleGraph.js +21 -5
  18. package/lib/public/Config.js +98 -3
  19. package/lib/public/Dependency.js +2 -1
  20. package/lib/public/MutableBundleGraph.js +2 -1
  21. package/lib/public/Target.js +2 -1
  22. package/lib/requests/AssetGraphRequest.js +13 -1
  23. package/lib/requests/AssetRequest.js +2 -1
  24. package/lib/requests/BundleGraphRequest.js +13 -1
  25. package/lib/requests/ConfigRequest.js +27 -4
  26. package/lib/requests/TargetRequest.js +18 -16
  27. package/lib/requests/WriteBundleRequest.js +15 -3
  28. package/lib/requests/WriteBundlesRequest.js +1 -0
  29. package/lib/resolveOptions.js +5 -6
  30. package/package.json +22 -18
  31. package/src/AssetGraph.js +12 -6
  32. package/src/Atlaspack.js +29 -13
  33. package/src/BundleGraph.js +13 -8
  34. package/src/Dependency.js +13 -5
  35. package/src/Environment.js +8 -5
  36. package/src/EnvironmentManager.js +145 -0
  37. package/src/InternalConfig.js +6 -5
  38. package/src/PackagerRunner.js +72 -20
  39. package/src/RequestTracker.js +567 -131
  40. package/src/UncommittedAsset.js +23 -3
  41. package/src/applyRuntimes.js +6 -1
  42. package/src/assetUtils.js +4 -3
  43. package/src/atlaspack-v3/worker/compat/plugin-config.js +9 -5
  44. package/src/atlaspack-v3/worker/worker.js +7 -0
  45. package/src/public/Asset.js +9 -2
  46. package/src/public/Bundle.js +2 -1
  47. package/src/public/BundleGraph.js +22 -5
  48. package/src/public/Config.js +129 -14
  49. package/src/public/Dependency.js +2 -1
  50. package/src/public/MutableBundleGraph.js +2 -1
  51. package/src/public/Target.js +2 -1
  52. package/src/requests/AssetGraphRequest.js +13 -3
  53. package/src/requests/AssetRequest.js +2 -1
  54. package/src/requests/BundleGraphRequest.js +13 -3
  55. package/src/requests/ConfigRequest.js +33 -9
  56. package/src/requests/TargetRequest.js +19 -25
  57. package/src/requests/WriteBundleRequest.js +14 -8
  58. package/src/requests/WriteBundlesRequest.js +1 -0
  59. package/src/resolveOptions.js +6 -8
  60. package/src/types.js +9 -7
  61. package/test/Environment.test.js +43 -34
  62. package/test/EnvironmentManager.test.js +192 -0
  63. package/test/PublicEnvironment.test.js +10 -7
  64. package/test/RequestTracker.test.js +115 -3
  65. package/test/public/Config.test.js +108 -0
  66. package/test/requests/ConfigRequest.test.js +187 -3
  67. package/test/test-utils.js +4 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,206 @@
1
1
  # @atlaspack/core
2
2
 
3
+ ## 2.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`1b52b99`](https://github.com/atlassian-labs/atlaspack/commit/1b52b99db4298b04c1a6eb0f97994d75a2d436f9)]:
8
+ - @atlaspack/graph@3.5.0
9
+
10
+ ## 2.18.0
11
+
12
+ ### Minor Changes
13
+
14
+ - [#601](https://github.com/atlassian-labs/atlaspack/pull/601) [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196) Thanks [@yamadapc](https://github.com/yamadapc)! - Improve granular configuration file invalidations
15
+
16
+ - [#599](https://github.com/atlassian-labs/atlaspack/pull/599) [`0b2f6f5`](https://github.com/atlassian-labs/atlaspack/commit/0b2f6f55794d3ff6e2f5a41f963e7e5dd8ad9f8d) Thanks [@pancaspe87](https://github.com/pancaspe87)! - load and write env to cache - change is feature flagged
17
+
18
+ ### Patch Changes
19
+
20
+ - [#595](https://github.com/atlassian-labs/atlaspack/pull/595) [`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b) Thanks [@yamadapc](https://github.com/yamadapc)! - Add bundleId to write bundle request results
21
+
22
+ - [#572](https://github.com/atlassian-labs/atlaspack/pull/572) [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca) Thanks [@yamadapc](https://github.com/yamadapc)! - Add feature-flagged change which removes all environment duplication around objects
23
+
24
+ - Updated dependencies [[`0999fb7`](https://github.com/atlassian-labs/atlaspack/commit/0999fb78da519a6c7582d212883e515fcf6c1252), [`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196), [`35fdd4b`](https://github.com/atlassian-labs/atlaspack/commit/35fdd4b52da0af20f74667f7b8adfb2f90279b7c), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
25
+ - @atlaspack/fs@2.15.5
26
+ - @atlaspack/types@2.15.0
27
+ - @atlaspack/rust@3.3.5
28
+ - @atlaspack/cache@3.2.5
29
+ - @atlaspack/package-manager@2.14.10
30
+ - @atlaspack/profiler@2.14.8
31
+ - @atlaspack/workers@2.14.10
32
+ - @atlaspack/plugin@2.14.10
33
+ - @atlaspack/logger@2.14.10
34
+ - @atlaspack/utils@2.14.10
35
+
36
+ ## 2.17.4
37
+
38
+ ### Patch Changes
39
+
40
+ - [#588](https://github.com/atlassian-labs/atlaspack/pull/588) [`1940859`](https://github.com/atlassian-labs/atlaspack/commit/194085942f0e86532e9d039fc3f8039badce4594) Thanks [@yamadapc](https://github.com/yamadapc)! - Do not invalidate all javascript files when tsconfig files change
41
+
42
+ - [#592](https://github.com/atlassian-labs/atlaspack/pull/592) [`15b6155`](https://github.com/atlassian-labs/atlaspack/commit/15b61556e9114203ebbc9de94b864118ca764598) Thanks [@yamadapc](https://github.com/yamadapc)! - Report large file invalidations
43
+
44
+ - [#503](https://github.com/atlassian-labs/atlaspack/pull/503) [`209692f`](https://github.com/atlassian-labs/atlaspack/commit/209692ffb11eae103a0d65c5e1118a5aa1625818) Thanks [@JakeLane](https://github.com/JakeLane)! - Fix conditional bundling reporter when condition is reused
45
+
46
+ - [#562](https://github.com/atlassian-labs/atlaspack/pull/562) [`d04de26`](https://github.com/atlassian-labs/atlaspack/commit/d04de26af684d7abfba5091fbe3df16a12cd0ebc) Thanks [@yamadapc](https://github.com/yamadapc)! - Update with feature-flagged change to write packages into files rather than LMDB
47
+
48
+ - Updated dependencies [[`124b7ff`](https://github.com/atlassian-labs/atlaspack/commit/124b7fff44f71aac9fbad289a9a9509b3dfc9aaa), [`e052521`](https://github.com/atlassian-labs/atlaspack/commit/e0525210850ed1606146eb86991049cf567c5dec), [`15c6d70`](https://github.com/atlassian-labs/atlaspack/commit/15c6d7000bd89da876bc590aa75b17a619a41896), [`e4d966c`](https://github.com/atlassian-labs/atlaspack/commit/e4d966c3c9c4292c5013372ae65b10d19d4bacc6), [`209692f`](https://github.com/atlassian-labs/atlaspack/commit/209692ffb11eae103a0d65c5e1118a5aa1625818), [`42a775d`](https://github.com/atlassian-labs/atlaspack/commit/42a775de8eec638ad188f3271964170d8c04d84b), [`29c2f10`](https://github.com/atlassian-labs/atlaspack/commit/29c2f106de9679adfb5afa04e1910471dc65a427), [`f4da1e1`](https://github.com/atlassian-labs/atlaspack/commit/f4da1e120e73eeb5e8b8927f05e88f04d6148c7b), [`1ef91fc`](https://github.com/atlassian-labs/atlaspack/commit/1ef91fcc863fdd2831511937083dbbc1263b3d9d)]:
49
+ - @atlaspack/cache@3.2.4
50
+ - @atlaspack/rust@3.3.4
51
+ - @atlaspack/fs@2.15.4
52
+ - @atlaspack/feature-flags@2.16.0
53
+ - @atlaspack/logger@2.14.9
54
+ - @atlaspack/utils@2.14.9
55
+ - @atlaspack/package-manager@2.14.9
56
+ - @atlaspack/graph@3.4.7
57
+ - @atlaspack/workers@2.14.9
58
+ - @atlaspack/profiler@2.14.7
59
+ - @atlaspack/types@2.14.9
60
+ - @atlaspack/plugin@2.14.9
61
+
62
+ ## 2.17.3
63
+
64
+ ### Patch Changes
65
+
66
+ - [#551](https://github.com/atlassian-labs/atlaspack/pull/551) [`30f6017`](https://github.com/atlassian-labs/atlaspack/commit/30f60175ba4d272c5fc193973c63bc298584775b) Thanks [@yamadapc](https://github.com/yamadapc)! - Log request tracker invalidation counts on start-up
67
+
68
+ - [#550](https://github.com/atlassian-labs/atlaspack/pull/550) [`3a3e8e7`](https://github.com/atlassian-labs/atlaspack/commit/3a3e8e7be9e2dffd7304436d792f0f595d59665a) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix typescript declaration files
69
+
70
+ - [#555](https://github.com/atlassian-labs/atlaspack/pull/555) [`15c1e3c`](https://github.com/atlassian-labs/atlaspack/commit/15c1e3c0628bae4c768d76cf3afc53d6d0d7ce7c) Thanks [@alshdavid](https://github.com/alshdavid)! - Added ATLASPACK_NATIVE_THREADS env variable to control the number of threads used by the native thread schedular
71
+
72
+ - Updated dependencies [[`30f6017`](https://github.com/atlassian-labs/atlaspack/commit/30f60175ba4d272c5fc193973c63bc298584775b), [`3a3e8e7`](https://github.com/atlassian-labs/atlaspack/commit/3a3e8e7be9e2dffd7304436d792f0f595d59665a), [`1ab0a27`](https://github.com/atlassian-labs/atlaspack/commit/1ab0a275aeca40350415e2b03e7440d1dddc6228), [`b8a4ae8`](https://github.com/atlassian-labs/atlaspack/commit/b8a4ae8f83dc0a83d8b145c5f729936ce52080a3)]:
73
+ - @atlaspack/feature-flags@2.15.1
74
+ - @atlaspack/fs@2.15.3
75
+ - @atlaspack/rust@3.3.3
76
+ - @atlaspack/cache@3.2.3
77
+ - @atlaspack/graph@3.4.6
78
+ - @atlaspack/utils@2.14.8
79
+ - @atlaspack/package-manager@2.14.8
80
+ - @atlaspack/logger@2.14.8
81
+ - @atlaspack/profiler@2.14.6
82
+ - @atlaspack/types@2.14.8
83
+ - @atlaspack/workers@2.14.8
84
+ - @atlaspack/plugin@2.14.8
85
+
86
+ ## 2.17.2
87
+
88
+ ### Patch Changes
89
+
90
+ - Updated dependencies [[`a1773d2`](https://github.com/atlassian-labs/atlaspack/commit/a1773d2a62d0ef7805ac7524621dcabcc1afe929), [`556d6ab`](https://github.com/atlassian-labs/atlaspack/commit/556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f)]:
91
+ - @atlaspack/feature-flags@2.15.0
92
+ - @atlaspack/logger@2.14.7
93
+ - @atlaspack/rust@3.3.2
94
+ - @atlaspack/cache@3.2.2
95
+ - @atlaspack/fs@2.15.2
96
+ - @atlaspack/graph@3.4.5
97
+ - @atlaspack/utils@2.14.7
98
+ - @atlaspack/package-manager@2.14.7
99
+ - @atlaspack/workers@2.14.7
100
+ - @atlaspack/profiler@2.14.5
101
+ - @atlaspack/types@2.14.7
102
+ - @atlaspack/plugin@2.14.7
103
+
104
+ ## 2.17.1
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies [[`e0f5337`](https://github.com/atlassian-labs/atlaspack/commit/e0f533757bd1019dbd108a04952c87da15286e09)]:
109
+ - @atlaspack/feature-flags@2.14.4
110
+ - @atlaspack/rust@3.3.1
111
+ - @atlaspack/cache@3.2.1
112
+ - @atlaspack/fs@2.15.1
113
+ - @atlaspack/graph@3.4.4
114
+ - @atlaspack/utils@2.14.6
115
+ - @atlaspack/logger@2.14.6
116
+ - @atlaspack/package-manager@2.14.6
117
+ - @atlaspack/profiler@2.14.4
118
+ - @atlaspack/types@2.14.6
119
+ - @atlaspack/workers@2.14.6
120
+ - @atlaspack/plugin@2.14.6
121
+
122
+ ## 2.17.0
123
+
124
+ ### Minor Changes
125
+
126
+ - [#541](https://github.com/atlassian-labs/atlaspack/pull/541) [`e2ba0f6`](https://github.com/atlassian-labs/atlaspack/commit/e2ba0f69702656f3d1ce95ab1454e35062b13b39) Thanks [@yamadapc](https://github.com/yamadapc)! - Add database compaction debug command
127
+
128
+ ### Patch Changes
129
+
130
+ - [#530](https://github.com/atlassian-labs/atlaspack/pull/530) [`2e90c9b`](https://github.com/atlassian-labs/atlaspack/commit/2e90c9bd07d7eb52645f9d84ccbb7f82685cbc8c) Thanks [@yamadapc](https://github.com/yamadapc)! - Write metadata about the cache in a new entry
131
+
132
+ - [#511](https://github.com/atlassian-labs/atlaspack/pull/511) [`11d6f16`](https://github.com/atlassian-labs/atlaspack/commit/11d6f16b6397dee2f217167e5c98b39edb63f7a7) Thanks [@yamadapc](https://github.com/yamadapc)! - Clean-up dylib worker threads segmentation fault bug fix feature-flag
133
+
134
+ - Updated dependencies [[`11d6f16`](https://github.com/atlassian-labs/atlaspack/commit/11d6f16b6397dee2f217167e5c98b39edb63f7a7), [`e2ba0f6`](https://github.com/atlassian-labs/atlaspack/commit/e2ba0f69702656f3d1ce95ab1454e35062b13b39), [`d2c50c2`](https://github.com/atlassian-labs/atlaspack/commit/d2c50c2c020888b33bb25b8690d9320c2b69e2a6), [`46a90dc`](https://github.com/atlassian-labs/atlaspack/commit/46a90dccd019a26b222c878a92d23acc75dc67c5), [`4c17141`](https://github.com/atlassian-labs/atlaspack/commit/4c1714103dab2aa9039c488f381551d2b65d1d01)]:
135
+ - @atlaspack/feature-flags@2.14.3
136
+ - @atlaspack/rust@3.3.0
137
+ - @atlaspack/cache@3.2.0
138
+ - @atlaspack/fs@2.15.0
139
+ - @atlaspack/graph@3.4.3
140
+ - @atlaspack/utils@2.14.5
141
+ - @atlaspack/logger@2.14.5
142
+ - @atlaspack/package-manager@2.14.5
143
+ - @atlaspack/profiler@2.14.3
144
+ - @atlaspack/types@2.14.5
145
+ - @atlaspack/workers@2.14.5
146
+ - @atlaspack/plugin@2.14.5
147
+
148
+ ## 2.16.1
149
+
150
+ ### Patch Changes
151
+
152
+ - [#525](https://github.com/atlassian-labs/atlaspack/pull/525) [`cb9da16`](https://github.com/atlassian-labs/atlaspack/commit/cb9da16fb2648e7f53c64df0313f60d5fb8970cc) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix issues with large blob cache writes, run cache writes in a write transaction
153
+
154
+ - Updated dependencies [[`1a2c14c`](https://github.com/atlassian-labs/atlaspack/commit/1a2c14c3cd4587551cc12e94d0680c8b71ea12bf), [`cb9da16`](https://github.com/atlassian-labs/atlaspack/commit/cb9da16fb2648e7f53c64df0313f60d5fb8970cc)]:
155
+ - @atlaspack/rust@3.2.0
156
+ - @atlaspack/cache@3.1.0
157
+ - @atlaspack/fs@2.14.4
158
+ - @atlaspack/logger@2.14.4
159
+ - @atlaspack/utils@2.14.4
160
+ - @atlaspack/package-manager@2.14.4
161
+ - @atlaspack/workers@2.14.4
162
+ - @atlaspack/types@2.14.4
163
+ - @atlaspack/plugin@2.14.4
164
+
165
+ ## 2.16.0
166
+
167
+ ### Minor Changes
168
+
169
+ - [#520](https://github.com/atlassian-labs/atlaspack/pull/520) [`90150df`](https://github.com/atlassian-labs/atlaspack/commit/90150dfb68236e1d1c11813108ecabd92cff9366) Thanks [@pancaspe87](https://github.com/pancaspe87)! - Modify "large blobs" to be written to the LMDB cache
170
+
171
+ ### Patch Changes
172
+
173
+ - Updated dependencies [[`f27d39e`](https://github.com/atlassian-labs/atlaspack/commit/f27d39e767b06def059944b3bc5fd50797eaea96)]:
174
+ - @atlaspack/rust@3.1.1
175
+ - @atlaspack/cache@3.0.1
176
+ - @atlaspack/fs@2.14.3
177
+ - @atlaspack/logger@2.14.3
178
+ - @atlaspack/utils@2.14.3
179
+ - @atlaspack/package-manager@2.14.3
180
+ - @atlaspack/workers@2.14.3
181
+ - @atlaspack/types@2.14.3
182
+ - @atlaspack/plugin@2.14.3
183
+
184
+ ## 2.15.1
185
+
186
+ ### Patch Changes
187
+
188
+ - [#512](https://github.com/atlassian-labs/atlaspack/pull/512) [`8f4e6c1`](https://github.com/atlassian-labs/atlaspack/commit/8f4e6c1b0e7c1fd48624afda48c1dcc599f1460f) Thanks [@yamadapc](https://github.com/yamadapc)! - Remove LMDB cache back-end
189
+
190
+ - Updated dependencies [[`9b85d3e`](https://github.com/atlassian-labs/atlaspack/commit/9b85d3e645b10bd027eed2304afc970a5ba40062), [`a891d65`](https://github.com/atlassian-labs/atlaspack/commit/a891d652bc4eb3d757d381adf65c5083f706effc), [`d02eab9`](https://github.com/atlassian-labs/atlaspack/commit/d02eab95eb60bf7457e0869af0b773608592c0e6), [`fb87a90`](https://github.com/atlassian-labs/atlaspack/commit/fb87a901973776b33ca4ce530e9d71669a9bd36d), [`7b9e8cf`](https://github.com/atlassian-labs/atlaspack/commit/7b9e8cf29e01a98e72e46b2b2fb74ccc514f4463), [`17b9579`](https://github.com/atlassian-labs/atlaspack/commit/17b9579484eced0ed8f23e2aba6d23b3c7238c39), [`8f4e6c1`](https://github.com/atlassian-labs/atlaspack/commit/8f4e6c1b0e7c1fd48624afda48c1dcc599f1460f)]:
191
+ - @atlaspack/feature-flags@2.14.2
192
+ - @atlaspack/rust@3.1.0
193
+ - @atlaspack/cache@3.0.0
194
+ - @atlaspack/fs@2.14.2
195
+ - @atlaspack/graph@3.4.2
196
+ - @atlaspack/utils@2.14.2
197
+ - @atlaspack/logger@2.14.2
198
+ - @atlaspack/package-manager@2.14.2
199
+ - @atlaspack/profiler@2.14.2
200
+ - @atlaspack/types@2.14.2
201
+ - @atlaspack/workers@2.14.2
202
+ - @atlaspack/plugin@2.14.2
203
+
3
204
  ## 2.15.0
4
205
 
5
206
  ### Minor Changes
package/lib/AssetGraph.js CHANGED
@@ -46,6 +46,14 @@ function _graph() {
46
46
  }
47
47
  var _Dependency = require("./Dependency");
48
48
  var _projectPath = require("./projectPath");
49
+ var _EnvironmentManager = require("./EnvironmentManager");
50
+ function _featureFlags() {
51
+ const data = require("@atlaspack/feature-flags");
52
+ _featureFlags = function () {
53
+ return data;
54
+ };
55
+ return data;
56
+ }
49
57
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
58
  function nodeFromDep(dep) {
51
59
  return {
@@ -63,7 +71,7 @@ function nodeFromDep(dep) {
63
71
  }
64
72
  function nodeFromAssetGroup(assetGroup) {
65
73
  return {
66
- id: (0, _rust().hashString)((0, _projectPath.fromProjectPathRelative)(assetGroup.filePath) + assetGroup.env.id + String(assetGroup.isSource) + String(assetGroup.sideEffects) + (assetGroup.code ?? '') + ':' + (assetGroup.pipeline ?? '') + ':' + (assetGroup.query ?? '')),
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 ?? '')),
67
75
  type: 'asset_group',
68
76
  value: assetGroup,
69
77
  usedSymbolsDownDirty: true
@@ -130,16 +138,19 @@ class AssetGraph extends _graph().ContentGraph {
130
138
 
131
139
  // Deduplicates Environments by making them referentially equal
132
140
  normalizeEnvironment(input) {
141
+ if ((0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
142
+ return;
143
+ }
133
144
  let {
134
145
  id,
135
146
  context
136
- } = input.env;
147
+ } = (0, _EnvironmentManager.fromEnvironmentId)(input.env);
137
148
  let idAndContext = `${id}-${context}`;
138
149
  let env = this.envCache.get(idAndContext);
139
150
  if (env) {
140
151
  input.env = env;
141
152
  } else {
142
- this.envCache.set(idAndContext, input.env);
153
+ this.envCache.set(idAndContext, (0, _EnvironmentManager.fromEnvironmentId)(input.env));
143
154
  }
144
155
  }
145
156
  setRootConnections({
@@ -199,13 +210,13 @@ class AssetGraph extends _graph().ContentGraph {
199
210
  env: target.env,
200
211
  isEntry: true,
201
212
  needsStableName: true,
202
- symbols: target.env.isLibrary ? new Map([['*', {
213
+ symbols: (0, _EnvironmentManager.fromEnvironmentId)(target.env).isLibrary ? new Map([['*', {
203
214
  local: '*',
204
215
  isWeak: true,
205
216
  loc: null
206
217
  }]]) : undefined
207
218
  }));
208
- if (node.value.env.isLibrary) {
219
+ if ((0, _EnvironmentManager.fromEnvironmentId)(node.value.env).isLibrary) {
209
220
  // in library mode, all of the entry's symbols are "used"
210
221
  node.usedSymbolsDown.add('*');
211
222
  node.usedSymbolsUp.set('*', undefined);
@@ -348,7 +359,7 @@ class AssetGraph extends _graph().ContentGraph {
348
359
  if (this.undeferredDependencies.has(d)) {
349
360
  return false;
350
361
  }
351
- let depIsDeferrable = d.symbols && !(d.env.isLibrary && d.isEntry) && !d.symbols.has('*') && ![...d.symbols.keys()].some(symbol => {
362
+ let depIsDeferrable = d.symbols && !((0, _EnvironmentManager.fromEnvironmentId)(d.env).isLibrary && d.isEntry) && !d.symbols.has('*') && ![...d.symbols.keys()].some(symbol => {
352
363
  var _resolvedAsset$symbol;
353
364
  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;
354
365
  return assetSymbol != null && symbols.has(assetSymbol);
package/lib/Atlaspack.js CHANGED
@@ -166,9 +166,7 @@ class Atlaspack {
166
166
  ...this.#initialOptions.featureFlags
167
167
  };
168
168
  (0, _featureFlags().setFeatureFlags)(featureFlags);
169
- if ((0, _featureFlags().getFeatureFlag)('enableRustWorkerThreadDylibHack')) {
170
- (0, _rustWorkerThreadDylibHack.loadRustWorkerThreadDylibHack)();
171
- }
169
+ (0, _rustWorkerThreadDylibHack.loadRustWorkerThreadDylibHack)();
172
170
  await _sourceMap().init;
173
171
  await (_rust().init === null || _rust().init === void 0 ? void 0 : (0, _rust().init)());
174
172
  this.#disposable = new (_events().Disposable)();
@@ -209,9 +207,15 @@ class Atlaspack {
209
207
  // $FlowFixMe
210
208
  const version = require('../package.json').version;
211
209
  await lmdb.put('current_session_version', Buffer.from(version));
210
+ let threads = undefined;
211
+ if (process.env.ATLASPACK_NATIVE_THREADS !== undefined) {
212
+ threads = parseInt(process.env.ATLASPACK_NATIVE_THREADS, 10);
213
+ } else if (process.env.NODE_ENV === 'test') {
214
+ threads = 2;
215
+ }
212
216
  rustAtlaspack = await _atlaspackV.AtlaspackV3.create({
213
217
  ...options,
214
- threads: process.env.NODE_ENV === 'test' ? 2 : undefined,
218
+ threads,
215
219
  entries: Array.isArray(entries) ? entries : entries == null ? undefined : [entries],
216
220
  env: resolvedOptions.env,
217
221
  fs: inputFS && new _atlaspackV.FileSystemV3(inputFS),
@@ -505,7 +509,9 @@ class Atlaspack {
505
509
  if (this.rustAtlaspack) {
506
510
  nativeInvalid = await this.rustAtlaspack.respondToFsEvents(events);
507
511
  }
508
- let isInvalid = await this.#requestTracker.respondToFSEvents(events, Number.POSITIVE_INFINITY);
512
+ let {
513
+ didInvalidate: isInvalid
514
+ } = await this.#requestTracker.respondToFSEvents(events, Number.POSITIVE_INFINITY);
509
515
  if ((nativeInvalid || isInvalid) && this.#watchQueue.getNumWaiting() === 0) {
510
516
  if (this.#watchAbortController) {
511
517
  this.#watchAbortController.abort();
@@ -602,6 +608,19 @@ class Atlaspack {
602
608
  }
603
609
  return result;
604
610
  }
611
+
612
+ /**
613
+ * Copy the cache to a new directory and compact it.
614
+ */
615
+ async unstable_compactCache() {
616
+ await this._init();
617
+ const cache = (0, _nullthrows().default)(this.#resolvedOptions).cache;
618
+ if (cache instanceof _cache().LMDBLiteCache) {
619
+ await cache.compact('parcel-cache-compacted');
620
+ } else {
621
+ throw new Error('Cache is not an LMDBLiteCache');
622
+ }
623
+ }
605
624
  async unstable_transform(options) {
606
625
  var _options$env;
607
626
  if (!this.#initialized) {
@@ -51,6 +51,7 @@ function _featureFlags() {
51
51
  };
52
52
  return data;
53
53
  }
54
+ var _EnvironmentManager = require("./EnvironmentManager");
54
55
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
55
56
  const bundleGraphEdgeTypes = exports.bundleGraphEdgeTypes = {
56
57
  // A lack of an edge type indicates to follow the edge while traversing
@@ -207,7 +208,7 @@ class BundleGraph {
207
208
  }
208
209
  }
209
210
  }
210
- if (node.type === 'dependency' && node.value.symbols != null && node.value.env.shouldScopeHoist &&
211
+ if (node.type === 'dependency' && node.value.symbols != null && (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).shouldScopeHoist &&
211
212
  // Disable in dev mode because this feature is at odds with safeToIncrementallyBundle
212
213
  isProduction) {
213
214
  let nodeValueSymbols = node.value.symbols;
@@ -862,7 +863,7 @@ class BundleGraph {
862
863
  return;
863
864
  }
864
865
  visitedBundles.add(descendant);
865
- if (descendant.type !== bundle.type || descendant.env.context !== bundle.env.context) {
866
+ if (descendant.type !== bundle.type || (0, _EnvironmentManager.fromEnvironmentId)(descendant.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) {
866
867
  actions.skipChildren();
867
868
  return;
868
869
  }
@@ -890,7 +891,7 @@ class BundleGraph {
890
891
  isAssetReachableFromBundle(asset, bundle) {
891
892
  // If a bundle's environment is isolated, it can't access assets present
892
893
  // in any ancestor bundles. Don't consider any assets reachable.
893
- if (_Environment.ISOLATED_ENVS.has(bundle.env.context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline) {
894
+ if (_Environment.ISOLATED_ENVS.has((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline) {
894
895
  return false;
895
896
  }
896
897
 
@@ -918,7 +919,7 @@ class BundleGraph {
918
919
  let node = (0, _nullthrows().default)(this._graph.getNode(nodeId));
919
920
  // If we've reached the root or a context change without
920
921
  // finding this asset in the ancestry, it is not reachable.
921
- if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || node.value.env.context !== bundle.env.context)) {
922
+ if (node.type === 'root' || node.type === 'bundle' && (node.value.id === bundle.id || (0, _EnvironmentManager.fromEnvironmentId)(node.value.env).context !== (0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context)) {
922
923
  isReachable = false;
923
924
  actions.stop();
924
925
  return;
@@ -1413,7 +1414,7 @@ class BundleGraph {
1413
1414
  for (let referencedBundle of this.getReferencedBundles(bundle)) {
1414
1415
  hash.writeString(referencedBundle.id);
1415
1416
  }
1416
- hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)(bundle.env)));
1417
+ hash.writeString(JSON.stringify((0, _utils().objectSortedEntriesDeep)((0, _EnvironmentManager.fromEnvironmentId)(bundle.env))));
1417
1418
  return hash.finish();
1418
1419
  }
1419
1420
  getBundleGraphHash() {
package/lib/Dependency.js CHANGED
@@ -24,6 +24,7 @@ function _assert() {
24
24
  return data;
25
25
  }
26
26
  var _IdentifierRegistry = require("./IdentifierRegistry");
27
+ var _EnvironmentManager = require("./EnvironmentManager");
27
28
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
29
  function createDependencyId({
29
30
  sourceAssetId,
@@ -41,8 +42,11 @@ function createDependencyId({
41
42
  const params = {
42
43
  sourceAssetId,
43
44
  specifier,
44
- environmentId: env.id,
45
- target,
45
+ environmentId: (0, _EnvironmentManager.toEnvironmentId)(env),
46
+ target: target != null ? {
47
+ ...target,
48
+ env: (0, _EnvironmentManager.fromEnvironmentId)(target.env)
49
+ } : null,
46
50
  pipeline,
47
51
  specifierType: _types.SpecifierType[specifierType],
48
52
  bundleBehavior,
@@ -15,6 +15,7 @@ function _rust() {
15
15
  var _utils = require("./utils");
16
16
  var _Environment = _interopRequireWildcard(require("./public/Environment"));
17
17
  var _IdentifierRegistry = require("./IdentifierRegistry");
18
+ var _EnvironmentManager = require("./EnvironmentManager");
18
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
19
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
20
21
  const DEFAULT_ENGINES = {
@@ -108,15 +109,15 @@ function createEnvironment({
108
109
  loc
109
110
  };
110
111
  res.id = getEnvironmentHash(res);
111
- return Object.freeze(res);
112
+ return (0, _EnvironmentManager.toEnvironmentRef)(Object.freeze(res));
112
113
  }
113
114
  function mergeEnvironments(projectRoot, a, b) {
114
115
  // If merging the same object, avoid copying.
115
116
  if (a === b || !b) {
116
- return a;
117
+ return (0, _EnvironmentManager.toEnvironmentRef)(a);
117
118
  }
118
119
  if (b instanceof _Environment.default) {
119
- return (0, _Environment.environmentToInternalEnvironment)(b);
120
+ return (0, _EnvironmentManager.toEnvironmentRef)((0, _Environment.environmentToInternalEnvironment)(b));
120
121
  }
121
122
 
122
123
  // $FlowFixMe - ignore the `id` that is already on a
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fromEnvironmentId = fromEnvironmentId;
7
+ exports.loadEnvironmentsFromCache = loadEnvironmentsFromCache;
8
+ exports.toEnvironmentId = toEnvironmentId;
9
+ exports.toEnvironmentRef = toEnvironmentRef;
10
+ exports.writeEnvironmentsToCache = writeEnvironmentsToCache;
11
+ function _rust() {
12
+ const data = require("@atlaspack/rust");
13
+ _rust = function () {
14
+ return data;
15
+ };
16
+ return data;
17
+ }
18
+ function _featureFlags() {
19
+ const data = require("@atlaspack/feature-flags");
20
+ _featureFlags = function () {
21
+ return data;
22
+ };
23
+ return data;
24
+ }
25
+ function _logger() {
26
+ const data = require("@atlaspack/logger");
27
+ _logger = function () {
28
+ return data;
29
+ };
30
+ return data;
31
+ }
32
+ var _constants = require("./constants");
33
+ /*!
34
+ * At the moment we're doing this change for `CoreEnvironment`,
35
+ * but the same change must be made for `TypesEnvironment` in @atlaspack/types.
36
+ */
37
+ const localEnvironmentCache = new Map();
38
+
39
+ /**
40
+ * When deduplication is cleaned-up this will always be a string.
41
+ */
42
+
43
+ /**
44
+ * Convert environment to a ref.
45
+ * This is what we should be using to store environments.
46
+ */
47
+ function toEnvironmentRef(env) {
48
+ if (!(0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
49
+ return env;
50
+ }
51
+ const id = toEnvironmentId(env);
52
+ return id;
53
+ }
54
+
55
+ /**
56
+ * Convert environment to a string ID
57
+ */
58
+ function toEnvironmentId(
59
+ /**
60
+ * Redundant type during roll-out
61
+ */
62
+ env) {
63
+ if (!(0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
64
+ return typeof env === 'string' ? env : env.id;
65
+ }
66
+ if (typeof env === 'string') {
67
+ return env;
68
+ }
69
+ (0, _rust().addEnvironment)(env);
70
+ return env.id;
71
+ }
72
+ function fromEnvironmentId(id) {
73
+ if (!(0, _featureFlags().getFeatureFlag)('environmentDeduplication')) {
74
+ if (typeof id === 'string') {
75
+ throw new Error('This should never happen when environmentDeduplication feature-flag is off');
76
+ } else {
77
+ return id;
78
+ }
79
+ }
80
+ if (typeof id !== 'string') {
81
+ return id;
82
+ }
83
+ const localEnv = localEnvironmentCache.get(id);
84
+ if (localEnv) {
85
+ return localEnv;
86
+ }
87
+ const env = Object.freeze((0, _rust().getEnvironment)(id));
88
+ localEnvironmentCache.set(id, env);
89
+ return env;
90
+ }
91
+
92
+ /**
93
+ * Writes all environments and their IDs to the cache
94
+ * @param {Cache} cache
95
+ * @returns {Promise<void>}
96
+ */
97
+ async function writeEnvironmentsToCache(cache) {
98
+ const environments = (0, _rust().getAllEnvironments)();
99
+ const environmentIds = new Set();
100
+
101
+ // Store each environment individually
102
+ for (const env of environments) {
103
+ environmentIds.add(env.id);
104
+ const envKey = `Environment/${_constants.ATLASPACK_VERSION}/${env.id}`;
105
+ await (0, _logger().instrument)(`RequestTracker::writeToCache::cache.put(${envKey})`, async () => {
106
+ await cache.set(envKey, env);
107
+ });
108
+ }
109
+
110
+ // Store the list of environment IDs
111
+ await (0, _logger().instrument)(`RequestTracker::writeToCache::cache.put(${`EnvironmentManager/${_constants.ATLASPACK_VERSION}`})`, async () => {
112
+ await cache.set(`EnvironmentManager/${_constants.ATLASPACK_VERSION}`, Array.from(environmentIds));
113
+ });
114
+ }
115
+
116
+ /**
117
+ * Loads all environments and their IDs from the cache
118
+ * @param {Cache} cache
119
+ * @returns {Promise<void>}
120
+ */
121
+ async function loadEnvironmentsFromCache(cache) {
122
+ const cachedEnvIds = await cache.get(`EnvironmentManager/${_constants.ATLASPACK_VERSION}`);
123
+ if (cachedEnvIds == null) {
124
+ return;
125
+ }
126
+ const environments = [];
127
+ for (const envId of cachedEnvIds) {
128
+ const envKey = `Environment/${_constants.ATLASPACK_VERSION}/${envId}`;
129
+ const cachedEnv = await cache.get(envKey);
130
+ if (cachedEnv != null) {
131
+ environments.push(cachedEnv);
132
+ }
133
+ }
134
+ if (environments.length > 0) {
135
+ (0, _rust().setAllEnvironments)(environments);
136
+ }
137
+ }
@@ -14,6 +14,7 @@ function _rust() {
14
14
  return data;
15
15
  }
16
16
  var _IdentifierRegistry = require("./IdentifierRegistry");
17
+ var _EnvironmentManager = require("./EnvironmentManager");
17
18
  function createConfig({
18
19
  plugin,
19
20
  isSource,
@@ -30,11 +31,11 @@ function createConfig({
30
31
  invalidateOnBuild
31
32
  }) {
32
33
  let environment = env ?? (0, _Environment.createEnvironment)();
33
- const configId = (0, _rust().hashString)(plugin + (0, _projectPath.fromProjectPathRelative)(searchPath) + environment.id + String(isSource));
34
+ const configId = (0, _rust().hashString)(plugin + (0, _projectPath.fromProjectPathRelative)(searchPath) + (0, _EnvironmentManager.toEnvironmentId)(environment) + String(isSource));
34
35
  _IdentifierRegistry.identifierRegistry.addIdentifier('config_request', configId, {
35
36
  plugin,
36
37
  searchPath,
37
- environmentId: environment.id,
38
+ environmentId: (0, _EnvironmentManager.toEnvironmentId)(environment),
38
39
  isSource
39
40
  });
40
41
  return {