@atlaspack/cache 3.1.1-canary.2 → 3.1.1-canary.200

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,298 @@
1
1
  # @atlaspack/cache
2
2
 
3
+ ## 3.2.26
4
+
5
+ ### Patch Changes
6
+
7
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
8
+
9
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922), [`686a398`](https://github.com/atlassian-labs/atlaspack/commit/686a398faa1f9e19cbf9274add2c46e246bafba8)]:
10
+ - @atlaspack/build-cache@2.13.6
11
+ - @atlaspack/feature-flags@2.25.1
12
+ - @atlaspack/fs@2.15.26
13
+ - @atlaspack/logger@2.14.23
14
+ - @atlaspack/rust@3.8.1
15
+ - @atlaspack/utils@2.19.3
16
+
17
+ ## 3.2.25
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [[`7a52bab`](https://github.com/atlassian-labs/atlaspack/commit/7a52bab6281e8edbfa66af248eb6f872c6b4b7bd), [`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`5a0363f`](https://github.com/atlassian-labs/atlaspack/commit/5a0363f1086e81068959b87e92064bed5a11a9b4), [`038e87a`](https://github.com/atlassian-labs/atlaspack/commit/038e87a7858d39556d59d3a2d17db534d45f62c6), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572), [`0684997`](https://github.com/atlassian-labs/atlaspack/commit/0684997c127a6204af1376b36e556fddd1ba5557), [`602f8ed`](https://github.com/atlassian-labs/atlaspack/commit/602f8ed9d8381301df8b2cc82c1d5cf6f2f94fec)]:
22
+ - @atlaspack/feature-flags@2.25.0
23
+ - @atlaspack/rust@3.8.0
24
+ - @atlaspack/fs@2.15.25
25
+ - @atlaspack/utils@2.19.2
26
+ - @atlaspack/logger@2.14.22
27
+
28
+ ## 3.2.24
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [[`830261d`](https://github.com/atlassian-labs/atlaspack/commit/830261dcf4a40293090b61cab52fd75d5683c73f), [`53dd47b`](https://github.com/atlassian-labs/atlaspack/commit/53dd47bd6d23cd47f87297347f03a609ab38a03d)]:
33
+ - @atlaspack/feature-flags@2.24.1
34
+ - @atlaspack/rust@3.7.0
35
+ - @atlaspack/fs@2.15.24
36
+ - @atlaspack/utils@2.19.1
37
+ - @atlaspack/logger@2.14.21
38
+
39
+ ## 3.2.23
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767), [`a5081c3`](https://github.com/atlassian-labs/atlaspack/commit/a5081c3f9207d28716ee4edd3841de1830ea4b80), [`f930003`](https://github.com/atlassian-labs/atlaspack/commit/f930003364fdc31e5487520ebe256f1a9389f579), [`f930003`](https://github.com/atlassian-labs/atlaspack/commit/f930003364fdc31e5487520ebe256f1a9389f579), [`8843980`](https://github.com/atlassian-labs/atlaspack/commit/88439807be20025fd3433380204ff1205079729e)]:
44
+ - @atlaspack/feature-flags@2.24.0
45
+ - @atlaspack/utils@2.19.0
46
+ - @atlaspack/fs@2.15.23
47
+ - @atlaspack/logger@2.14.20
48
+
49
+ ## 3.2.22
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies [[`3cfb7cf`](https://github.com/atlassian-labs/atlaspack/commit/3cfb7cfd90b78a5c48ce717e779ff789769825a3)]:
54
+ - @atlaspack/feature-flags@2.23.2
55
+ - @atlaspack/rust@3.6.2
56
+ - @atlaspack/fs@2.15.22
57
+ - @atlaspack/utils@2.18.4
58
+ - @atlaspack/logger@2.14.19
59
+
60
+ ## 3.2.21
61
+
62
+ ### Patch Changes
63
+
64
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
65
+
66
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
67
+ - @atlaspack/feature-flags@2.23.1
68
+ - @atlaspack/build-cache@2.13.5
69
+ - @atlaspack/logger@2.14.18
70
+ - @atlaspack/utils@2.18.3
71
+ - @atlaspack/rust@3.6.1
72
+ - @atlaspack/fs@2.15.21
73
+
74
+ ## 3.2.20
75
+
76
+ ### Patch Changes
77
+
78
+ - Updated dependencies [[`f6b3f22`](https://github.com/atlassian-labs/atlaspack/commit/f6b3f2276c7e417580b49c4879563aab51f156b1)]:
79
+ - @atlaspack/feature-flags@2.23.0
80
+ - @atlaspack/fs@2.15.20
81
+ - @atlaspack/utils@2.18.2
82
+ - @atlaspack/logger@2.14.17
83
+
84
+ ## 3.2.19
85
+
86
+ ### Patch Changes
87
+
88
+ - Updated dependencies [[`ad26146`](https://github.com/atlassian-labs/atlaspack/commit/ad26146f13b4c1cc65d4a0f9c67060b90ef14ff3), [`f1b48e7`](https://github.com/atlassian-labs/atlaspack/commit/f1b48e7a04e005cef0f36a3e692087a9ecdb6f7a), [`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45), [`73dd7ba`](https://github.com/atlassian-labs/atlaspack/commit/73dd7baab69456ef2f6e4a0cc7dbb04f407eb148)]:
89
+ - @atlaspack/rust@3.6.0
90
+ - @atlaspack/feature-flags@2.22.0
91
+ - @atlaspack/fs@2.15.19
92
+ - @atlaspack/logger@2.14.16
93
+ - @atlaspack/utils@2.18.1
94
+
95
+ ## 3.2.18
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
100
+ - @atlaspack/feature-flags@2.21.0
101
+ - @atlaspack/utils@2.18.0
102
+ - @atlaspack/rust@3.5.0
103
+ - @atlaspack/fs@2.15.18
104
+ - @atlaspack/logger@2.14.15
105
+
106
+ ## 3.2.17
107
+
108
+ ### Patch Changes
109
+
110
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
111
+
112
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94), [`12bee0e`](https://github.com/atlassian-labs/atlaspack/commit/12bee0e23f0464d7f6bd3e24fbe0d19c126d587d)]:
113
+ - @atlaspack/feature-flags@2.20.1
114
+ - @atlaspack/build-cache@2.13.4
115
+ - @atlaspack/logger@2.14.14
116
+ - @atlaspack/utils@2.17.4
117
+ - @atlaspack/rust@3.4.2
118
+ - @atlaspack/fs@2.15.17
119
+
120
+ ## 3.2.16
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
125
+ - @atlaspack/feature-flags@2.20.0
126
+ - @atlaspack/fs@2.15.16
127
+ - @atlaspack/utils@2.17.3
128
+
129
+ ## 3.2.15
130
+
131
+ ### Patch Changes
132
+
133
+ - Updated dependencies [[`1c7865a`](https://github.com/atlassian-labs/atlaspack/commit/1c7865a64451116d94015e248302435839d347c0), [`a0b959f`](https://github.com/atlassian-labs/atlaspack/commit/a0b959fbf61fc3f820ff03c7e8988945fe40a91a)]:
134
+ - @atlaspack/feature-flags@2.19.2
135
+ - @atlaspack/fs@2.15.15
136
+ - @atlaspack/utils@2.17.2
137
+
138
+ ## 3.2.14
139
+
140
+ ### Patch Changes
141
+
142
+ - Updated dependencies [[`13aef17`](https://github.com/atlassian-labs/atlaspack/commit/13aef177eea289a6e40d2113b5ec1ac9be18a33d)]:
143
+ - @atlaspack/feature-flags@2.19.1
144
+ - @atlaspack/fs@2.15.14
145
+ - @atlaspack/utils@2.17.1
146
+
147
+ ## 3.2.13
148
+
149
+ ### Patch Changes
150
+
151
+ - [#697](https://github.com/atlassian-labs/atlaspack/pull/697) [`c9631af`](https://github.com/atlassian-labs/atlaspack/commit/c9631aff284b2c1c27e8a52f9da392ce65d666e8) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix bug where cache large blob operations were not atomic
152
+
153
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`becf977`](https://github.com/atlassian-labs/atlaspack/commit/becf977f625d5ee46dae3d4c679f173bf5f40cc0), [`becf977`](https://github.com/atlassian-labs/atlaspack/commit/becf977f625d5ee46dae3d4c679f173bf5f40cc0), [`c4415a4`](https://github.com/atlassian-labs/atlaspack/commit/c4415a455543d984ca28452c2cb87a794d22497c), [`f0f7c71`](https://github.com/atlassian-labs/atlaspack/commit/f0f7c7168a1d3d18c6f30d2daed611275692b7c5), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
154
+ - @atlaspack/feature-flags@2.19.0
155
+ - @atlaspack/utils@2.17.0
156
+ - @atlaspack/rust@3.4.1
157
+ - @atlaspack/fs@2.15.13
158
+ - @atlaspack/logger@2.14.13
159
+
160
+ ## 3.2.12
161
+
162
+ ### Patch Changes
163
+
164
+ - Updated dependencies [[`c75bf55`](https://github.com/atlassian-labs/atlaspack/commit/c75bf553fff4decc285b5fd499a275853b18f8f2)]:
165
+ - @atlaspack/rust@3.4.0
166
+ - @atlaspack/fs@2.15.12
167
+ - @atlaspack/logger@2.14.12
168
+ - @atlaspack/utils@2.16.1
169
+
170
+ ## 3.2.11
171
+
172
+ ### Patch Changes
173
+
174
+ - Updated dependencies [[`e8a60ff`](https://github.com/atlassian-labs/atlaspack/commit/e8a60ffbea41caef265786bbf73349771760081c), [`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
175
+ - @atlaspack/feature-flags@2.18.4
176
+ - @atlaspack/utils@2.16.0
177
+ - @atlaspack/fs@2.15.11
178
+
179
+ ## 3.2.10
180
+
181
+ ### Patch Changes
182
+
183
+ - Updated dependencies [[`5ded263`](https://github.com/atlassian-labs/atlaspack/commit/5ded263c7f11b866e8885b81c73e20dd060b25be)]:
184
+ - @atlaspack/feature-flags@2.18.3
185
+ - @atlaspack/fs@2.15.10
186
+ - @atlaspack/utils@2.15.3
187
+
188
+ ## 3.2.9
189
+
190
+ ### Patch Changes
191
+
192
+ - Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
193
+ - @atlaspack/feature-flags@2.18.2
194
+ - @atlaspack/fs@2.15.9
195
+ - @atlaspack/utils@2.15.2
196
+
197
+ ## 3.2.8
198
+
199
+ ### Patch Changes
200
+
201
+ - Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb), [`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
202
+ - @atlaspack/logger@2.14.11
203
+ - @atlaspack/feature-flags@2.18.1
204
+ - @atlaspack/fs@2.15.8
205
+ - @atlaspack/utils@2.15.1
206
+
207
+ ## 3.2.7
208
+
209
+ ### Patch Changes
210
+
211
+ - Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2), [`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
212
+ - @atlaspack/feature-flags@2.18.0
213
+ - @atlaspack/utils@2.15.0
214
+ - @atlaspack/fs@2.15.7
215
+
216
+ ## 3.2.6
217
+
218
+ ### Patch Changes
219
+
220
+ - Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
221
+ - @atlaspack/feature-flags@2.17.0
222
+ - @atlaspack/fs@2.15.6
223
+ - @atlaspack/utils@2.14.11
224
+
225
+ ## 3.2.5
226
+
227
+ ### Patch Changes
228
+
229
+ - Updated dependencies [[`0999fb7`](https://github.com/atlassian-labs/atlaspack/commit/0999fb78da519a6c7582d212883e515fcf6c1252), [`35fdd4b`](https://github.com/atlassian-labs/atlaspack/commit/35fdd4b52da0af20f74667f7b8adfb2f90279b7c), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
230
+ - @atlaspack/fs@2.15.5
231
+ - @atlaspack/rust@3.3.5
232
+ - @atlaspack/logger@2.14.10
233
+ - @atlaspack/utils@2.14.10
234
+
235
+ ## 3.2.4
236
+
237
+ ### Patch Changes
238
+
239
+ - [#583](https://github.com/atlassian-labs/atlaspack/pull/583) [`124b7ff`](https://github.com/atlassian-labs/atlaspack/commit/124b7fff44f71aac9fbad289a9a9509b3dfc9aaa) Thanks [@yamadapc](https://github.com/yamadapc)! - Fix problem where cache writes could start to fail during a V3 build
240
+
241
+ - 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)]:
242
+ - @atlaspack/rust@3.3.4
243
+ - @atlaspack/fs@2.15.4
244
+ - @atlaspack/feature-flags@2.16.0
245
+ - @atlaspack/logger@2.14.9
246
+ - @atlaspack/utils@2.14.9
247
+
248
+ ## 3.2.3
249
+
250
+ ### Patch Changes
251
+
252
+ - 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)]:
253
+ - @atlaspack/feature-flags@2.15.1
254
+ - @atlaspack/fs@2.15.3
255
+ - @atlaspack/rust@3.3.3
256
+ - @atlaspack/utils@2.14.8
257
+ - @atlaspack/logger@2.14.8
258
+
259
+ ## 3.2.2
260
+
261
+ ### Patch Changes
262
+
263
+ - Updated dependencies [[`a1773d2`](https://github.com/atlassian-labs/atlaspack/commit/a1773d2a62d0ef7805ac7524621dcabcc1afe929), [`556d6ab`](https://github.com/atlassian-labs/atlaspack/commit/556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f)]:
264
+ - @atlaspack/feature-flags@2.15.0
265
+ - @atlaspack/logger@2.14.7
266
+ - @atlaspack/rust@3.3.2
267
+ - @atlaspack/fs@2.15.2
268
+ - @atlaspack/utils@2.14.7
269
+
270
+ ## 3.2.1
271
+
272
+ ### Patch Changes
273
+
274
+ - Updated dependencies [[`e0f5337`](https://github.com/atlassian-labs/atlaspack/commit/e0f533757bd1019dbd108a04952c87da15286e09)]:
275
+ - @atlaspack/feature-flags@2.14.4
276
+ - @atlaspack/rust@3.3.1
277
+ - @atlaspack/fs@2.15.1
278
+ - @atlaspack/utils@2.14.6
279
+ - @atlaspack/logger@2.14.6
280
+
281
+ ## 3.2.0
282
+
283
+ ### Minor Changes
284
+
285
+ - [#531](https://github.com/atlassian-labs/atlaspack/pull/531) [`d2c50c2`](https://github.com/atlassian-labs/atlaspack/commit/d2c50c2c020888b33bb25b8690d9320c2b69e2a6) Thanks [@yamadapc](https://github.com/yamadapc)! - Add way to iterate LMDB cache keys
286
+
287
+ ### Patch Changes
288
+
289
+ - 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)]:
290
+ - @atlaspack/feature-flags@2.14.3
291
+ - @atlaspack/rust@3.3.0
292
+ - @atlaspack/fs@2.15.0
293
+ - @atlaspack/utils@2.14.5
294
+ - @atlaspack/logger@2.14.5
295
+
3
296
  ## 3.1.0
4
297
 
5
298
  ### Minor Changes
package/lib/FSCache.js CHANGED
@@ -25,6 +25,20 @@ function _util() {
25
25
  };
26
26
  return data;
27
27
  }
28
+ function _rust() {
29
+ const data = require("@atlaspack/rust");
30
+ _rust = function () {
31
+ return data;
32
+ };
33
+ return data;
34
+ }
35
+ function _featureFlags() {
36
+ const data = require("@atlaspack/feature-flags");
37
+ _featureFlags = function () {
38
+ return data;
39
+ };
40
+ return data;
41
+ }
28
42
  function _logger() {
29
43
  const data = _interopRequireDefault(require("@atlaspack/logger"));
30
44
  _logger = function () {
@@ -43,6 +57,7 @@ var _package = _interopRequireDefault(require("../package.json"));
43
57
  var _constants = require("./constants");
44
58
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
45
59
  // flowlint-next-line untyped-import:off
60
+
46
61
  const pipeline = (0, _util().promisify)(_stream().default.pipeline);
47
62
  class FSCache {
48
63
  constructor(fs, cacheDir) {
@@ -57,11 +72,17 @@ class FSCache {
57
72
  // This speeds up large caches on many file systems since there are fewer files in a single directory.
58
73
  let dirPromises = [];
59
74
  for (let i = 0; i < 256; i++) {
60
- dirPromises.push(this.fs.mkdirp(_path().default.join(this.dir, ('00' + i.toString(16)).slice(-2))));
75
+ dirPromises.push(
76
+ // @ts-expect-error TS2345
77
+ this.fs.mkdirp(_path().default.join(this.dir, ('00' + i.toString(16)).slice(-2))));
61
78
  }
62
79
  await Promise.all(dirPromises);
63
80
  }
64
81
  _getCachePath(cacheId) {
82
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
83
+ const cleanId = (0, _rust().hashString)(cacheId);
84
+ return _path().default.join(this.dir, cleanId.slice(0, 2), cleanId.slice(2));
85
+ }
65
86
  return _path().default.join(this.dir, cacheId.slice(0, 2), cacheId.slice(2));
66
87
  }
67
88
  getStream(key) {
@@ -91,6 +112,9 @@ class FSCache {
91
112
  }
92
113
  }
93
114
  #getFilePath(key, index) {
115
+ if ((0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
116
+ return _path().default.join(this.dir, `${(0, _rust().hashString)(key)}-${index}`);
117
+ }
94
118
  return _path().default.join(this.dir, `${key}-${index}`);
95
119
  }
96
120
  async #unlinkChunks(key, index) {
@@ -117,12 +141,19 @@ class FSCache {
117
141
  const writePromises = [];
118
142
  if (chunks === 1) {
119
143
  // If there's one chunk, don't slice the content
120
- writePromises.push(this.fs.writeFile(this.#getFilePath(key, 0), contents, {
144
+ writePromises.push(
145
+ // @ts-expect-error TS2345
146
+ this.fs.writeFile(this.#getFilePath(key, 0), contents, {
147
+ // @ts-expect-error TS2353
121
148
  signal: options === null || options === void 0 ? void 0 : options.signal
122
149
  }));
123
150
  } else {
124
151
  for (let i = 0; i < chunks; i += 1) {
125
- writePromises.push(this.fs.writeFile(this.#getFilePath(key, i), typeof contents === 'string' ? contents.slice(i * _constants.WRITE_LIMIT_CHUNK, (i + 1) * _constants.WRITE_LIMIT_CHUNK) : contents.subarray(i * _constants.WRITE_LIMIT_CHUNK, (i + 1) * _constants.WRITE_LIMIT_CHUNK), {
152
+ writePromises.push(
153
+ // @ts-expect-error TS2345
154
+ this.fs.writeFile(this.#getFilePath(key, i), typeof contents === 'string' ? contents.slice(i * _constants.WRITE_LIMIT_CHUNK, (i + 1) * _constants.WRITE_LIMIT_CHUNK) : contents.subarray(i * _constants.WRITE_LIMIT_CHUNK, (i + 1) * _constants.WRITE_LIMIT_CHUNK),
155
+ // @ts-expect-error TS2353
156
+ {
126
157
  signal: options === null || options === void 0 ? void 0 : options.signal
127
158
  }));
128
159
  }
@@ -137,6 +168,7 @@ class FSCache {
137
168
  let i = 0;
138
169
  let filePath = this.#getFilePath(key, i);
139
170
  while (await this.fs.exists(filePath)) {
171
+ // @ts-expect-error TS2345
140
172
  deletePromises.push(this.fs.rimraf(filePath));
141
173
  i += 1;
142
174
  filePath = this.#getFilePath(key, i);
@@ -34,12 +34,8 @@ function _idb() {
34
34
  }
35
35
  var _package = _interopRequireDefault(require("../package.json"));
36
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
- // $FlowFixMe[untyped-import]
38
- // $FlowFixMe[untyped-import]
39
37
  const STORE_NAME = 'cache';
40
38
  class IDBCache {
41
- // $FlowFixMe
42
-
43
39
  constructor() {
44
40
  this.store = (0, _idb().openDB)('REPL-parcel-cache', 1, {
45
41
  upgrade(db) {
@@ -75,9 +71,14 @@ class IDBCache {
75
71
  await (await this.store).put(STORE_NAME, (0, _buildCache().serialize)(value), key);
76
72
  }
77
73
  getStream(key) {
78
- let dataPromise = this.store.then(s => s.get(STORE_NAME, key)).then(d => Buffer.from(d)).catch(e => e);
74
+ let dataPromise = this.store
75
+ // @ts-expect-error TS7006
76
+ .then(s => s.get(STORE_NAME, key))
77
+ // @ts-expect-error TS7006
78
+ .then(d => Buffer.from(d))
79
+ // @ts-expect-error TS7006
80
+ .catch(e => e);
79
81
  const stream = new (_stream().Readable)({
80
- // $FlowFixMe(incompatible-call)
81
82
  async read() {
82
83
  let data = await dataPromise;
83
84
  if (data instanceof Error) {
package/lib/IDBCache.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.IDBCache = void 0;
7
- // $FlowFixMe
7
+ // @ts-expect-error TS2420
8
8
  class IDBCache {
9
9
  constructor() {
10
10
  throw new Error('IDBCache is only supported in the browser');
@@ -26,6 +26,20 @@ function _rust() {
26
26
  };
27
27
  return data;
28
28
  }
29
+ function _ncp() {
30
+ const data = _interopRequireDefault(require("ncp"));
31
+ _ncp = function () {
32
+ return data;
33
+ };
34
+ return data;
35
+ }
36
+ function _util() {
37
+ const data = require("util");
38
+ _util = function () {
39
+ return data;
40
+ };
41
+ return data;
42
+ }
29
43
  function _stream() {
30
44
  const data = _interopRequireDefault(require("stream"));
31
45
  _stream = function () {
@@ -40,13 +54,6 @@ function _path() {
40
54
  };
41
55
  return data;
42
56
  }
43
- function _util() {
44
- const data = require("util");
45
- _util = function () {
46
- return data;
47
- };
48
- return data;
49
- }
50
57
  function _fs() {
51
58
  const data = require("@atlaspack/fs");
52
59
  _fs = function () {
@@ -56,16 +63,20 @@ function _fs() {
56
63
  }
57
64
  var _package = _interopRequireDefault(require("../package.json"));
58
65
  var _FSCache = require("./FSCache");
66
+ function _logger() {
67
+ const data = require("@atlaspack/logger");
68
+ _logger = function () {
69
+ return data;
70
+ };
71
+ return data;
72
+ }
59
73
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
60
- // $FlowFixMe
74
+ // @ts-expect-error TS7016
75
+
76
+ const ncpAsync = (0, _util().promisify)(_ncp().default);
61
77
  class LmdbWrapper {
62
78
  constructor(lmdb) {
63
79
  this.lmdb = lmdb;
64
-
65
- // $FlowFixMe
66
- this[Symbol.dispose] = () => {
67
- this.lmdb.close();
68
- };
69
80
  }
70
81
  has(key) {
71
82
  return this.lmdb.hasSync(key);
@@ -80,23 +91,40 @@ class LmdbWrapper {
80
91
  const buffer = typeof value === 'string' ? Buffer.from(value) : value;
81
92
  await this.lmdb.put(key, buffer);
82
93
  }
83
- resetReadTxn() {}
94
+ *keys() {
95
+ const PAGE_SIZE = 10000000;
96
+ let currentKeys = this.lmdb.keysSync(0, PAGE_SIZE);
97
+ while (currentKeys.length > 0) {
98
+ for (const key of currentKeys) {
99
+ yield key;
100
+ }
101
+ currentKeys = this.lmdb.keysSync(currentKeys.length, PAGE_SIZE);
102
+ }
103
+ }
104
+ compact(targetPath) {
105
+ this.lmdb.compact(targetPath);
106
+ }
84
107
  }
85
108
  exports.LmdbWrapper = LmdbWrapper;
86
- function open(directory
109
+ function open(directory,
87
110
  // eslint-disable-next-line no-unused-vars
88
- ) {
111
+ openOptions) {
89
112
  return new LmdbWrapper(new (_rust().Lmdb)({
90
113
  path: directory,
91
114
  asyncWrites: true,
92
- mapSize: 1024 * 1024 * 1024 * 15
115
+ mapSize: process.env.ATLASPACK_BUILD_ENV === 'test' ? 1024 * 1024 * 1024 : 1024 * 1024 * 1024 * 15
93
116
  }));
94
117
  }
95
118
  const pipeline = (0, _util().promisify)(_stream().default.pipeline);
96
119
  class LMDBLiteCache {
120
+ /**
121
+ * Directory where we store raw files.
122
+ */
123
+
97
124
  constructor(cacheDir) {
98
125
  this.fs = new (_fs().NodeFS)();
99
126
  this.dir = cacheDir;
127
+ this.cacheFilesDirectory = _path().default.join(cacheDir, 'files');
100
128
  this.fsCache = new _FSCache.FSCache(this.fs, cacheDir);
101
129
  this.store = open(cacheDir, {
102
130
  name: 'parcel-cache',
@@ -115,6 +143,7 @@ class LMDBLiteCache {
115
143
  if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
116
144
  await this.fsCache.ensure();
117
145
  }
146
+ await this.fs.mkdirp(this.cacheFilesDirectory);
118
147
  return Promise.resolve();
119
148
  }
120
149
  serialize() {
@@ -139,10 +168,18 @@ class LMDBLiteCache {
139
168
  await this.setBlob(key, (0, _buildCache().serialize)(value));
140
169
  }
141
170
  getStream(key) {
142
- return this.fs.createReadStream(_path().default.join(this.dir, key));
171
+ if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
172
+ return this.fs.createReadStream(_path().default.join(this.dir, key));
173
+ }
174
+ return this.fs.createReadStream(this.getFileKey(key));
143
175
  }
144
- setStream(key, stream) {
145
- return pipeline(stream, this.fs.createWriteStream(_path().default.join(this.dir, key)));
176
+ async setStream(key, stream) {
177
+ if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
178
+ return pipeline(stream, this.fs.createWriteStream(_path().default.join(this.dir, key)));
179
+ }
180
+ const filePath = this.getFileKey(key);
181
+ await this.fs.mkdirp(_path().default.dirname(filePath));
182
+ return pipeline(stream, this.fs.createWriteStream(filePath));
146
183
  }
147
184
 
148
185
  // eslint-disable-next-line require-await
@@ -162,34 +199,25 @@ class LMDBLiteCache {
162
199
  getBuffer(key) {
163
200
  return Promise.resolve(this.store.get(key));
164
201
  }
165
- #getFilePath(key, index) {
166
- return _path().default.join(this.dir, `${key}-${index}`);
167
- }
168
202
  hasLargeBlob(key) {
169
203
  if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
170
204
  return this.fsCache.hasLargeBlob(key);
171
205
  }
172
- return this.has(key);
206
+ return this.fs.exists(this.getFileKey(key));
173
207
  }
174
-
175
- /**
176
- * @deprecated Use getBlob instead.
177
- */
178
208
  getLargeBlob(key) {
179
209
  if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
180
210
  return this.fsCache.getLargeBlob(key);
181
211
  }
182
- return Promise.resolve(this.getBlobSync(key));
212
+ return this.fs.readFile(this.getFileKey(key));
183
213
  }
184
-
185
- /**
186
- * @deprecated Use setBlob instead.
187
- */
188
- setLargeBlob(key, contents, options) {
214
+ async setLargeBlob(key, contents, options) {
189
215
  if (!(0, _featureFlags().getFeatureFlag)('cachePerformanceImprovements')) {
190
216
  return this.fsCache.setLargeBlob(key, contents, options);
191
217
  }
192
- return this.setBlob(key, contents);
218
+ const targetPath = this.getFileKey(key);
219
+ await this.fs.mkdirp(_path().default.dirname(targetPath));
220
+ return this.fs.writeFile(targetPath, contents);
193
221
  }
194
222
 
195
223
  /**
@@ -201,12 +229,53 @@ class LMDBLiteCache {
201
229
  }
202
230
  return this.store.delete(key);
203
231
  }
204
- refresh() {
205
- // Reset the read transaction for the store. This guarantees that
206
- // the next read will see the latest changes to the store.
207
- // Useful in scenarios where reads and writes are multi-threaded.
208
- // See https://github.com/kriszyp/lmdb-js#resetreadtxn-void
209
- this.store.resetReadTxn();
232
+ keys() {
233
+ return this.store.keys();
234
+ }
235
+ async compact(targetPath) {
236
+ await this.fs.mkdirp(targetPath);
237
+ const files = await this.fs.readdir(this.dir);
238
+ // copy all files except data.mdb and lock.mdb to the target path (recursive)
239
+ for (const file of files) {
240
+ const filePath = _path().default.join(this.dir, file);
241
+ if (file === 'data.mdb' || file === 'lock.mdb') {
242
+ continue;
243
+ }
244
+ await ncpAsync(filePath, _path().default.join(targetPath, file));
245
+ }
246
+ this.store.compact(_path().default.join(targetPath, 'data.mdb'));
247
+ }
248
+ refresh() {}
249
+
250
+ /**
251
+ * Streams, packages are stored in files instead of LMDB.
252
+ *
253
+ * On this case, if a cache key happens to have a parent traversal, ../..
254
+ * it is treated specially
255
+ *
256
+ * That is, something/../something and something are meant to be different
257
+ * keys.
258
+ *
259
+ * Plus we do not want to store values outside of the cache directory.
260
+ */
261
+ getFileKey(key) {
262
+ const cleanKey = key.split('/').map(part => {
263
+ if (part === '..') {
264
+ return '$$__parent_dir$$';
265
+ }
266
+ return part;
267
+ }).join('/');
268
+ return _path().default.join(this.cacheFilesDirectory, cleanKey);
269
+ }
270
+ async clear() {
271
+ await (0, _logger().instrumentAsync)('LMDBLiteCache::clear', async () => {
272
+ const keys = await this.keys();
273
+ for (const key of keys) {
274
+ await this.store.delete(key);
275
+ }
276
+ await this.fs.rimraf(this.cacheFilesDirectory);
277
+ await this.fs.mkdirp(this.cacheFilesDirectory);
278
+ });
210
279
  }
211
280
  }
212
281
  exports.LMDBLiteCache = LMDBLiteCache;