@rsbuild/plugin-babel 0.2.15 → 0.2.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/compiled/babel-loader/{583.index.js → 672.index.js} +5 -5
- package/compiled/babel-loader/index.js +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +20 -17
- package/dist/index.mjs +21 -19
- package/package.json +4 -4
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports.id =
|
|
3
|
-
exports.ids = [
|
|
2
|
+
exports.id = 672;
|
|
3
|
+
exports.ids = [672];
|
|
4
4
|
exports.modules = {
|
|
5
5
|
|
|
6
|
-
/***/
|
|
6
|
+
/***/ 641:
|
|
7
7
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
8
8
|
|
|
9
9
|
|
|
@@ -43,7 +43,7 @@ module.exports = function commonPathPrefix (paths, sep = determineSeparator(path
|
|
|
43
43
|
|
|
44
44
|
/***/ }),
|
|
45
45
|
|
|
46
|
-
/***/
|
|
46
|
+
/***/ 672:
|
|
47
47
|
/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
|
|
48
48
|
|
|
49
49
|
// ESM COMPAT FLAG
|
|
@@ -61,7 +61,7 @@ var external_node_path_ = __webpack_require__(411);
|
|
|
61
61
|
// EXTERNAL MODULE: external "node:fs"
|
|
62
62
|
var external_node_fs_ = __webpack_require__(561);
|
|
63
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__(
|
|
64
|
+
var common_path_prefix = __webpack_require__(641);
|
|
65
65
|
// EXTERNAL MODULE: external "node:url"
|
|
66
66
|
var external_node_url_ = __webpack_require__(41);
|
|
67
67
|
;// CONCATENATED MODULE: ../../node_modules/.pnpm/yocto-queue@1.0.0/node_modules/yocto-queue/index.js
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={
|
|
1
|
+
(()=>{var e={396: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},142:(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(416);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)}},632:(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(142);const i=r(416);const n=r(120);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]}},120:(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}},416:(e,t,r)=>{const o=r(718);const{promisify:s}=r(837);const a=r(396);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__(632);module.exports=r})();
|
package/dist/index.d.ts
CHANGED
|
@@ -66,6 +66,19 @@ type PluginBabelOptions = {
|
|
|
66
66
|
babelLoaderOptions?: ChainedConfigWithUtils<TransformOptions, BabelConfigUtils>;
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
+
declare const getDefaultBabelOptions: () => {
|
|
70
|
+
babelrc: boolean;
|
|
71
|
+
configFile: boolean;
|
|
72
|
+
compact: boolean;
|
|
73
|
+
plugins: never[];
|
|
74
|
+
presets: (string | {
|
|
75
|
+
allowNamespaces: boolean;
|
|
76
|
+
allExtensions: boolean;
|
|
77
|
+
allowDeclareFields: boolean;
|
|
78
|
+
optimizeConstEnums: boolean;
|
|
79
|
+
isTSX: boolean;
|
|
80
|
+
})[][];
|
|
81
|
+
};
|
|
69
82
|
declare const pluginBabel: (options?: PluginBabelOptions) => RsbuildPlugin;
|
|
70
83
|
|
|
71
84
|
declare const getBabelUtils: (config: TransformOptions) => BabelConfigUtils;
|
|
@@ -76,4 +89,4 @@ declare const modifyBabelLoaderOptions: ({ chain, CHAIN_ID, modifier, }: {
|
|
|
76
89
|
modifier: (config: TransformOptions) => TransformOptions;
|
|
77
90
|
}) => void;
|
|
78
91
|
|
|
79
|
-
export { BabelConfigUtils, PluginBabelOptions, PresetEnvBuiltIns, PresetEnvOptions, PresetEnvTargets, getBabelUtils, getUseBuiltIns, modifyBabelLoaderOptions, pluginBabel };
|
|
92
|
+
export { BabelConfigUtils, PluginBabelOptions, PresetEnvBuiltIns, PresetEnvOptions, PresetEnvTargets, getBabelUtils, getDefaultBabelOptions, getUseBuiltIns, modifyBabelLoaderOptions, pluginBabel };
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
getBabelUtils: () => getBabelUtils,
|
|
34
|
+
getDefaultBabelOptions: () => getDefaultBabelOptions,
|
|
34
35
|
getUseBuiltIns: () => getUseBuiltIns,
|
|
35
36
|
modifyBabelLoaderOptions: () => modifyBabelLoaderOptions,
|
|
36
37
|
pluginBabel: () => pluginBabel
|
|
@@ -181,31 +182,32 @@ var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
|
|
181
182
|
optimizeConstEnums: true,
|
|
182
183
|
isTSX: true
|
|
183
184
|
};
|
|
185
|
+
var getDefaultBabelOptions = () => {
|
|
186
|
+
return {
|
|
187
|
+
babelrc: false,
|
|
188
|
+
configFile: false,
|
|
189
|
+
compact: (0, import_shared2.isProd)(),
|
|
190
|
+
plugins: [],
|
|
191
|
+
presets: [
|
|
192
|
+
// TODO: only apply preset-typescript for ts file (isTSX & allExtensions false)
|
|
193
|
+
[
|
|
194
|
+
require.resolve("@babel/preset-typescript"),
|
|
195
|
+
DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
|
|
196
|
+
]
|
|
197
|
+
]
|
|
198
|
+
};
|
|
199
|
+
};
|
|
184
200
|
var pluginBabel = (options = {}) => ({
|
|
185
201
|
name: "rsbuild:babel",
|
|
186
202
|
setup(api) {
|
|
187
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID
|
|
203
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
188
204
|
const getBabelOptions = () => {
|
|
189
|
-
const baseConfig =
|
|
190
|
-
plugins: [],
|
|
191
|
-
presets: [
|
|
192
|
-
// TODO: only apply preset-typescript for ts file (isTSX & allExtensions false)
|
|
193
|
-
[
|
|
194
|
-
require.resolve("@babel/preset-typescript"),
|
|
195
|
-
DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
|
|
196
|
-
]
|
|
197
|
-
]
|
|
198
|
-
};
|
|
205
|
+
const baseConfig = getDefaultBabelOptions();
|
|
199
206
|
const userBabelConfig = applyUserBabelConfig(
|
|
200
207
|
(0, import_shared2.cloneDeep)(baseConfig),
|
|
201
208
|
options.babelLoaderOptions
|
|
202
209
|
);
|
|
203
|
-
return
|
|
204
|
-
babelrc: false,
|
|
205
|
-
configFile: false,
|
|
206
|
-
compact: isProd,
|
|
207
|
-
...userBabelConfig
|
|
208
|
-
};
|
|
210
|
+
return userBabelConfig;
|
|
209
211
|
};
|
|
210
212
|
const babelOptions = getBabelOptions();
|
|
211
213
|
const babelLoader = import_path2.default.resolve(
|
|
@@ -239,6 +241,7 @@ var pluginBabel = (options = {}) => ({
|
|
|
239
241
|
// Annotate the CommonJS export names for ESM import in node:
|
|
240
242
|
0 && (module.exports = {
|
|
241
243
|
getBabelUtils,
|
|
244
|
+
getDefaultBabelOptions,
|
|
242
245
|
getUseBuiltIns,
|
|
243
246
|
modifyBabelLoaderOptions,
|
|
244
247
|
pluginBabel
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
6
6
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
// ../../node_modules/.pnpm/@modern-js+module-tools@2.
|
|
9
|
+
// ../../node_modules/.pnpm/@modern-js+module-tools@2.45.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
12
|
var getFilename = () => fileURLToPath(import.meta.url);
|
|
@@ -19,7 +19,7 @@ global.require = createRequire(import.meta.url);
|
|
|
19
19
|
|
|
20
20
|
// src/plugin.ts
|
|
21
21
|
import path2 from "path";
|
|
22
|
-
import { castArray as castArray2, cloneDeep, SCRIPT_REGEX } from "@rsbuild/shared";
|
|
22
|
+
import { castArray as castArray2, cloneDeep, SCRIPT_REGEX, isProd } from "@rsbuild/shared";
|
|
23
23
|
|
|
24
24
|
// src/helper.ts
|
|
25
25
|
import { isAbsolute, normalize, sep } from "path";
|
|
@@ -164,31 +164,32 @@ var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
|
|
164
164
|
optimizeConstEnums: true,
|
|
165
165
|
isTSX: true
|
|
166
166
|
};
|
|
167
|
+
var getDefaultBabelOptions = () => {
|
|
168
|
+
return {
|
|
169
|
+
babelrc: false,
|
|
170
|
+
configFile: false,
|
|
171
|
+
compact: isProd(),
|
|
172
|
+
plugins: [],
|
|
173
|
+
presets: [
|
|
174
|
+
// TODO: only apply preset-typescript for ts file (isTSX & allExtensions false)
|
|
175
|
+
[
|
|
176
|
+
__require.resolve("@babel/preset-typescript"),
|
|
177
|
+
DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
|
|
178
|
+
]
|
|
179
|
+
]
|
|
180
|
+
};
|
|
181
|
+
};
|
|
167
182
|
var pluginBabel = (options = {}) => ({
|
|
168
183
|
name: "rsbuild:babel",
|
|
169
184
|
setup(api) {
|
|
170
|
-
api.modifyBundlerChain(async (chain, { CHAIN_ID
|
|
185
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
171
186
|
const getBabelOptions = () => {
|
|
172
|
-
const baseConfig =
|
|
173
|
-
plugins: [],
|
|
174
|
-
presets: [
|
|
175
|
-
// TODO: only apply preset-typescript for ts file (isTSX & allExtensions false)
|
|
176
|
-
[
|
|
177
|
-
__require.resolve("@babel/preset-typescript"),
|
|
178
|
-
DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
|
|
179
|
-
]
|
|
180
|
-
]
|
|
181
|
-
};
|
|
187
|
+
const baseConfig = getDefaultBabelOptions();
|
|
182
188
|
const userBabelConfig = applyUserBabelConfig(
|
|
183
189
|
cloneDeep(baseConfig),
|
|
184
190
|
options.babelLoaderOptions
|
|
185
191
|
);
|
|
186
|
-
return
|
|
187
|
-
babelrc: false,
|
|
188
|
-
configFile: false,
|
|
189
|
-
compact: isProd,
|
|
190
|
-
...userBabelConfig
|
|
191
|
-
};
|
|
192
|
+
return userBabelConfig;
|
|
192
193
|
};
|
|
193
194
|
const babelOptions = getBabelOptions();
|
|
194
195
|
const babelLoader = path2.resolve(
|
|
@@ -221,6 +222,7 @@ var pluginBabel = (options = {}) => ({
|
|
|
221
222
|
});
|
|
222
223
|
export {
|
|
223
224
|
getBabelUtils,
|
|
225
|
+
getDefaultBabelOptions,
|
|
224
226
|
getUseBuiltIns,
|
|
225
227
|
modifyBabelLoaderOptions,
|
|
226
228
|
pluginBabel
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-babel",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "Babel plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -27,13 +27,13 @@
|
|
|
27
27
|
"@babel/preset-typescript": "^7.23.2",
|
|
28
28
|
"@types/babel__core": "^7.20.3",
|
|
29
29
|
"upath": "2.0.1",
|
|
30
|
-
"@rsbuild/shared": "0.2.
|
|
30
|
+
"@rsbuild/shared": "0.2.17"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "16.x",
|
|
34
34
|
"typescript": "^5.3.0",
|
|
35
|
-
"@rsbuild/core": "0.2.
|
|
36
|
-
"@rsbuild/test-helper": "0.2.
|
|
35
|
+
"@rsbuild/core": "0.2.17",
|
|
36
|
+
"@rsbuild/test-helper": "0.2.17"
|
|
37
37
|
},
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public",
|