@rsbuild/plugin-babel 0.6.8 → 0.6.9

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 +1,755 @@
1
- (()=>{var e={329: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},548:(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(672).then(r.bind(r,672));const f=r(843);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)}},384:(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(548);const i=r(843);const n=r(136);const c=r(77);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]}},136:(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}},843:(e,t,r)=>{const o=r(718);const{promisify:s}=r(837);const a=r(329);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")},77: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__(384);module.exports=r})();
1
+ /******/ (() => { // webpackBootstrap
2
+ /******/ var __webpack_modules__ = ({
3
+
4
+ /***/ 329:
5
+ /***/ ((module) => {
6
+
7
+ const STRIP_FILENAME_RE = /^[^:]+: /;
8
+ const format = err => {
9
+ if (err instanceof SyntaxError) {
10
+ err.name = "SyntaxError";
11
+ err.message = err.message.replace(STRIP_FILENAME_RE, "");
12
+ err.hideStack = true;
13
+ } else if (err instanceof TypeError) {
14
+ err.name = null;
15
+ err.message = err.message.replace(STRIP_FILENAME_RE, "");
16
+ err.hideStack = true;
17
+ }
18
+ return err;
19
+ };
20
+ class LoaderError extends Error {
21
+ constructor(err) {
22
+ super();
23
+ const {
24
+ name,
25
+ message,
26
+ codeFrame,
27
+ hideStack
28
+ } = format(err);
29
+ this.name = "BabelLoaderError";
30
+ this.message = `${name ? `${name}: ` : ""}${message}\n\n${codeFrame}\n`;
31
+ this.hideStack = hideStack;
32
+ Error.captureStackTrace(this, this.constructor);
33
+ }
34
+ }
35
+ module.exports = LoaderError;
36
+
37
+ /***/ }),
38
+
39
+ /***/ 548:
40
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
41
+
42
+ /**
43
+ * Filesystem Cache
44
+ *
45
+ * Given a file and a transform function, cache the result into files
46
+ * or retrieve the previously cached files if the given file is already known.
47
+ *
48
+ * @see https://github.com/babel/babel-loader/issues/34
49
+ * @see https://github.com/babel/babel-loader/pull/41
50
+ */
51
+ const os = __nccwpck_require__(37);
52
+ const path = __nccwpck_require__(17);
53
+ const zlib = __nccwpck_require__(796);
54
+ const crypto = __nccwpck_require__(113);
55
+ const {
56
+ promisify
57
+ } = __nccwpck_require__(837);
58
+ const {
59
+ readFile,
60
+ writeFile,
61
+ mkdir
62
+ } = __nccwpck_require__(292);
63
+ const findCacheDirP = __nccwpck_require__.e(/* import() */ 672).then(__nccwpck_require__.bind(__nccwpck_require__, 672));
64
+ const transform = __nccwpck_require__(843);
65
+ // Lazily instantiated when needed
66
+ let defaultCacheDirectory = null;
67
+ let hashType = "sha256";
68
+ // use md5 hashing if sha256 is not available
69
+ try {
70
+ crypto.createHash(hashType);
71
+ } catch (err) {
72
+ hashType = "md5";
73
+ }
74
+ const gunzip = promisify(zlib.gunzip);
75
+ const gzip = promisify(zlib.gzip);
76
+
77
+ /**
78
+ * Read the contents from the compressed file.
79
+ *
80
+ * @async
81
+ * @params {String} filename
82
+ * @params {Boolean} compress
83
+ */
84
+ const read = async function (filename, compress) {
85
+ const data = await readFile(filename + (compress ? ".gz" : ""));
86
+ const content = compress ? await gunzip(data) : data;
87
+ return JSON.parse(content.toString());
88
+ };
89
+
90
+ /**
91
+ * Write contents into a compressed file.
92
+ *
93
+ * @async
94
+ * @params {String} filename
95
+ * @params {Boolean} compress
96
+ * @params {String} result
97
+ */
98
+ const write = async function (filename, compress, result) {
99
+ const content = JSON.stringify(result);
100
+ const data = compress ? await gzip(content) : content;
101
+ return await writeFile(filename + (compress ? ".gz" : ""), data);
102
+ };
103
+
104
+ /**
105
+ * Build the filename for the cached file
106
+ *
107
+ * @params {String} source File source code
108
+ * @params {Object} options Options used
109
+ *
110
+ * @return {String}
111
+ */
112
+ const filename = function (source, identifier, options) {
113
+ const hash = crypto.createHash(hashType);
114
+ const contents = JSON.stringify({
115
+ source,
116
+ options,
117
+ identifier
118
+ });
119
+ hash.update(contents);
120
+ return hash.digest("hex") + ".json";
121
+ };
122
+
123
+ /**
124
+ * Handle the cache
125
+ *
126
+ * @params {String} directory
127
+ * @params {Object} params
128
+ */
129
+ const handleCache = async function (directory, params) {
130
+ const {
131
+ source,
132
+ options = {},
133
+ cacheIdentifier,
134
+ cacheDirectory,
135
+ cacheCompression
136
+ } = params;
137
+ const file = path.join(directory, filename(source, cacheIdentifier, options));
138
+ try {
139
+ // No errors mean that the file was previously cached
140
+ // we just need to return it
141
+ return await read(file, cacheCompression);
142
+ } catch (err) {}
143
+ const fallback = typeof cacheDirectory !== "string" && directory !== os.tmpdir();
144
+
145
+ // Make sure the directory exists.
146
+ try {
147
+ // overwrite directory if exists
148
+ await mkdir(directory, {
149
+ recursive: true
150
+ });
151
+ } catch (err) {
152
+ if (fallback) {
153
+ return handleCache(os.tmpdir(), params);
154
+ }
155
+ throw err;
156
+ }
157
+
158
+ // Otherwise just transform the file
159
+ // return it to the user asap and write it in cache
160
+ const result = await transform(source, options);
161
+
162
+ // Do not cache if there are external dependencies,
163
+ // since they might change and we cannot control it.
164
+ if (!result.externalDependencies.length) {
165
+ try {
166
+ await write(file, cacheCompression, result);
167
+ } catch (err) {
168
+ if (fallback) {
169
+ // Fallback to tmpdir if node_modules folder not writable
170
+ return handleCache(os.tmpdir(), params);
171
+ }
172
+ throw err;
173
+ }
174
+ }
175
+ return result;
176
+ };
177
+
178
+ /**
179
+ * Retrieve file from cache, or create a new one for future reads
180
+ *
181
+ * @async
182
+ * @param {Object} params
183
+ * @param {String} params.cacheDirectory Directory to store cached files
184
+ * @param {String} params.cacheIdentifier Unique identifier to bust cache
185
+ * @param {Boolean} params.cacheCompression Whether compressing cached files
186
+ * @param {String} params.source Original contents of the file to be cached
187
+ * @param {Object} params.options Options to be given to the transform fn
188
+ *
189
+ * @example
190
+ *
191
+ * const result = await cache({
192
+ * cacheDirectory: '.tmp/cache',
193
+ * cacheIdentifier: 'babel-loader-cachefile',
194
+ * cacheCompression: false,
195
+ * source: *source code from file*,
196
+ * options: {
197
+ * experimental: true,
198
+ * runtime: true
199
+ * },
200
+ * });
201
+ */
202
+
203
+ module.exports = async function (params) {
204
+ let directory;
205
+ if (typeof params.cacheDirectory === "string") {
206
+ directory = params.cacheDirectory;
207
+ } else {
208
+ if (defaultCacheDirectory === null) {
209
+ const {
210
+ default: findCacheDir
211
+ } = await findCacheDirP;
212
+ defaultCacheDirectory = findCacheDir({
213
+ name: "babel-loader"
214
+ }) || os.tmpdir();
215
+ }
216
+ directory = defaultCacheDirectory;
217
+ }
218
+ return await handleCache(directory, params);
219
+ };
220
+
221
+ /***/ }),
222
+
223
+ /***/ 384:
224
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
225
+
226
+ let babel;
227
+ try {
228
+ babel = __nccwpck_require__(718);
229
+ } catch (err) {
230
+ if (err.code === "MODULE_NOT_FOUND") {
231
+ err.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'.";
232
+ }
233
+ throw err;
234
+ }
235
+
236
+ // Since we've got the reverse bridge package at @babel/core@6.x, give
237
+ // people useful feedback if they try to use it alongside babel-loader.
238
+ if (/^6\./.test(babel.version)) {
239
+ 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'.");
240
+ }
241
+ const {
242
+ version
243
+ } = __nccwpck_require__(684);
244
+ const cache = __nccwpck_require__(548);
245
+ const transform = __nccwpck_require__(843);
246
+ const injectCaller = __nccwpck_require__(136);
247
+ const schema = __nccwpck_require__(77);
248
+ const {
249
+ isAbsolute
250
+ } = __nccwpck_require__(17);
251
+ const validateOptions = (__nccwpck_require__(14).validate);
252
+ function subscribe(subscriber, metadata, context) {
253
+ if (context[subscriber]) {
254
+ context[subscriber](metadata);
255
+ }
256
+ }
257
+ module.exports = makeLoader();
258
+ module.exports.custom = makeLoader;
259
+ function makeLoader(callback) {
260
+ const overrides = callback ? callback(babel) : undefined;
261
+ return function (source, inputSourceMap) {
262
+ // Make the loader async
263
+ const callback = this.async();
264
+ loader.call(this, source, inputSourceMap, overrides).then(args => callback(null, ...args), err => callback(err));
265
+ };
266
+ }
267
+ async function loader(source, inputSourceMap, overrides) {
268
+ const filename = this.resourcePath;
269
+ let loaderOptions = this.getOptions();
270
+ validateOptions(schema, loaderOptions, {
271
+ name: "Babel loader"
272
+ });
273
+ if (loaderOptions.customize != null) {
274
+ if (typeof loaderOptions.customize !== "string") {
275
+ throw new Error("Customized loaders must be implemented as standalone modules.");
276
+ }
277
+ if (!isAbsolute(loaderOptions.customize)) {
278
+ 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.");
279
+ }
280
+ if (overrides) {
281
+ throw new Error("babel-loader's 'customize' option is not available when already " + "using a customized babel-loader wrapper.");
282
+ }
283
+ let override = require(loaderOptions.customize);
284
+ if (override.__esModule) override = override.default;
285
+ if (typeof override !== "function") {
286
+ throw new Error("Custom overrides must be functions.");
287
+ }
288
+ overrides = override(babel);
289
+ }
290
+ let customOptions;
291
+ if (overrides && overrides.customOptions) {
292
+ const result = await overrides.customOptions.call(this, loaderOptions, {
293
+ source,
294
+ map: inputSourceMap
295
+ });
296
+ customOptions = result.custom;
297
+ loaderOptions = result.loader;
298
+ }
299
+
300
+ // Deprecation handling
301
+ if ("forceEnv" in loaderOptions) {
302
+ console.warn("The option `forceEnv` has been removed in favor of `envName` in Babel 7.");
303
+ }
304
+ if (typeof loaderOptions.babelrc === "string") {
305
+ 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");
306
+ }
307
+
308
+ // Standardize on 'sourceMaps' as the key passed through to Webpack, so that
309
+ // users may safely use either one alongside our default use of
310
+ // 'this.sourceMap' below without getting error about conflicting aliases.
311
+ if (Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMap") && !Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMaps")) {
312
+ loaderOptions = Object.assign({}, loaderOptions, {
313
+ sourceMaps: loaderOptions.sourceMap
314
+ });
315
+ delete loaderOptions.sourceMap;
316
+ }
317
+ const programmaticOptions = Object.assign({}, loaderOptions, {
318
+ filename,
319
+ inputSourceMap: inputSourceMap || loaderOptions.inputSourceMap,
320
+ // Set the default sourcemap behavior based on Webpack's mapping flag,
321
+ // but allow users to override if they want.
322
+ sourceMaps: loaderOptions.sourceMaps === undefined ? this.sourceMap : loaderOptions.sourceMaps,
323
+ // Ensure that Webpack will get a full absolute path in the sourcemap
324
+ // so that it can properly map the module back to its internal cached
325
+ // modules.
326
+ sourceFileName: filename
327
+ });
328
+ // Remove loader related options
329
+ delete programmaticOptions.customize;
330
+ delete programmaticOptions.cacheDirectory;
331
+ delete programmaticOptions.cacheIdentifier;
332
+ delete programmaticOptions.cacheCompression;
333
+ delete programmaticOptions.metadataSubscribers;
334
+ const config = await babel.loadPartialConfigAsync(injectCaller(programmaticOptions, this.target));
335
+ if (config) {
336
+ let options = config.options;
337
+ if (overrides && overrides.config) {
338
+ options = await overrides.config.call(this, config, {
339
+ source,
340
+ map: inputSourceMap,
341
+ customOptions
342
+ });
343
+ }
344
+ if (options.sourceMaps === "inline") {
345
+ // Babel has this weird behavior where if you set "inline", we
346
+ // inline the sourcemap, and set 'result.map = null'. This results
347
+ // in bad behavior from Babel since the maps get put into the code,
348
+ // which Webpack does not expect, and because the map we return to
349
+ // Webpack is null, which is also bad. To avoid that, we override the
350
+ // behavior here so "inline" just behaves like 'true'.
351
+ options.sourceMaps = true;
352
+ }
353
+ const {
354
+ cacheDirectory = null,
355
+ cacheIdentifier = JSON.stringify({
356
+ options,
357
+ "@babel/core": transform.version,
358
+ "@babel/loader": version
359
+ }),
360
+ cacheCompression = true,
361
+ metadataSubscribers = []
362
+ } = loaderOptions;
363
+ let result;
364
+ if (cacheDirectory) {
365
+ result = await cache({
366
+ source,
367
+ options,
368
+ transform,
369
+ cacheDirectory,
370
+ cacheIdentifier,
371
+ cacheCompression
372
+ });
373
+ } else {
374
+ result = await transform(source, options);
375
+ }
376
+ config.files.forEach(configFile => this.addDependency(configFile));
377
+ if (result) {
378
+ if (overrides && overrides.result) {
379
+ result = await overrides.result.call(this, result, {
380
+ source,
381
+ map: inputSourceMap,
382
+ customOptions,
383
+ config,
384
+ options
385
+ });
386
+ }
387
+ const {
388
+ code,
389
+ map,
390
+ metadata,
391
+ externalDependencies
392
+ } = result;
393
+ externalDependencies == null ? void 0 : externalDependencies.forEach(dep => this.addDependency(dep));
394
+ metadataSubscribers.forEach(subscriber => {
395
+ subscribe(subscriber, metadata, this);
396
+ });
397
+ return [code, map];
398
+ }
399
+ }
400
+
401
+ // If the file was ignored, pass through the original content.
402
+ return [source, inputSourceMap];
403
+ }
404
+
405
+ /***/ }),
406
+
407
+ /***/ 136:
408
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
409
+
410
+ const babel = __nccwpck_require__(718);
411
+ module.exports = function injectCaller(opts, target) {
412
+ if (!supportsCallerOption()) return opts;
413
+ return Object.assign({}, opts, {
414
+ caller: Object.assign({
415
+ name: "babel-loader",
416
+ // Provide plugins with insight into webpack target.
417
+ // https://github.com/babel/babel-loader/issues/787
418
+ target,
419
+ // Webpack >= 2 supports ESM and dynamic import.
420
+ supportsStaticESM: true,
421
+ supportsDynamicImport: true,
422
+ // Webpack 5 supports TLA behind a flag. We enable it by default
423
+ // for Babel, and then webpack will throw an error if the experimental
424
+ // flag isn't enabled.
425
+ supportsTopLevelAwait: true
426
+ }, opts.caller)
427
+ });
428
+ };
429
+
430
+ // TODO: We can remove this eventually, I'm just adding it so that people have
431
+ // a little time to migrate to the newer RCs of @babel/core without getting
432
+ // hard-to-diagnose errors about unknown 'caller' options.
433
+ let supportsCallerOptionFlag = undefined;
434
+ function supportsCallerOption() {
435
+ if (supportsCallerOptionFlag === undefined) {
436
+ try {
437
+ // Rather than try to match the Babel version, we just see if it throws
438
+ // when passed a 'caller' flag, and use that to decide if it is supported.
439
+ babel.loadPartialConfig({
440
+ caller: undefined,
441
+ babelrc: false,
442
+ configFile: false
443
+ });
444
+ supportsCallerOptionFlag = true;
445
+ } catch (err) {
446
+ supportsCallerOptionFlag = false;
447
+ }
448
+ }
449
+ return supportsCallerOptionFlag;
450
+ }
451
+
452
+ /***/ }),
453
+
454
+ /***/ 843:
455
+ /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
456
+
457
+ const babel = __nccwpck_require__(718);
458
+ const {
459
+ promisify
460
+ } = __nccwpck_require__(837);
461
+ const LoaderError = __nccwpck_require__(329);
462
+ const transform = promisify(babel.transform);
463
+ module.exports = async function (source, options) {
464
+ let result;
465
+ try {
466
+ result = await transform(source, options);
467
+ } catch (err) {
468
+ throw err.message && err.codeFrame ? new LoaderError(err) : err;
469
+ }
470
+ if (!result) return null;
471
+
472
+ // We don't return the full result here because some entries are not
473
+ // really serializable. For a full list of properties see here:
474
+ // https://github.com/babel/babel/blob/main/packages/babel-core/src/transformation/index.js
475
+ // For discussion on this topic see here:
476
+ // https://github.com/babel/babel-loader/pull/629
477
+ const {
478
+ ast,
479
+ code,
480
+ map,
481
+ metadata,
482
+ sourceType,
483
+ externalDependencies
484
+ } = result;
485
+ if (map && (!map.sourcesContent || !map.sourcesContent.length)) {
486
+ map.sourcesContent = [source];
487
+ }
488
+ return {
489
+ ast,
490
+ code,
491
+ map,
492
+ metadata,
493
+ sourceType,
494
+ // Convert it from a Set to an Array to make it JSON-serializable.
495
+ externalDependencies: Array.from(externalDependencies || [])
496
+ };
497
+ };
498
+ module.exports.version = babel.version;
499
+
500
+ /***/ }),
501
+
502
+ /***/ 684:
503
+ /***/ ((module) => {
504
+
505
+ "use strict";
506
+ module.exports = require("./package.json");
507
+
508
+ /***/ }),
509
+
510
+ /***/ 14:
511
+ /***/ ((module) => {
512
+
513
+ "use strict";
514
+ module.exports = require("./schema-utils");
515
+
516
+ /***/ }),
517
+
518
+ /***/ 718:
519
+ /***/ ((module) => {
520
+
521
+ "use strict";
522
+ module.exports = require("@babel/core");
523
+
524
+ /***/ }),
525
+
526
+ /***/ 113:
527
+ /***/ ((module) => {
528
+
529
+ "use strict";
530
+ module.exports = require("crypto");
531
+
532
+ /***/ }),
533
+
534
+ /***/ 292:
535
+ /***/ ((module) => {
536
+
537
+ "use strict";
538
+ module.exports = require("fs/promises");
539
+
540
+ /***/ }),
541
+
542
+ /***/ 561:
543
+ /***/ ((module) => {
544
+
545
+ "use strict";
546
+ module.exports = require("node:fs");
547
+
548
+ /***/ }),
549
+
550
+ /***/ 411:
551
+ /***/ ((module) => {
552
+
553
+ "use strict";
554
+ module.exports = require("node:path");
555
+
556
+ /***/ }),
557
+
558
+ /***/ 742:
559
+ /***/ ((module) => {
560
+
561
+ "use strict";
562
+ module.exports = require("node:process");
563
+
564
+ /***/ }),
565
+
566
+ /***/ 41:
567
+ /***/ ((module) => {
568
+
569
+ "use strict";
570
+ module.exports = require("node:url");
571
+
572
+ /***/ }),
573
+
574
+ /***/ 37:
575
+ /***/ ((module) => {
576
+
577
+ "use strict";
578
+ module.exports = require("os");
579
+
580
+ /***/ }),
581
+
582
+ /***/ 17:
583
+ /***/ ((module) => {
584
+
585
+ "use strict";
586
+ module.exports = require("path");
587
+
588
+ /***/ }),
589
+
590
+ /***/ 837:
591
+ /***/ ((module) => {
592
+
593
+ "use strict";
594
+ module.exports = require("util");
595
+
596
+ /***/ }),
597
+
598
+ /***/ 796:
599
+ /***/ ((module) => {
600
+
601
+ "use strict";
602
+ module.exports = require("zlib");
603
+
604
+ /***/ }),
605
+
606
+ /***/ 77:
607
+ /***/ ((module) => {
608
+
609
+ "use strict";
610
+ module.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}');
611
+
612
+ /***/ })
613
+
614
+ /******/ });
615
+ /************************************************************************/
616
+ /******/ // The module cache
617
+ /******/ var __webpack_module_cache__ = {};
618
+ /******/
619
+ /******/ // The require function
620
+ /******/ function __nccwpck_require__(moduleId) {
621
+ /******/ // Check if module is in cache
622
+ /******/ var cachedModule = __webpack_module_cache__[moduleId];
623
+ /******/ if (cachedModule !== undefined) {
624
+ /******/ return cachedModule.exports;
625
+ /******/ }
626
+ /******/ // Create a new module (and put it into the cache)
627
+ /******/ var module = __webpack_module_cache__[moduleId] = {
628
+ /******/ // no module.id needed
629
+ /******/ // no module.loaded needed
630
+ /******/ exports: {}
631
+ /******/ };
632
+ /******/
633
+ /******/ // Execute the module function
634
+ /******/ var threw = true;
635
+ /******/ try {
636
+ /******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
637
+ /******/ threw = false;
638
+ /******/ } finally {
639
+ /******/ if(threw) delete __webpack_module_cache__[moduleId];
640
+ /******/ }
641
+ /******/
642
+ /******/ // Return the exports of the module
643
+ /******/ return module.exports;
644
+ /******/ }
645
+ /******/
646
+ /******/ // expose the modules object (__webpack_modules__)
647
+ /******/ __nccwpck_require__.m = __webpack_modules__;
648
+ /******/
649
+ /************************************************************************/
650
+ /******/ /* webpack/runtime/define property getters */
651
+ /******/ (() => {
652
+ /******/ // define getter functions for harmony exports
653
+ /******/ __nccwpck_require__.d = (exports, definition) => {
654
+ /******/ for(var key in definition) {
655
+ /******/ if(__nccwpck_require__.o(definition, key) && !__nccwpck_require__.o(exports, key)) {
656
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
657
+ /******/ }
658
+ /******/ }
659
+ /******/ };
660
+ /******/ })();
661
+ /******/
662
+ /******/ /* webpack/runtime/ensure chunk */
663
+ /******/ (() => {
664
+ /******/ __nccwpck_require__.f = {};
665
+ /******/ // This file contains only the entry chunk.
666
+ /******/ // The chunk loading function for additional chunks
667
+ /******/ __nccwpck_require__.e = (chunkId) => {
668
+ /******/ return Promise.all(Object.keys(__nccwpck_require__.f).reduce((promises, key) => {
669
+ /******/ __nccwpck_require__.f[key](chunkId, promises);
670
+ /******/ return promises;
671
+ /******/ }, []));
672
+ /******/ };
673
+ /******/ })();
674
+ /******/
675
+ /******/ /* webpack/runtime/get javascript chunk filename */
676
+ /******/ (() => {
677
+ /******/ // This function allow to reference async chunks
678
+ /******/ __nccwpck_require__.u = (chunkId) => {
679
+ /******/ // return url for filenames based on template
680
+ /******/ return "" + chunkId + ".index.js";
681
+ /******/ };
682
+ /******/ })();
683
+ /******/
684
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
685
+ /******/ (() => {
686
+ /******/ __nccwpck_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
687
+ /******/ })();
688
+ /******/
689
+ /******/ /* webpack/runtime/make namespace object */
690
+ /******/ (() => {
691
+ /******/ // define __esModule on exports
692
+ /******/ __nccwpck_require__.r = (exports) => {
693
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
694
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
695
+ /******/ }
696
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
697
+ /******/ };
698
+ /******/ })();
699
+ /******/
700
+ /******/ /* webpack/runtime/compat */
701
+ /******/
702
+ /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
703
+ /******/
704
+ /******/ /* webpack/runtime/require chunk loading */
705
+ /******/ (() => {
706
+ /******/ // no baseURI
707
+ /******/
708
+ /******/ // object to store loaded chunks
709
+ /******/ // "1" means "loaded", otherwise not loaded yet
710
+ /******/ var installedChunks = {
711
+ /******/ 179: 1
712
+ /******/ };
713
+ /******/
714
+ /******/ // no on chunks loaded
715
+ /******/
716
+ /******/ var installChunk = (chunk) => {
717
+ /******/ var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;
718
+ /******/ for(var moduleId in moreModules) {
719
+ /******/ if(__nccwpck_require__.o(moreModules, moduleId)) {
720
+ /******/ __nccwpck_require__.m[moduleId] = moreModules[moduleId];
721
+ /******/ }
722
+ /******/ }
723
+ /******/ if(runtime) runtime(__nccwpck_require__);
724
+ /******/ for(var i = 0; i < chunkIds.length; i++)
725
+ /******/ installedChunks[chunkIds[i]] = 1;
726
+ /******/
727
+ /******/ };
728
+ /******/
729
+ /******/ // require() chunk loading for javascript
730
+ /******/ __nccwpck_require__.f.require = (chunkId, promises) => {
731
+ /******/ // "1" is the signal for "already loaded"
732
+ /******/ if(!installedChunks[chunkId]) {
733
+ /******/ if(true) { // all chunks have JS
734
+ /******/ installChunk(require("./" + __nccwpck_require__.u(chunkId)));
735
+ /******/ } else installedChunks[chunkId] = 1;
736
+ /******/ }
737
+ /******/ };
738
+ /******/
739
+ /******/ // no external install chunk
740
+ /******/
741
+ /******/ // no HMR
742
+ /******/
743
+ /******/ // no HMR manifest
744
+ /******/ })();
745
+ /******/
746
+ /************************************************************************/
747
+ /******/
748
+ /******/ // startup
749
+ /******/ // Load entry module and return exports
750
+ /******/ // This entry module is referenced by other modules so it can't be inlined
751
+ /******/ var __webpack_exports__ = __nccwpck_require__(384);
752
+ /******/ module.exports = __webpack_exports__;
753
+ /******/
754
+ /******/ })()
755
+ ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-babel",
3
- "version": "0.6.8",
3
+ "version": "0.6.9",
4
4
  "description": "Babel plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -29,18 +29,18 @@
29
29
  "@babel/preset-typescript": "^7.24.1",
30
30
  "@types/babel__core": "^7.20.5",
31
31
  "upath": "2.0.1",
32
- "@rsbuild/shared": "0.6.8"
32
+ "@rsbuild/shared": "0.6.9"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "18.x",
36
36
  "babel-loader": "9.1.3",
37
- "prebundle": "1.0.3",
37
+ "prebundle": "1.1.0",
38
38
  "typescript": "^5.4.2",
39
- "@rsbuild/core": "0.6.8",
40
- "@scripts/test-helper": "0.6.8"
39
+ "@rsbuild/core": "0.6.9",
40
+ "@scripts/test-helper": "0.6.9"
41
41
  },
42
42
  "peerDependencies": {
43
- "@rsbuild/core": "^0.6.8"
43
+ "@rsbuild/core": "^0.6.9"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public",