@rspack/core 1.0.14 → 1.1.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 (46) hide show
  1. package/compiled/@swc/types/index.d.ts +1962 -0
  2. package/compiled/@swc/types/index.js +19 -0
  3. package/compiled/@swc/types/license +201 -0
  4. package/compiled/@swc/types/package.json +1 -0
  5. package/compiled/enhanced-resolve/CachedInputFileSystem.js +267 -80
  6. package/compiled/enhanced-resolve/index.d.ts +849 -236
  7. package/compiled/enhanced-resolve/package.json +1 -1
  8. package/compiled/graceful-fs/index.js +10 -10
  9. package/compiled/graceful-fs/package.json +1 -1
  10. package/compiled/zod/index.d.ts +2 -2
  11. package/dist/Compilation.d.ts +7 -18
  12. package/dist/DependenciesBlock.d.ts +6 -4
  13. package/dist/FileSystem.d.ts +7 -2
  14. package/dist/Module.d.ts +17 -14
  15. package/dist/builtin-loader/swc/types.d.ts +9 -435
  16. package/dist/builtin-plugin/EntryPlugin.d.ts +14 -11
  17. package/dist/builtin-plugin/FlagDependencyUsagePlugin.d.ts +10 -10
  18. package/dist/builtin-plugin/HtmlRspackPlugin.d.ts +1 -1
  19. package/dist/builtin-plugin/MangleExportsPlugin.d.ts +10 -10
  20. package/dist/builtin-plugin/ModuleConcatenationPlugin.d.ts +8 -10
  21. package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +10 -0
  22. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +8 -8
  23. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/index.d.ts +4 -2
  25. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +3 -3
  26. package/dist/builtin-plugin/lazy-compilation/plugin.d.ts +3 -3
  27. package/dist/config/adapter.d.ts +1 -1
  28. package/dist/config/adapterRuleUse.d.ts +1 -1
  29. package/dist/config/index.d.ts +1 -0
  30. package/dist/config/normalization.d.ts +4 -11
  31. package/dist/config/types.d.ts +417 -9
  32. package/dist/config/zod.d.ts +1044 -1303
  33. package/dist/exports.d.ts +4 -2
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.js +1023 -5103
  36. package/dist/util/ArrayQueue.d.ts +1 -9
  37. package/dist/util/asyncLib.d.ts +54 -0
  38. package/package.json +9 -9
  39. package/dist/builtin-loader/swc/react.d.ts +0 -15
  40. package/dist/lib/Dependency.d.ts +0 -23
  41. package/dist/lib/formatLocation.d.ts +0 -16
  42. package/dist/logging/runtime.d.ts +0 -16
  43. package/dist/util/IterableHelpers.d.ts +0 -12
  44. package/dist/util/scheme.d.ts +0 -6
  45. package/dist/util/webpack.d.ts +0 -4
  46. /package/dist/builtin-plugin/{LightningCssMiminizerRspackPlugin.d.ts → LightningCssMinimizerRspackPlugin.d.ts} +0 -0
@@ -8,8 +8,20 @@
8
8
  const nextTick = require("process").nextTick;
9
9
 
10
10
  /** @typedef {import("./Resolver").FileSystem} FileSystem */
11
+ /** @typedef {import("./Resolver").PathLike} PathLike */
12
+ /** @typedef {import("./Resolver").PathOrFileDescriptor} PathOrFileDescriptor */
11
13
  /** @typedef {import("./Resolver").SyncFileSystem} SyncFileSystem */
14
+ /** @typedef {FileSystem & SyncFileSystem} BaseFileSystem */
12
15
 
16
+ /**
17
+ * @template T
18
+ * @typedef {import("./Resolver").FileSystemCallback<T>} FileSystemCallback<T>
19
+ */
20
+
21
+ /**
22
+ * @param {string} path path
23
+ * @returns {string} dirname
24
+ */
13
25
  const dirname = path => {
14
26
  let idx = path.length - 1;
15
27
  while (idx >= 0) {
@@ -22,6 +34,12 @@ const dirname = path => {
22
34
  return path.slice(0, idx);
23
35
  };
24
36
 
37
+ /**
38
+ * @template T
39
+ * @param {FileSystemCallback<T>[]} callbacks callbacks
40
+ * @param {Error | null} err error
41
+ * @param {T} result result
42
+ */
25
43
  const runCallbacks = (callbacks, err, result) => {
26
44
  if (callbacks.length === 1) {
27
45
  callbacks[0](err, result);
@@ -42,9 +60,9 @@ const runCallbacks = (callbacks, err, result) => {
42
60
 
43
61
  class OperationMergerBackend {
44
62
  /**
45
- * @param {any} provider async method
46
- * @param {any} syncProvider sync method
47
- * @param {any} providerContext call context for the provider methods
63
+ * @param {Function | undefined} provider async method in filesystem
64
+ * @param {Function | undefined} syncProvider sync method in filesystem
65
+ * @param {BaseFileSystem} providerContext call context for the provider methods
48
66
  */
49
67
  constructor(provider, syncProvider, providerContext) {
50
68
  this._provider = provider;
@@ -53,38 +71,69 @@ class OperationMergerBackend {
53
71
  this._activeAsyncOperations = new Map();
54
72
 
55
73
  this.provide = this._provider
56
- ? (path, options, callback) => {
74
+ ? /**
75
+ * @param {PathLike | PathOrFileDescriptor} path path
76
+ * @param {object | FileSystemCallback<any> | undefined} options options
77
+ * @param {FileSystemCallback<any>=} callback callback
78
+ * @returns {any} result
79
+ */
80
+ (path, options, callback) => {
57
81
  if (typeof options === "function") {
58
- callback = options;
82
+ callback = /** @type {FileSystemCallback<any>} */ (options);
59
83
  options = undefined;
60
84
  }
85
+ if (
86
+ typeof path !== "string" &&
87
+ !Buffer.isBuffer(path) &&
88
+ !(path instanceof URL) &&
89
+ typeof path !== "number"
90
+ ) {
91
+ /** @type {Function} */
92
+ (callback)(
93
+ new TypeError("path must be a string, Buffer, URL or number")
94
+ );
95
+ return;
96
+ }
61
97
  if (options) {
62
- return this._provider.call(
98
+ return /** @type {Function} */ (this._provider).call(
63
99
  this._providerContext,
64
100
  path,
65
101
  options,
66
102
  callback
67
103
  );
68
104
  }
69
- if (typeof path !== "string") {
70
- callback(new TypeError("path must be a string"));
71
- return;
72
- }
73
105
  let callbacks = this._activeAsyncOperations.get(path);
74
106
  if (callbacks) {
75
107
  callbacks.push(callback);
76
108
  return;
77
109
  }
78
110
  this._activeAsyncOperations.set(path, (callbacks = [callback]));
79
- provider(path, (err, result) => {
80
- this._activeAsyncOperations.delete(path);
81
- runCallbacks(callbacks, err, result);
82
- });
111
+ /** @type {Function} */
112
+ (provider)(
113
+ path,
114
+ /**
115
+ * @param {Error} err error
116
+ * @param {any} result result
117
+ */
118
+ (err, result) => {
119
+ this._activeAsyncOperations.delete(path);
120
+ runCallbacks(callbacks, err, result);
121
+ }
122
+ );
83
123
  }
84
124
  : null;
85
125
  this.provideSync = this._syncProvider
86
- ? (path, options) => {
87
- return this._syncProvider.call(this._providerContext, path, options);
126
+ ? /**
127
+ * @param {PathLike | PathOrFileDescriptor} path path
128
+ * @param {object=} options options
129
+ * @returns {any} result
130
+ */
131
+ (path, options) => {
132
+ return /** @type {Function} */ (this._syncProvider).call(
133
+ this._providerContext,
134
+ path,
135
+ options
136
+ );
88
137
  }
89
138
  : null;
90
139
  }
@@ -117,21 +166,29 @@ const STORAGE_MODE_IDLE = 0;
117
166
  const STORAGE_MODE_SYNC = 1;
118
167
  const STORAGE_MODE_ASYNC = 2;
119
168
 
169
+ /**
170
+ * @callback Provide
171
+ * @param {PathLike | PathOrFileDescriptor} path path
172
+ * @param {any} options options
173
+ * @param {FileSystemCallback<any>} callback callback
174
+ * @returns {void}
175
+ */
176
+
120
177
  class CacheBackend {
121
178
  /**
122
179
  * @param {number} duration max cache duration of items
123
- * @param {any} provider async method
124
- * @param {any} syncProvider sync method
125
- * @param {any} providerContext call context for the provider methods
180
+ * @param {function | undefined} provider async method
181
+ * @param {function | undefined} syncProvider sync method
182
+ * @param {BaseFileSystem} providerContext call context for the provider methods
126
183
  */
127
184
  constructor(duration, provider, syncProvider, providerContext) {
128
185
  this._duration = duration;
129
186
  this._provider = provider;
130
187
  this._syncProvider = syncProvider;
131
188
  this._providerContext = providerContext;
132
- /** @type {Map<string, (function(Error, any): void)[]>} */
189
+ /** @type {Map<string, FileSystemCallback<any>[]>} */
133
190
  this._activeAsyncOperations = new Map();
134
- /** @type {Map<string, { err: Error, result: any, level: Set<string> }>} */
191
+ /** @type {Map<string, { err: Error | null, result?: any, level: Set<string> }>} */
135
192
  this._data = new Map();
136
193
  /** @type {Set<string>[]} */
137
194
  this._levels = [];
@@ -147,21 +204,35 @@ class CacheBackend {
147
204
  /** @type {number | undefined} */
148
205
  this._nextDecay = undefined;
149
206
 
207
+ // @ts-ignore
150
208
  this.provide = provider ? this.provide.bind(this) : null;
209
+ // @ts-ignore
151
210
  this.provideSync = syncProvider ? this.provideSync.bind(this) : null;
152
211
  }
153
212
 
213
+ /**
214
+ * @param {PathLike | PathOrFileDescriptor} path path
215
+ * @param {any} options options
216
+ * @param {FileSystemCallback<any>} callback callback
217
+ * @returns {void}
218
+ */
154
219
  provide(path, options, callback) {
155
220
  if (typeof options === "function") {
156
221
  callback = options;
157
222
  options = undefined;
158
223
  }
159
- if (typeof path !== "string") {
160
- callback(new TypeError("path must be a string"));
224
+ if (
225
+ typeof path !== "string" &&
226
+ !Buffer.isBuffer(path) &&
227
+ !(path instanceof URL) &&
228
+ typeof path !== "number"
229
+ ) {
230
+ callback(new TypeError("path must be a string, Buffer, URL or number"));
161
231
  return;
162
232
  }
233
+ const strPath = typeof path !== "string" ? path.toString() : path;
163
234
  if (options) {
164
- return this._provider.call(
235
+ return /** @type {Function} */ (this._provider).call(
165
236
  this._providerContext,
166
237
  path,
167
238
  options,
@@ -175,38 +246,66 @@ class CacheBackend {
175
246
  }
176
247
 
177
248
  // Check in cache
178
- let cacheEntry = this._data.get(path);
249
+ let cacheEntry = this._data.get(strPath);
179
250
  if (cacheEntry !== undefined) {
180
251
  if (cacheEntry.err) return nextTick(callback, cacheEntry.err);
181
252
  return nextTick(callback, null, cacheEntry.result);
182
253
  }
183
254
 
184
255
  // Check if there is already the same operation running
185
- let callbacks = this._activeAsyncOperations.get(path);
256
+ let callbacks = this._activeAsyncOperations.get(strPath);
186
257
  if (callbacks !== undefined) {
187
258
  callbacks.push(callback);
188
259
  return;
189
260
  }
190
- this._activeAsyncOperations.set(path, (callbacks = [callback]));
261
+ this._activeAsyncOperations.set(strPath, (callbacks = [callback]));
191
262
 
192
263
  // Run the operation
193
- this._provider.call(this._providerContext, path, (err, result) => {
194
- this._activeAsyncOperations.delete(path);
195
- this._storeResult(path, err, result);
196
-
197
- // Enter async mode if not yet done
198
- this._enterAsyncMode();
199
-
200
- runCallbacks(callbacks, err, result);
201
- });
264
+ /** @type {Function} */
265
+ (this._provider).call(
266
+ this._providerContext,
267
+ path,
268
+ /**
269
+ * @param {Error | null} err error
270
+ * @param {any} [result] result
271
+ */
272
+ (err, result) => {
273
+ this._activeAsyncOperations.delete(strPath);
274
+ this._storeResult(strPath, err, result);
275
+
276
+ // Enter async mode if not yet done
277
+ this._enterAsyncMode();
278
+
279
+ runCallbacks(
280
+ /** @type {FileSystemCallback<any>[]} */ (callbacks),
281
+ err,
282
+ result
283
+ );
284
+ }
285
+ );
202
286
  }
203
287
 
288
+ /**
289
+ * @param {PathLike | PathOrFileDescriptor} path path
290
+ * @param {any} options options
291
+ * @returns {any} result
292
+ */
204
293
  provideSync(path, options) {
205
- if (typeof path !== "string") {
294
+ if (
295
+ typeof path !== "string" &&
296
+ !Buffer.isBuffer(path) &&
297
+ !(path instanceof URL) &&
298
+ typeof path !== "number"
299
+ ) {
206
300
  throw new TypeError("path must be a string");
207
301
  }
302
+ const strPath = typeof path !== "string" ? path.toString() : path;
208
303
  if (options) {
209
- return this._syncProvider.call(this._providerContext, path, options);
304
+ return /** @type {Function} */ (this._syncProvider).call(
305
+ this._providerContext,
306
+ path,
307
+ options
308
+ );
210
309
  }
211
310
 
212
311
  // In sync mode we may have to decay some cache items
@@ -215,7 +314,7 @@ class CacheBackend {
215
314
  }
216
315
 
217
316
  // Check in cache
218
- let cacheEntry = this._data.get(path);
317
+ let cacheEntry = this._data.get(strPath);
219
318
  if (cacheEntry !== undefined) {
220
319
  if (cacheEntry.err) throw cacheEntry.err;
221
320
  return cacheEntry.result;
@@ -223,26 +322,36 @@ class CacheBackend {
223
322
 
224
323
  // Get all active async operations
225
324
  // This sync operation will also complete them
226
- const callbacks = this._activeAsyncOperations.get(path);
227
- this._activeAsyncOperations.delete(path);
325
+ const callbacks = this._activeAsyncOperations.get(strPath);
326
+ this._activeAsyncOperations.delete(strPath);
228
327
 
229
328
  // Run the operation
230
329
  // When in idle mode, we will enter sync mode
231
330
  let result;
232
331
  try {
233
- result = this._syncProvider.call(this._providerContext, path);
332
+ result = /** @type {Function} */ (this._syncProvider).call(
333
+ this._providerContext,
334
+ path
335
+ );
234
336
  } catch (err) {
235
- this._storeResult(path, err, undefined);
337
+ this._storeResult(strPath, /** @type {Error} */ (err), undefined);
236
338
  this._enterSyncModeWhenIdle();
237
- if (callbacks) runCallbacks(callbacks, err, undefined);
339
+ if (callbacks) {
340
+ runCallbacks(callbacks, /** @type {Error} */ (err), undefined);
341
+ }
238
342
  throw err;
239
343
  }
240
- this._storeResult(path, undefined, result);
344
+ this._storeResult(strPath, null, result);
241
345
  this._enterSyncModeWhenIdle();
242
- if (callbacks) runCallbacks(callbacks, undefined, result);
346
+ if (callbacks) {
347
+ runCallbacks(callbacks, null, result);
348
+ }
243
349
  return result;
244
350
  }
245
351
 
352
+ /**
353
+ * @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>} [what] what to purge
354
+ */
246
355
  purge(what) {
247
356
  if (!what) {
248
357
  if (this._mode !== STORAGE_MODE_IDLE) {
@@ -252,9 +361,15 @@ class CacheBackend {
252
361
  }
253
362
  this._enterIdleMode();
254
363
  }
255
- } else if (typeof what === "string") {
364
+ } else if (
365
+ typeof what === "string" ||
366
+ Buffer.isBuffer(what) ||
367
+ what instanceof URL ||
368
+ typeof what === "number"
369
+ ) {
370
+ const strWhat = typeof what !== "string" ? what.toString() : what;
256
371
  for (let [key, data] of this._data) {
257
- if (key.startsWith(what)) {
372
+ if (key.startsWith(strWhat)) {
258
373
  this._data.delete(key);
259
374
  data.level.delete(key);
260
375
  }
@@ -265,7 +380,8 @@ class CacheBackend {
265
380
  } else {
266
381
  for (let [key, data] of this._data) {
267
382
  for (const item of what) {
268
- if (key.startsWith(item)) {
383
+ const strItem = typeof item !== "string" ? item.toString() : item;
384
+ if (key.startsWith(strItem)) {
269
385
  this._data.delete(key);
270
386
  data.level.delete(key);
271
387
  break;
@@ -278,20 +394,35 @@ class CacheBackend {
278
394
  }
279
395
  }
280
396
 
397
+ /**
398
+ * @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>} [what] what to purge
399
+ */
281
400
  purgeParent(what) {
282
401
  if (!what) {
283
402
  this.purge();
284
- } else if (typeof what === "string") {
285
- this.purge(dirname(what));
403
+ } else if (
404
+ typeof what === "string" ||
405
+ Buffer.isBuffer(what) ||
406
+ what instanceof URL ||
407
+ typeof what === "number"
408
+ ) {
409
+ const strWhat = typeof what !== "string" ? what.toString() : what;
410
+ this.purge(dirname(strWhat));
286
411
  } else {
287
412
  const set = new Set();
288
413
  for (const item of what) {
289
- set.add(dirname(item));
414
+ const strItem = typeof item !== "string" ? item.toString() : item;
415
+ set.add(dirname(strItem));
290
416
  }
291
417
  this.purge(set);
292
418
  }
293
419
  }
294
420
 
421
+ /**
422
+ * @param {string} path path
423
+ * @param {Error | null} err error
424
+ * @param {any} result result
425
+ */
295
426
  _storeResult(path, err, result) {
296
427
  if (this._data.has(path)) return;
297
428
  const level = this._levels[this._currentLevel];
@@ -310,8 +441,8 @@ class CacheBackend {
310
441
  if (this._data.size === 0) {
311
442
  this._enterIdleMode();
312
443
  } else {
313
- // @ts-ignore _nextDecay is always a number in sync mode
314
- this._nextDecay += this._tickInterval;
444
+ /** @type {number} */
445
+ (this._nextDecay) += this._tickInterval;
315
446
  }
316
447
  }
317
448
 
@@ -335,8 +466,12 @@ class CacheBackend {
335
466
  break;
336
467
  case STORAGE_MODE_SYNC:
337
468
  this._runDecays();
338
- // @ts-ignore _runDecays may change the mode
339
- if (this._mode === STORAGE_MODE_IDLE) return;
469
+ // _runDecays may change the mode
470
+ if (
471
+ /** @type {STORAGE_MODE_IDLE | STORAGE_MODE_SYNC | STORAGE_MODE_ASYNC}*/
472
+ (this._mode) === STORAGE_MODE_IDLE
473
+ )
474
+ return;
340
475
  timeout = Math.max(
341
476
  0,
342
477
  /** @type {number} */ (this._nextDecay) - Date.now()
@@ -366,6 +501,16 @@ class CacheBackend {
366
501
  }
367
502
  }
368
503
 
504
+ /**
505
+ * @template {function} Provider
506
+ * @template {function} AsyncProvider
507
+ * @template FileSystem
508
+ * @param {number} duration duration in ms files are cached
509
+ * @param {Provider | undefined} provider provider
510
+ * @param {AsyncProvider | undefined} syncProvider sync provider
511
+ * @param {BaseFileSystem} providerContext provider context
512
+ * @returns {OperationMergerBackend | CacheBackend} backend
513
+ */
369
514
  const createBackend = (duration, provider, syncProvider, providerContext) => {
370
515
  if (duration > 0) {
371
516
  return new CacheBackend(duration, provider, syncProvider, providerContext);
@@ -374,6 +519,10 @@ const createBackend = (duration, provider, syncProvider, providerContext) => {
374
519
  };
375
520
 
376
521
  module.exports = class CachedInputFileSystem {
522
+ /**
523
+ * @param {BaseFileSystem} fileSystem file system
524
+ * @param {number} duration duration in ms files are cached
525
+ */
377
526
  constructor(fileSystem, duration) {
378
527
  this.fileSystem = fileSystem;
379
528
 
@@ -408,7 +557,9 @@ module.exports = class CachedInputFileSystem {
408
557
  const readdir = this._readdirBackend.provide;
409
558
  this.readdir = /** @type {FileSystem["readdir"]} */ (readdir);
410
559
  const readdirSync = this._readdirBackend.provideSync;
411
- this.readdirSync = /** @type {SyncFileSystem["readdirSync"]} */ (readdirSync);
560
+ this.readdirSync = /** @type {SyncFileSystem["readdirSync"]} */ (
561
+ readdirSync
562
+ );
412
563
 
413
564
  this._readFileBackend = createBackend(
414
565
  duration,
@@ -419,40 +570,57 @@ module.exports = class CachedInputFileSystem {
419
570
  const readFile = this._readFileBackend.provide;
420
571
  this.readFile = /** @type {FileSystem["readFile"]} */ (readFile);
421
572
  const readFileSync = this._readFileBackend.provideSync;
422
- this.readFileSync = /** @type {SyncFileSystem["readFileSync"]} */ (readFileSync);
573
+ this.readFileSync = /** @type {SyncFileSystem["readFileSync"]} */ (
574
+ readFileSync
575
+ );
423
576
 
424
577
  this._readJsonBackend = createBackend(
425
578
  duration,
579
+ // prettier-ignore
426
580
  this.fileSystem.readJson ||
427
581
  (this.readFile &&
428
- ((path, callback) => {
429
- // @ts-ignore
430
- this.readFile(path, (err, buffer) => {
431
- if (err) return callback(err);
432
- if (!buffer || buffer.length === 0)
433
- return callback(new Error("No file content"));
434
- let data;
435
- try {
436
- data = JSON.parse(buffer.toString("utf-8"));
437
- } catch (e) {
438
- return callback(e);
439
- }
440
- callback(null, data);
441
- });
442
- })),
582
+ (
583
+ /**
584
+ * @param {string} path path
585
+ * @param {FileSystemCallback<any>} callback
586
+ */
587
+ (path, callback) => {
588
+ this.readFile(path, (err, buffer) => {
589
+ if (err) return callback(err);
590
+ if (!buffer || buffer.length === 0)
591
+ return callback(new Error("No file content"));
592
+ let data;
593
+ try {
594
+ data = JSON.parse(buffer.toString("utf-8"));
595
+ } catch (e) {
596
+ return callback(/** @type {Error} */ (e));
597
+ }
598
+ callback(null, data);
599
+ });
600
+ })
601
+ ),
602
+ // prettier-ignore
443
603
  this.fileSystem.readJsonSync ||
444
604
  (this.readFileSync &&
445
- (path => {
446
- const buffer = this.readFileSync(path);
447
- const data = JSON.parse(buffer.toString("utf-8"));
448
- return data;
449
- })),
605
+ (
606
+ /**
607
+ * @param {string} path path
608
+ * @returns {any} result
609
+ */
610
+ (path) => {
611
+ const buffer = this.readFileSync(path);
612
+ const data = JSON.parse(buffer.toString("utf-8"));
613
+ return data;
614
+ }
615
+ )),
450
616
  this.fileSystem
451
617
  );
452
618
  const readJson = this._readJsonBackend.provide;
453
619
  this.readJson = /** @type {FileSystem["readJson"]} */ (readJson);
454
620
  const readJsonSync = this._readJsonBackend.provideSync;
455
- this.readJsonSync = /** @type {SyncFileSystem["readJsonSync"]} */ (readJsonSync);
621
+ this.readJsonSync = /** @type {SyncFileSystem["readJsonSync"]} */ (
622
+ readJsonSync
623
+ );
456
624
 
457
625
  this._readlinkBackend = createBackend(
458
626
  duration,
@@ -463,9 +631,27 @@ module.exports = class CachedInputFileSystem {
463
631
  const readlink = this._readlinkBackend.provide;
464
632
  this.readlink = /** @type {FileSystem["readlink"]} */ (readlink);
465
633
  const readlinkSync = this._readlinkBackend.provideSync;
466
- this.readlinkSync = /** @type {SyncFileSystem["readlinkSync"]} */ (readlinkSync);
634
+ this.readlinkSync = /** @type {SyncFileSystem["readlinkSync"]} */ (
635
+ readlinkSync
636
+ );
637
+
638
+ this._realpathBackend = createBackend(
639
+ duration,
640
+ this.fileSystem.realpath,
641
+ this.fileSystem.realpathSync,
642
+ this.fileSystem
643
+ );
644
+ const realpath = this._realpathBackend.provide;
645
+ this.realpath = /** @type {FileSystem["realpath"]} */ (realpath);
646
+ const realpathSync = this._realpathBackend.provideSync;
647
+ this.realpathSync = /** @type {SyncFileSystem["realpathSync"]} */ (
648
+ realpathSync
649
+ );
467
650
  }
468
651
 
652
+ /**
653
+ * @param {string | Buffer | URL | number | (string | URL | Buffer | number)[] | Set<string | URL | Buffer | number>} [what] what to purge
654
+ */
469
655
  purge(what) {
470
656
  this._statBackend.purge(what);
471
657
  this._lstatBackend.purge(what);
@@ -473,5 +659,6 @@ module.exports = class CachedInputFileSystem {
473
659
  this._readFileBackend.purge(what);
474
660
  this._readlinkBackend.purge(what);
475
661
  this._readJsonBackend.purge(what);
662
+ this._realpathBackend.purge(what);
476
663
  }
477
664
  };