@rsbuild/plugin-babel 1.0.3 → 1.0.5

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.
@@ -1,550 +0,0 @@
1
- "use strict";
2
- exports.id = 672;
3
- exports.ids = [672];
4
- exports.modules = {
5
-
6
- /***/ 641:
7
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
8
-
9
-
10
- const { sep: DEFAULT_SEPARATOR } = __webpack_require__(17)
11
-
12
- const determineSeparator = paths => {
13
- for (const path of paths) {
14
- const match = /(\/|\\)/.exec(path)
15
- if (match !== null) return match[0]
16
- }
17
-
18
- return DEFAULT_SEPARATOR
19
- }
20
-
21
- module.exports = function commonPathPrefix (paths, sep = determineSeparator(paths)) {
22
- const [first = '', ...remaining] = paths
23
- if (first === '' || remaining.length === 0) return ''
24
-
25
- const parts = first.split(sep)
26
-
27
- let endOfPrefix = parts.length
28
- for (const path of remaining) {
29
- const compare = path.split(sep)
30
- for (let i = 0; i < endOfPrefix; i++) {
31
- if (compare[i] !== parts[i]) {
32
- endOfPrefix = i
33
- }
34
- }
35
-
36
- if (endOfPrefix === 0) return ''
37
- }
38
-
39
- const prefix = parts.slice(0, endOfPrefix).join(sep)
40
- return prefix.endsWith(sep) ? prefix : prefix + sep
41
- }
42
-
43
-
44
- /***/ }),
45
-
46
- /***/ 672:
47
- /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
48
-
49
- // ESM COMPAT FLAG
50
- __webpack_require__.r(__webpack_exports__);
51
-
52
- // EXPORTS
53
- __webpack_require__.d(__webpack_exports__, {
54
- "default": () => (/* binding */ findCacheDirectory)
55
- });
56
-
57
- // EXTERNAL MODULE: external "node:process"
58
- var external_node_process_ = __webpack_require__(742);
59
- // EXTERNAL MODULE: external "node:path"
60
- var external_node_path_ = __webpack_require__(411);
61
- // EXTERNAL MODULE: external "node:fs"
62
- var external_node_fs_ = __webpack_require__(561);
63
- // EXTERNAL MODULE: ../../node_modules/.pnpm/common-path-prefix@3.0.0/node_modules/common-path-prefix/index.js
64
- var common_path_prefix = __webpack_require__(641);
65
- // EXTERNAL MODULE: external "node:url"
66
- var external_node_url_ = __webpack_require__(41);
67
- ;// CONCATENATED MODULE: ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
68
- /*
69
- How it works:
70
- `this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.
71
- */
72
-
73
- class Node {
74
- value;
75
- next;
76
-
77
- constructor(value) {
78
- this.value = value;
79
- }
80
- }
81
-
82
- class yocto_queue_Queue {
83
- #head;
84
- #tail;
85
- #size;
86
-
87
- constructor() {
88
- this.clear();
89
- }
90
-
91
- enqueue(value) {
92
- const node = new Node(value);
93
-
94
- if (this.#head) {
95
- this.#tail.next = node;
96
- this.#tail = node;
97
- } else {
98
- this.#head = node;
99
- this.#tail = node;
100
- }
101
-
102
- this.#size++;
103
- }
104
-
105
- dequeue() {
106
- const current = this.#head;
107
- if (!current) {
108
- return;
109
- }
110
-
111
- this.#head = this.#head.next;
112
- this.#size--;
113
- return current.value;
114
- }
115
-
116
- clear() {
117
- this.#head = undefined;
118
- this.#tail = undefined;
119
- this.#size = 0;
120
- }
121
-
122
- get size() {
123
- return this.#size;
124
- }
125
-
126
- * [Symbol.iterator]() {
127
- let current = this.#head;
128
-
129
- while (current) {
130
- yield current.value;
131
- current = current.next;
132
- }
133
- }
134
- }
135
-
136
- ;// CONCATENATED MODULE: ../../node_modules/.pnpm/p-limit@4.0.0/node_modules/p-limit/index.js
137
-
138
-
139
- function p_limit_pLimit(concurrency) {
140
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
141
- throw new TypeError('Expected `concurrency` to be a number from 1 and up');
142
- }
143
-
144
- const queue = new Queue();
145
- let activeCount = 0;
146
-
147
- const next = () => {
148
- activeCount--;
149
-
150
- if (queue.size > 0) {
151
- queue.dequeue()();
152
- }
153
- };
154
-
155
- const run = async (fn, resolve, args) => {
156
- activeCount++;
157
-
158
- const result = (async () => fn(...args))();
159
-
160
- resolve(result);
161
-
162
- try {
163
- await result;
164
- } catch {}
165
-
166
- next();
167
- };
168
-
169
- const enqueue = (fn, resolve, args) => {
170
- queue.enqueue(run.bind(undefined, fn, resolve, args));
171
-
172
- (async () => {
173
- // This function needs to wait until the next microtask before comparing
174
- // `activeCount` to `concurrency`, because `activeCount` is updated asynchronously
175
- // when the run function is dequeued and called. The comparison in the if-statement
176
- // needs to happen asynchronously as well to get an up-to-date value for `activeCount`.
177
- await Promise.resolve();
178
-
179
- if (activeCount < concurrency && queue.size > 0) {
180
- queue.dequeue()();
181
- }
182
- })();
183
- };
184
-
185
- const generator = (fn, ...args) => new Promise(resolve => {
186
- enqueue(fn, resolve, args);
187
- });
188
-
189
- Object.defineProperties(generator, {
190
- activeCount: {
191
- get: () => activeCount,
192
- },
193
- pendingCount: {
194
- get: () => queue.size,
195
- },
196
- clearQueue: {
197
- value: () => {
198
- queue.clear();
199
- },
200
- },
201
- });
202
-
203
- return generator;
204
- }
205
-
206
- ;// CONCATENATED MODULE: ../../node_modules/.pnpm/p-locate@6.0.0/node_modules/p-locate/index.js
207
-
208
-
209
- class EndError extends Error {
210
- constructor(value) {
211
- super();
212
- this.value = value;
213
- }
214
- }
215
-
216
- // The input can also be a promise, so we await it.
217
- const testElement = async (element, tester) => tester(await element);
218
-
219
- // The input can also be a promise, so we `Promise.all()` them both.
220
- const finder = async element => {
221
- const values = await Promise.all(element);
222
- if (values[1] === true) {
223
- throw new EndError(values[0]);
224
- }
225
-
226
- return false;
227
- };
228
-
229
- async function p_locate_pLocate(
230
- iterable,
231
- tester,
232
- {
233
- concurrency = Number.POSITIVE_INFINITY,
234
- preserveOrder = true,
235
- } = {},
236
- ) {
237
- const limit = pLimit(concurrency);
238
-
239
- // Start all the promises concurrently with optional limit.
240
- const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
241
-
242
- // Check the promises either serially or concurrently.
243
- const checkLimit = pLimit(preserveOrder ? 1 : Number.POSITIVE_INFINITY);
244
-
245
- try {
246
- await Promise.all(items.map(element => checkLimit(finder, element)));
247
- } catch (error) {
248
- if (error instanceof EndError) {
249
- return error.value;
250
- }
251
-
252
- throw error;
253
- }
254
- }
255
-
256
- ;// CONCATENATED MODULE: ../../node_modules/.pnpm/locate-path@7.2.0/node_modules/locate-path/index.js
257
-
258
-
259
-
260
-
261
-
262
-
263
- const typeMappings = {
264
- directory: 'isDirectory',
265
- file: 'isFile',
266
- };
267
-
268
- function checkType(type) {
269
- if (Object.hasOwnProperty.call(typeMappings, type)) {
270
- return;
271
- }
272
-
273
- throw new Error(`Invalid type specified: ${type}`);
274
- }
275
-
276
- const matchType = (type, stat) => stat[typeMappings[type]]();
277
-
278
- const toPath = urlOrPath => urlOrPath instanceof URL ? (0,external_node_url_.fileURLToPath)(urlOrPath) : urlOrPath;
279
-
280
- async function locate_path_locatePath(
281
- paths,
282
- {
283
- cwd = process.cwd(),
284
- type = 'file',
285
- allowSymlinks = true,
286
- concurrency,
287
- preserveOrder,
288
- } = {},
289
- ) {
290
- checkType(type);
291
- cwd = toPath(cwd);
292
-
293
- const statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;
294
-
295
- return pLocate(paths, async path_ => {
296
- try {
297
- const stat = await statFunction(path.resolve(cwd, path_));
298
- return matchType(type, stat);
299
- } catch {
300
- return false;
301
- }
302
- }, {concurrency, preserveOrder});
303
- }
304
-
305
- function locatePathSync(
306
- paths,
307
- {
308
- cwd = external_node_process_.cwd(),
309
- type = 'file',
310
- allowSymlinks = true,
311
- } = {},
312
- ) {
313
- checkType(type);
314
- cwd = toPath(cwd);
315
-
316
- const statFunction = allowSymlinks ? external_node_fs_.statSync : external_node_fs_.lstatSync;
317
-
318
- for (const path_ of paths) {
319
- try {
320
- const stat = statFunction(external_node_path_.resolve(cwd, path_), {
321
- throwIfNoEntry: false,
322
- });
323
-
324
- if (!stat) {
325
- continue;
326
- }
327
-
328
- if (matchType(type, stat)) {
329
- return path_;
330
- }
331
- } catch {}
332
- }
333
- }
334
-
335
- ;// CONCATENATED MODULE: ../../node_modules/.pnpm/path-exists@5.0.0/node_modules/path-exists/index.js
336
-
337
-
338
- async function pathExists(path) {
339
- try {
340
- await fsPromises.access(path);
341
- return true;
342
- } catch {
343
- return false;
344
- }
345
- }
346
-
347
- function pathExistsSync(path) {
348
- try {
349
- fs.accessSync(path);
350
- return true;
351
- } catch {
352
- return false;
353
- }
354
- }
355
-
356
- ;// CONCATENATED MODULE: ../../node_modules/.pnpm/find-up@6.3.0/node_modules/find-up/index.js
357
-
358
-
359
-
360
-
361
- const find_up_toPath = urlOrPath => urlOrPath instanceof URL ? (0,external_node_url_.fileURLToPath)(urlOrPath) : urlOrPath;
362
-
363
- const findUpStop = Symbol('findUpStop');
364
-
365
- async function findUpMultiple(name, options = {}) {
366
- let directory = path.resolve(find_up_toPath(options.cwd) || '');
367
- const {root} = path.parse(directory);
368
- const stopAt = path.resolve(directory, options.stopAt || root);
369
- const limit = options.limit || Number.POSITIVE_INFINITY;
370
- const paths = [name].flat();
371
-
372
- const runMatcher = async locateOptions => {
373
- if (typeof name !== 'function') {
374
- return locatePath(paths, locateOptions);
375
- }
376
-
377
- const foundPath = await name(locateOptions.cwd);
378
- if (typeof foundPath === 'string') {
379
- return locatePath([foundPath], locateOptions);
380
- }
381
-
382
- return foundPath;
383
- };
384
-
385
- const matches = [];
386
- // eslint-disable-next-line no-constant-condition
387
- while (true) {
388
- // eslint-disable-next-line no-await-in-loop
389
- const foundPath = await runMatcher({...options, cwd: directory});
390
-
391
- if (foundPath === findUpStop) {
392
- break;
393
- }
394
-
395
- if (foundPath) {
396
- matches.push(path.resolve(directory, foundPath));
397
- }
398
-
399
- if (directory === stopAt || matches.length >= limit) {
400
- break;
401
- }
402
-
403
- directory = path.dirname(directory);
404
- }
405
-
406
- return matches;
407
- }
408
-
409
- function findUpMultipleSync(name, options = {}) {
410
- let directory = external_node_path_.resolve(find_up_toPath(options.cwd) || '');
411
- const {root} = external_node_path_.parse(directory);
412
- const stopAt = options.stopAt || root;
413
- const limit = options.limit || Number.POSITIVE_INFINITY;
414
- const paths = [name].flat();
415
-
416
- const runMatcher = locateOptions => {
417
- if (typeof name !== 'function') {
418
- return locatePathSync(paths, locateOptions);
419
- }
420
-
421
- const foundPath = name(locateOptions.cwd);
422
- if (typeof foundPath === 'string') {
423
- return locatePathSync([foundPath], locateOptions);
424
- }
425
-
426
- return foundPath;
427
- };
428
-
429
- const matches = [];
430
- // eslint-disable-next-line no-constant-condition
431
- while (true) {
432
- const foundPath = runMatcher({...options, cwd: directory});
433
-
434
- if (foundPath === findUpStop) {
435
- break;
436
- }
437
-
438
- if (foundPath) {
439
- matches.push(external_node_path_.resolve(directory, foundPath));
440
- }
441
-
442
- if (directory === stopAt || matches.length >= limit) {
443
- break;
444
- }
445
-
446
- directory = external_node_path_.dirname(directory);
447
- }
448
-
449
- return matches;
450
- }
451
-
452
- async function find_up_findUp(name, options = {}) {
453
- const matches = await findUpMultiple(name, {...options, limit: 1});
454
- return matches[0];
455
- }
456
-
457
- function findUpSync(name, options = {}) {
458
- const matches = findUpMultipleSync(name, {...options, limit: 1});
459
- return matches[0];
460
- }
461
-
462
-
463
-
464
- ;// CONCATENATED MODULE: ../../node_modules/.pnpm/pkg-dir@7.0.0/node_modules/pkg-dir/index.js
465
-
466
-
467
-
468
- async function packageDirectory({cwd} = {}) {
469
- const filePath = await findUp('package.json', {cwd});
470
- return filePath && path.dirname(filePath);
471
- }
472
-
473
- function packageDirectorySync({cwd} = {}) {
474
- const filePath = findUpSync('package.json', {cwd});
475
- return filePath && external_node_path_.dirname(filePath);
476
- }
477
-
478
- ;// CONCATENATED MODULE: ../../node_modules/.pnpm/find-cache-dir@4.0.0/node_modules/find-cache-dir/index.js
479
-
480
-
481
-
482
-
483
-
484
-
485
- const {env, cwd} = external_node_process_;
486
-
487
- const isWritable = path => {
488
- try {
489
- external_node_fs_.accessSync(path, external_node_fs_.constants.W_OK);
490
- return true;
491
- } catch {
492
- return false;
493
- }
494
- };
495
-
496
- function useDirectory(directory, options) {
497
- if (options.create) {
498
- external_node_fs_.mkdirSync(directory, {recursive: true});
499
- }
500
-
501
- if (options.thunk) {
502
- return (...arguments_) => external_node_path_.join(directory, ...arguments_);
503
- }
504
-
505
- return directory;
506
- }
507
-
508
- function getNodeModuleDirectory(directory) {
509
- const nodeModules = external_node_path_.join(directory, 'node_modules');
510
-
511
- if (
512
- !isWritable(nodeModules)
513
- && (external_node_fs_.existsSync(nodeModules) || !isWritable(external_node_path_.join(directory)))
514
- ) {
515
- return;
516
- }
517
-
518
- return nodeModules;
519
- }
520
-
521
- function findCacheDirectory(options = {}) {
522
- if (env.CACHE_DIR && !['true', 'false', '1', '0'].includes(env.CACHE_DIR)) {
523
- return useDirectory(external_node_path_.join(env.CACHE_DIR, options.name), options);
524
- }
525
-
526
- let {cwd: directory = cwd()} = options;
527
-
528
- if (options.files) {
529
- directory = common_path_prefix(options.files.map(file => external_node_path_.resolve(directory, file)));
530
- }
531
-
532
- directory = packageDirectorySync({cwd: directory});
533
-
534
- if (!directory) {
535
- return;
536
- }
537
-
538
- const nodeModules = getNodeModuleDirectory(directory);
539
- if (!nodeModules) {
540
- return;
541
- }
542
-
543
- return useDirectory(external_node_path_.join(directory, 'node_modules', '.cache', options.name), options);
544
- }
545
-
546
-
547
- /***/ })
548
-
549
- };
550
- ;