@rsbuild/plugin-babel 0.1.8 → 0.2.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.
@@ -0,0 +1,550 @@
1
+ "use strict";
2
+ exports.id = 583;
3
+ exports.ids = [583];
4
+ exports.modules = {
5
+
6
+ /***/ 463:
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
+ /***/ 583:
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__(463);
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
+ ;
@@ -0,0 +1 @@
1
+ export = any;
@@ -0,0 +1 @@
1
+ (()=>{var e={805:e=>{const t=/^[^:]+: /;const format=e=>{if(e instanceof SyntaxError){e.name="SyntaxError";e.message=e.message.replace(t,"");e.hideStack=true}else if(e instanceof TypeError){e.name=null;e.message=e.message.replace(t,"");e.hideStack=true}return e};class LoaderError extends Error{constructor(e){super();const{name:t,message:r,codeFrame:o,hideStack:s}=format(e);this.name="BabelLoaderError";this.message=`${t?`${t}: `:""}${r}\n\n${o}\n`;this.hideStack=s;Error.captureStackTrace(this,this.constructor)}}e.exports=LoaderError},399:(e,t,r)=>{const o=r(37);const s=r(17);const a=r(796);const i=r(113);const{promisify:n}=r(837);const{readFile:c,writeFile:u,mkdir:l}=r(292);const p=r.e(583).then(r.bind(r,583));const f=r(136);let d=null;let _="sha256";try{i.createHash(_)}catch(e){_="md5"}const b=n(a.gunzip);const m=n(a.gzip);const read=async function(e,t){const r=await c(e+(t?".gz":""));const o=t?await b(r):r;return JSON.parse(o.toString())};const write=async function(e,t,r){const o=JSON.stringify(r);const s=t?await m(o):o;return await u(e+(t?".gz":""),s)};const filename=function(e,t,r){const o=i.createHash(_);const s=JSON.stringify({source:e,options:r,identifier:t});o.update(s);return o.digest("hex")+".json"};const handleCache=async function(e,t){const{source:r,options:a={},cacheIdentifier:i,cacheDirectory:n,cacheCompression:c}=t;const u=s.join(e,filename(r,i,a));try{return await read(u,c)}catch(e){}const p=typeof n!=="string"&&e!==o.tmpdir();try{await l(e,{recursive:true})}catch(e){if(p){return handleCache(o.tmpdir(),t)}throw e}const d=await f(r,a);if(!d.externalDependencies.length){try{await write(u,c,d)}catch(e){if(p){return handleCache(o.tmpdir(),t)}throw e}}return d};e.exports=async function(e){let t;if(typeof e.cacheDirectory==="string"){t=e.cacheDirectory}else{if(d===null){const{default:e}=await p;d=e({name:"babel-loader"})||o.tmpdir()}t=d}return await handleCache(t,e)}},903:(e,t,r)=>{let o;try{o=r(718)}catch(e){if(e.code==="MODULE_NOT_FOUND"){e.message+="\n babel-loader@9 requires Babel 7.12+ (the package '@babel/core'). "+"If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'."}throw e}if(/^6\./.test(o.version)){throw new Error("\n babel-loader@9 will not work with the '@babel/core@6' bridge package. "+"If you want to use Babel 6.x, install 'babel-loader@7'.")}const{version:s}=r(684);const a=r(399);const i=r(136);const n=r(103);const c=r(427);const{isAbsolute:u}=r(17);const l=r(14).validate;function subscribe(e,t,r){if(r[e]){r[e](t)}}e.exports=makeLoader();e.exports.custom=makeLoader;function makeLoader(e){const t=e?e(o):undefined;return function(e,r){const o=this.async();loader.call(this,e,r,t).then((e=>o(null,...e)),(e=>o(e)))}}async function loader(e,t,r){const p=this.resourcePath;let f=this.getOptions();l(c,f,{name:"Babel loader"});if(f.customize!=null){if(typeof f.customize!=="string"){throw new Error("Customized loaders must be implemented as standalone modules.")}if(!u(f.customize)){throw new Error("Customized loaders must be passed as absolute paths, since "+"babel-loader has no way to know what they would be relative to.")}if(r){throw new Error("babel-loader's 'customize' option is not available when already "+"using a customized babel-loader wrapper.")}let e=require(f.customize);if(e.__esModule)e=e.default;if(typeof e!=="function"){throw new Error("Custom overrides must be functions.")}r=e(o)}let d;if(r&&r.customOptions){const o=await r.customOptions.call(this,f,{source:e,map:t});d=o.custom;f=o.loader}if("forceEnv"in f){console.warn("The option `forceEnv` has been removed in favor of `envName` in Babel 7.")}if(typeof f.babelrc==="string"){console.warn("The option `babelrc` should not be set to a string anymore in the babel-loader config. "+"Please update your configuration and set `babelrc` to true or false.\n"+"If you want to specify a specific babel config file to inherit config from "+"please use the `extends` option.\nFor more information about this options see "+"https://babeljs.io/docs/core-packages/#options")}if(Object.prototype.hasOwnProperty.call(f,"sourceMap")&&!Object.prototype.hasOwnProperty.call(f,"sourceMaps")){f=Object.assign({},f,{sourceMaps:f.sourceMap});delete f.sourceMap}const _=Object.assign({},f,{filename:p,inputSourceMap:t||f.inputSourceMap,sourceMaps:f.sourceMaps===undefined?this.sourceMap:f.sourceMaps,sourceFileName:p});delete _.customize;delete _.cacheDirectory;delete _.cacheIdentifier;delete _.cacheCompression;delete _.metadataSubscribers;const b=await o.loadPartialConfigAsync(n(_,this.target));if(b){let o=b.options;if(r&&r.config){o=await r.config.call(this,b,{source:e,map:t,customOptions:d})}if(o.sourceMaps==="inline"){o.sourceMaps=true}const{cacheDirectory:n=null,cacheIdentifier:c=JSON.stringify({options:o,"@babel/core":i.version,"@babel/loader":s}),cacheCompression:u=true,metadataSubscribers:l=[]}=f;let p;if(n){p=await a({source:e,options:o,transform:i,cacheDirectory:n,cacheIdentifier:c,cacheCompression:u})}else{p=await i(e,o)}b.files.forEach((e=>this.addDependency(e)));if(p){if(r&&r.result){p=await r.result.call(this,p,{source:e,map:t,customOptions:d,config:b,options:o})}const{code:s,map:a,metadata:i,externalDependencies:n}=p;n==null?void 0:n.forEach((e=>this.addDependency(e)));l.forEach((e=>{subscribe(e,i,this)}));return[s,a]}}return[e,t]}},103:(e,t,r)=>{const o=r(718);e.exports=function injectCaller(e,t){if(!supportsCallerOption())return e;return Object.assign({},e,{caller:Object.assign({name:"babel-loader",target:t,supportsStaticESM:true,supportsDynamicImport:true,supportsTopLevelAwait:true},e.caller)})};let s=undefined;function supportsCallerOption(){if(s===undefined){try{o.loadPartialConfig({caller:undefined,babelrc:false,configFile:false});s=true}catch(e){s=false}}return s}},136:(e,t,r)=>{const o=r(718);const{promisify:s}=r(837);const a=r(805);const i=s(o.transform);e.exports=async function(e,t){let r;try{r=await i(e,t)}catch(e){throw e.message&&e.codeFrame?new a(e):e}if(!r)return null;const{ast:o,code:s,map:n,metadata:c,sourceType:u,externalDependencies:l}=r;if(n&&(!n.sourcesContent||!n.sourcesContent.length)){n.sourcesContent=[e]}return{ast:o,code:s,map:n,metadata:c,sourceType:u,externalDependencies:Array.from(l||[])}};e.exports.version=o.version},684:e=>{"use strict";e.exports=require("./package.json")},14:e=>{"use strict";e.exports=require("./schema-utils")},718:e=>{"use strict";e.exports=require("@babel/core")},113:e=>{"use strict";e.exports=require("crypto")},292:e=>{"use strict";e.exports=require("fs/promises")},561:e=>{"use strict";e.exports=require("node:fs")},411:e=>{"use strict";e.exports=require("node:path")},742:e=>{"use strict";e.exports=require("node:process")},41:e=>{"use strict";e.exports=require("node:url")},37:e=>{"use strict";e.exports=require("os")},17:e=>{"use strict";e.exports=require("path")},837:e=>{"use strict";e.exports=require("util")},796:e=>{"use strict";e.exports=require("zlib")},427:e=>{"use strict";e.exports=JSON.parse('{"type":"object","properties":{"cacheDirectory":{"oneOf":[{"type":"boolean"},{"type":"string"}],"default":false},"cacheIdentifier":{"type":"string"},"cacheCompression":{"type":"boolean","default":true},"customize":{"type":"string","default":null}},"additionalProperties":true}')}};var t={};function __nccwpck_require__(r){var o=t[r];if(o!==undefined){return o.exports}var s=t[r]={exports:{}};var a=true;try{e[r](s,s.exports,__nccwpck_require__);a=false}finally{if(a)delete t[r]}return s.exports}__nccwpck_require__.m=e;(()=>{__nccwpck_require__.d=(e,t)=>{for(var r in t){if(__nccwpck_require__.o(t,r)&&!__nccwpck_require__.o(e,r)){Object.defineProperty(e,r,{enumerable:true,get:t[r]})}}}})();(()=>{__nccwpck_require__.f={};__nccwpck_require__.e=e=>Promise.all(Object.keys(__nccwpck_require__.f).reduce(((t,r)=>{__nccwpck_require__.f[r](e,t);return t}),[]))})();(()=>{__nccwpck_require__.u=e=>""+e+".index.js"})();(()=>{__nccwpck_require__.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})();(()=>{__nccwpck_require__.r=e=>{if(typeof Symbol!=="undefined"&&Symbol.toStringTag){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}Object.defineProperty(e,"__esModule",{value:true})}})();if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";(()=>{var e={179:1};var installChunk=t=>{var r=t.modules,o=t.ids,s=t.runtime;for(var a in r){if(__nccwpck_require__.o(r,a)){__nccwpck_require__.m[a]=r[a]}}if(s)s(__nccwpck_require__);for(var i=0;i<o.length;i++)e[o[i]]=1};__nccwpck_require__.f.require=(t,r)=>{if(!e[t]){if(true){installChunk(require("./"+__nccwpck_require__.u(t)))}else e[t]=1}}})();var r=__nccwpck_require__(903);module.exports=r})();
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014-2019 Luís Couto <hello@luiscouto.pt>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ {"name":"babel-loader","author":"Luis Couto <hello@luiscouto.pt>","version":"9.1.3","license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -0,0 +1 @@
1
+ module.exports.validate = () => {};
package/dist/index.d.ts CHANGED
@@ -44,14 +44,24 @@ type PresetReactOptions = AutomaticRuntimePresetReactOptions | ClassicRuntimePre
44
44
  type BabelConfigUtils = {
45
45
  addPlugins: (plugins: PluginItem[]) => void;
46
46
  addPresets: (presets: PluginItem[]) => void;
47
- addIncludes: (includes: string | RegExp | (string | RegExp)[]) => void;
48
- addExcludes: (excludes: string | RegExp | (string | RegExp)[]) => void;
49
47
  removePlugins: (plugins: string | string[]) => void;
50
48
  removePresets: (presets: string | string[]) => void;
51
49
  modifyPresetEnvOptions: (options: PresetEnvOptions) => void;
52
50
  modifyPresetReactOptions: (options: PresetReactOptions) => void;
51
+ /**
52
+ * use `source.include` instead
53
+ * @deprecated
54
+ */
55
+ addIncludes: (includes: string | RegExp | (string | RegExp)[]) => void;
56
+ /**
57
+ * use `source.exclude` instead
58
+ * @deprecated
59
+ */
60
+ addExcludes: (excludes: string | RegExp | (string | RegExp)[]) => void;
61
+ };
62
+ type PluginBabelOptions = {
63
+ babelLoaderOptions?: ChainedConfigWithUtils<TransformOptions, BabelConfigUtils>;
53
64
  };
54
- type PluginBabelOptions = ChainedConfigWithUtils<TransformOptions, BabelConfigUtils>;
55
65
 
56
66
  declare const pluginBabel: (options?: PluginBabelOptions) => RsbuildPlugin;
57
67
 
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ __export(src_exports, {
37
37
  module.exports = __toCommonJS(src_exports);
38
38
 
39
39
  // src/plugin.ts
40
+ var import_path2 = __toESM(require("path"));
40
41
  var import_shared2 = require("@rsbuild/shared");
41
42
 
42
43
  // src/helper.ts
@@ -198,7 +199,7 @@ var pluginBabel = (options = {}) => ({
198
199
  };
199
200
  const userBabelConfig = applyUserBabelConfig(
200
201
  (0, import_shared2.cloneDeep)(baseConfig),
201
- options,
202
+ options.babelLoaderOptions,
202
203
  babelUtils
203
204
  );
204
205
  const babelOptions2 = {
@@ -221,7 +222,7 @@ var pluginBabel = (options = {}) => ({
221
222
  excludes.forEach((condition) => {
222
223
  rule.exclude.add(condition);
223
224
  });
224
- rule.test(import_shared2.SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(require.resolve("babel-loader")).options(babelOptions);
225
+ rule.test(import_shared2.SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(import_path2.default.resolve(__dirname, "../compiled/babel-loader/index.js")).options(babelOptions);
225
226
  });
226
227
  }
227
228
  });
package/dist/index.mjs CHANGED
@@ -9,12 +9,16 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
9
9
  // ../../node_modules/.pnpm/@modern-js+module-tools@2.41.0_typescript@5.3.2/node_modules/@modern-js/module-tools/shims/esm.js
10
10
  import { fileURLToPath } from "url";
11
11
  import path from "path";
12
+ var getFilename = () => fileURLToPath(import.meta.url);
13
+ var getDirname = () => path.dirname(getFilename());
14
+ var __dirname = /* @__PURE__ */ getDirname();
12
15
 
13
16
  // ../../scripts/requireShims.js
14
17
  import { createRequire } from "module";
15
18
  global.require = createRequire(import.meta.url);
16
19
 
17
20
  // src/plugin.ts
21
+ import path2 from "path";
18
22
  import { cloneDeep, SCRIPT_REGEX } from "@rsbuild/shared";
19
23
 
20
24
  // src/helper.ts
@@ -179,7 +183,7 @@ var pluginBabel = (options = {}) => ({
179
183
  };
180
184
  const userBabelConfig = applyUserBabelConfig(
181
185
  cloneDeep(baseConfig),
182
- options,
186
+ options.babelLoaderOptions,
183
187
  babelUtils
184
188
  );
185
189
  const babelOptions2 = {
@@ -202,7 +206,7 @@ var pluginBabel = (options = {}) => ({
202
206
  excludes.forEach((condition) => {
203
207
  rule.exclude.add(condition);
204
208
  });
205
- rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(__require.resolve("babel-loader")).options(babelOptions);
209
+ rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(path2.resolve(__dirname, "../compiled/babel-loader/index.js")).options(babelOptions);
206
210
  });
207
211
  }
208
212
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-babel",
3
- "version": "0.1.8",
3
+ "version": "0.2.0",
4
4
  "description": "Babel plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,6 +8,7 @@
8
8
  "directory": "packages/plugin-babel"
9
9
  },
10
10
  "license": "MIT",
11
+ "type": "commonjs",
11
12
  "exports": {
12
13
  ".": {
13
14
  "types": "./dist/index.d.ts",
@@ -18,21 +19,21 @@
18
19
  "main": "./dist/index.js",
19
20
  "types": "./dist/index.d.ts",
20
21
  "files": [
21
- "dist"
22
+ "dist",
23
+ "compiled"
22
24
  ],
23
25
  "dependencies": {
24
26
  "@babel/core": "^7.23.2",
25
27
  "@babel/preset-typescript": "^7.23.2",
26
28
  "@types/babel__core": "^7.20.3",
27
- "babel-loader": "9.1.3",
28
29
  "upath": "2.0.1",
29
- "@rsbuild/shared": "0.1.8"
30
+ "@rsbuild/shared": "0.2.0"
30
31
  },
31
32
  "devDependencies": {
32
- "@types/node": "^16",
33
+ "@types/node": "16.x",
33
34
  "typescript": "^5.3.0",
34
- "@rsbuild/test-helper": "0.1.8",
35
- "@rsbuild/core": "0.1.8"
35
+ "@rsbuild/core": "0.2.0",
36
+ "@rsbuild/test-helper": "0.2.0"
36
37
  },
37
38
  "publishConfig": {
38
39
  "access": "public",