@rsbuild/plugin-babel 1.0.7 → 2.0.0-alpha.3
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/index.js +15 -15
- package/dist/index.cjs +9 -11
- package/dist/index.js +9 -11
- package/dist/plugin.d.ts +1 -1
- package/package.json +9 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
605: (module) => {
|
|
4
4
|
const STRIP_FILENAME_RE = /^[^:]+: /;
|
|
5
5
|
const format = (err) => {
|
|
6
6
|
if (err instanceof SyntaxError) {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
}
|
|
27
27
|
module.exports = LoaderError;
|
|
28
28
|
},
|
|
29
|
-
|
|
29
|
+
329: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
30
30
|
const os = __nccwpck_require__(857);
|
|
31
31
|
const path = __nccwpck_require__(928);
|
|
32
32
|
const zlib = __nccwpck_require__(106);
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
const { readFile, writeFile, mkdir } = __nccwpck_require__(943);
|
|
35
35
|
const { sync: findUpSync } = __nccwpck_require__(48);
|
|
36
36
|
const { env } = process;
|
|
37
|
-
const transform = __nccwpck_require__(
|
|
38
|
-
const serialize = __nccwpck_require__(
|
|
37
|
+
const transform = __nccwpck_require__(703);
|
|
38
|
+
const serialize = __nccwpck_require__(725);
|
|
39
39
|
let defaultCacheDirectory = null;
|
|
40
40
|
const gunzip = promisify(zlib.gunzip);
|
|
41
41
|
const gzip = promisify(zlib.gzip);
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
return os.tmpdir();
|
|
166
166
|
}
|
|
167
167
|
},
|
|
168
|
-
|
|
168
|
+
799: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
169
169
|
let babel;
|
|
170
170
|
try {
|
|
171
171
|
babel = __nccwpck_require__(571);
|
|
@@ -184,10 +184,10 @@
|
|
|
184
184
|
);
|
|
185
185
|
}
|
|
186
186
|
const { version } = __nccwpck_require__(344);
|
|
187
|
-
const cache = __nccwpck_require__(
|
|
188
|
-
const transform = __nccwpck_require__(
|
|
189
|
-
const injectCaller = __nccwpck_require__(
|
|
190
|
-
const schema = __nccwpck_require__(
|
|
187
|
+
const cache = __nccwpck_require__(329);
|
|
188
|
+
const transform = __nccwpck_require__(703);
|
|
189
|
+
const injectCaller = __nccwpck_require__(714);
|
|
190
|
+
const schema = __nccwpck_require__(280);
|
|
191
191
|
const { isAbsolute } = __nccwpck_require__(928);
|
|
192
192
|
const { promisify } = __nccwpck_require__(23);
|
|
193
193
|
function subscribe(subscriber, metadata, context) {
|
|
@@ -373,7 +373,7 @@
|
|
|
373
373
|
return [source, inputSourceMap];
|
|
374
374
|
}
|
|
375
375
|
},
|
|
376
|
-
|
|
376
|
+
714: (module) => {
|
|
377
377
|
module.exports = function injectCaller(opts, target) {
|
|
378
378
|
return Object.assign({}, opts, {
|
|
379
379
|
caller: Object.assign(
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
});
|
|
390
390
|
};
|
|
391
391
|
},
|
|
392
|
-
|
|
392
|
+
725: (module) => {
|
|
393
393
|
var objToString = Object.prototype.toString;
|
|
394
394
|
var objKeys = Object.getOwnPropertyNames;
|
|
395
395
|
function serialize(val, isArrayProp) {
|
|
@@ -455,10 +455,10 @@
|
|
|
455
455
|
}
|
|
456
456
|
};
|
|
457
457
|
},
|
|
458
|
-
|
|
458
|
+
703: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
459
459
|
const babel = __nccwpck_require__(571);
|
|
460
460
|
const { promisify } = __nccwpck_require__(23);
|
|
461
|
-
const LoaderError = __nccwpck_require__(
|
|
461
|
+
const LoaderError = __nccwpck_require__(605);
|
|
462
462
|
const transform = promisify(babel.transform);
|
|
463
463
|
module.exports = async function (source, options) {
|
|
464
464
|
let result;
|
|
@@ -809,7 +809,7 @@
|
|
|
809
809
|
"use strict";
|
|
810
810
|
module.exports = require("zlib");
|
|
811
811
|
},
|
|
812
|
-
|
|
812
|
+
280: (module) => {
|
|
813
813
|
"use strict";
|
|
814
814
|
module.exports = JSON.parse(
|
|
815
815
|
'{"title":"Babel Loader options","type":"object","properties":{"cacheDirectory":{"anyOf":[{"type":"boolean"},{"type":"string"}],"default":false},"cacheIdentifier":{"type":"string"},"cacheCompression":{"type":"boolean","default":true},"customize":{"anyOf":[{"type":"null"},{"type":"string"}],"default":null},"metadataSubscribers":{"type":"array"}},"additionalProperties":true}',
|
|
@@ -838,6 +838,6 @@
|
|
|
838
838
|
}
|
|
839
839
|
if (typeof __nccwpck_require__ !== "undefined")
|
|
840
840
|
__nccwpck_require__.ab = __dirname + "/";
|
|
841
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
841
|
+
var __webpack_exports__ = __nccwpck_require__(799);
|
|
842
842
|
module.exports = __webpack_exports__;
|
|
843
843
|
})();
|
package/dist/index.cjs
CHANGED
|
@@ -98,14 +98,11 @@ const BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array
|
|
|
98
98
|
}
|
|
99
99
|
return defaultOptions;
|
|
100
100
|
}, modifyBabelLoaderOptions = ({ chain, CHAIN_ID, modifier })=>{
|
|
101
|
-
for (let
|
|
102
|
-
CHAIN_ID.RULE.JS,
|
|
103
|
-
CHAIN_ID.RULE.JS_DATA_URI,
|
|
104
|
-
BABEL_JS_RULE
|
|
105
|
-
])
|
|
106
|
-
let rule = chain.module.rule(ruleId);
|
|
107
|
-
rule.uses.has(CHAIN_ID.USE.BABEL) && rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
|
|
108
|
-
}
|
|
101
|
+
for (let rule of [
|
|
102
|
+
chain.module.rules.get(CHAIN_ID.RULE.JS).oneOfs.get(CHAIN_ID.ONE_OF.JS_MAIN),
|
|
103
|
+
chain.module.rules.get(CHAIN_ID.RULE.JS_DATA_URI),
|
|
104
|
+
chain.module.rules.get(BABEL_JS_RULE)
|
|
105
|
+
].filter(Boolean))rule.uses.has(CHAIN_ID.USE.BABEL) && rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
|
|
109
106
|
}, external_node_fs_namespaceObject = require("node:fs");
|
|
110
107
|
var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
|
|
111
108
|
const external_node_module_namespaceObject = require("node:module"), external_node_url_namespaceObject = require("node:url"), external_deepmerge_namespaceObject = require("deepmerge");
|
|
@@ -124,7 +121,7 @@ async function getCacheIdentifier(options) {
|
|
|
124
121
|
let identifier = `${process.env.NODE_ENV}${JSON.stringify(options)}`, { version: coreVersion } = await import("@babel/core"), loaderVersion = JSON.parse(await external_node_fs_default().promises.readFile((0, external_node_path_namespaceObject.join)(plugin_dirname, '../compiled/babel-loader/package.json'), 'utf-8')).version ?? '';
|
|
125
122
|
return identifier + `@babel/core@${coreVersion}babel-loader@${loaderVersion}`;
|
|
126
123
|
}
|
|
127
|
-
|
|
124
|
+
function getDefaultBabelOptions(config, context) {
|
|
128
125
|
let isLegacyDecorators = 'legacy' === config.source.decorators.version, options = {
|
|
129
126
|
babelrc: !1,
|
|
130
127
|
configFile: !1,
|
|
@@ -150,7 +147,8 @@ const getDefaultBabelOptions = (config, context)=>{
|
|
|
150
147
|
options.cacheCompression = !1, options.cacheDirectory = (0, external_node_path_namespaceObject.join)(cacheDirectory, 'babel-loader');
|
|
151
148
|
}
|
|
152
149
|
return options;
|
|
153
|
-
}
|
|
150
|
+
}
|
|
151
|
+
const pluginBabel = (options = {})=>({
|
|
154
152
|
name: PLUGIN_BABEL_NAME,
|
|
155
153
|
setup (api) {
|
|
156
154
|
let getBabelOptions = async (environment)=>{
|
|
@@ -166,7 +164,7 @@ const getDefaultBabelOptions = (config, context)=>{
|
|
|
166
164
|
if (include) for (let condition of castArray(include))rule.include.add(condition);
|
|
167
165
|
if (exclude) for (let condition of castArray(exclude))rule.exclude.add(condition);
|
|
168
166
|
rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).loader(babelLoader).options(babelOptions);
|
|
169
|
-
} else chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(babelLoader).options(babelOptions);
|
|
167
|
+
} else chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).oneOfs.get(CHAIN_ID.ONE_OF.JS_MAIN).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(babelLoader).options(babelOptions);
|
|
170
168
|
}
|
|
171
169
|
});
|
|
172
170
|
}
|
package/dist/index.js
CHANGED
|
@@ -56,14 +56,11 @@ let BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.i
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
}, modifyBabelLoaderOptions = ({ chain, CHAIN_ID, modifier })=>{
|
|
59
|
-
for (let
|
|
60
|
-
CHAIN_ID.RULE.JS,
|
|
61
|
-
CHAIN_ID.RULE.JS_DATA_URI,
|
|
62
|
-
BABEL_JS_RULE
|
|
63
|
-
])
|
|
64
|
-
let rule = chain.module.rule(ruleId);
|
|
65
|
-
rule.uses.has(CHAIN_ID.USE.BABEL) && rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
|
|
66
|
-
}
|
|
59
|
+
for (let rule of [
|
|
60
|
+
chain.module.rules.get(CHAIN_ID.RULE.JS).oneOfs.get(CHAIN_ID.ONE_OF.JS_MAIN),
|
|
61
|
+
chain.module.rules.get(CHAIN_ID.RULE.JS_DATA_URI),
|
|
62
|
+
chain.module.rules.get(BABEL_JS_RULE)
|
|
63
|
+
].filter(Boolean))rule.uses.has(CHAIN_ID.USE.BABEL) && rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
|
|
67
64
|
}, plugin_dirname = node_path.dirname(fileURLToPath(import.meta.url)), plugin_require = createRequire(import.meta.url), PLUGIN_BABEL_NAME = 'rsbuild:babel', SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
|
68
65
|
allowNamespaces: !0,
|
|
69
66
|
allExtensions: !0,
|
|
@@ -78,7 +75,7 @@ async function getCacheIdentifier(options) {
|
|
|
78
75
|
let identifier = `${process.env.NODE_ENV}${JSON.stringify(options)}`, { version: coreVersion } = await import("@babel/core"), loaderVersion = JSON.parse(await node_fs.promises.readFile(join(plugin_dirname, '../compiled/babel-loader/package.json'), 'utf-8')).version ?? '';
|
|
79
76
|
return identifier + `@babel/core@${coreVersion}babel-loader@${loaderVersion}`;
|
|
80
77
|
}
|
|
81
|
-
|
|
78
|
+
function getDefaultBabelOptions(config, context) {
|
|
82
79
|
let isLegacyDecorators = 'legacy' === config.source.decorators.version, options = {
|
|
83
80
|
babelrc: !1,
|
|
84
81
|
configFile: !1,
|
|
@@ -104,7 +101,8 @@ let getDefaultBabelOptions = (config, context)=>{
|
|
|
104
101
|
options.cacheCompression = !1, options.cacheDirectory = join(cacheDirectory, 'babel-loader');
|
|
105
102
|
}
|
|
106
103
|
return options;
|
|
107
|
-
}
|
|
104
|
+
}
|
|
105
|
+
let pluginBabel = (options = {})=>({
|
|
108
106
|
name: PLUGIN_BABEL_NAME,
|
|
109
107
|
setup (api) {
|
|
110
108
|
let getBabelOptions = async (environment)=>{
|
|
@@ -133,7 +131,7 @@ let getDefaultBabelOptions = (config, context)=>{
|
|
|
133
131
|
if (include) for (let condition of castArray(include))rule.include.add(condition);
|
|
134
132
|
if (exclude) for (let condition of castArray(exclude))rule.exclude.add(condition);
|
|
135
133
|
rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).loader(babelLoader).options(babelOptions);
|
|
136
|
-
} else chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(babelLoader).options(babelOptions);
|
|
134
|
+
} else chain.module.rule(CHAIN_ID.RULE.JS).test(SCRIPT_REGEX).oneOfs.get(CHAIN_ID.ONE_OF.JS_MAIN).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(babelLoader).options(babelOptions);
|
|
137
135
|
}
|
|
138
136
|
});
|
|
139
137
|
}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NormalizedEnvironmentConfig, RsbuildContext, RsbuildPlugin } from '@rsbuild/core';
|
|
2
2
|
import type { BabelLoaderOptions, PluginBabelOptions } from './types.js';
|
|
3
3
|
export declare const PLUGIN_BABEL_NAME = "rsbuild:babel";
|
|
4
|
-
export declare
|
|
4
|
+
export declare function getDefaultBabelOptions(config: NormalizedEnvironmentConfig, context: RsbuildContext): BabelLoaderOptions;
|
|
5
5
|
export declare const pluginBabel: (options?: PluginBabelOptions) => RsbuildPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-babel",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.3",
|
|
4
4
|
"description": "Babel plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"compiled"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@babel/core": "^7.28.
|
|
27
|
-
"@babel/plugin-proposal-decorators": "^7.28.
|
|
28
|
-
"@babel/plugin-transform-class-properties": "^7.
|
|
26
|
+
"@babel/core": "^7.28.6",
|
|
27
|
+
"@babel/plugin-proposal-decorators": "^7.28.6",
|
|
28
|
+
"@babel/plugin-transform-class-properties": "^7.28.6",
|
|
29
29
|
"@babel/preset-typescript": "^7.28.5",
|
|
30
30
|
"@types/babel__core": "^7.20.5",
|
|
31
31
|
"deepmerge": "^4.3.1",
|
|
@@ -33,16 +33,16 @@
|
|
|
33
33
|
"upath": "2.0.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@rslib/core": "0.19.
|
|
37
|
-
"@types/node": "^24.10.
|
|
36
|
+
"@rslib/core": "0.19.3",
|
|
37
|
+
"@types/node": "^24.10.9",
|
|
38
38
|
"babel-loader": "10.0.0",
|
|
39
|
-
"prebundle": "1.6.
|
|
39
|
+
"prebundle": "1.6.2",
|
|
40
40
|
"typescript": "^5.9.3",
|
|
41
|
-
"@rsbuild/core": "
|
|
41
|
+
"@rsbuild/core": "2.0.0-alpha.3",
|
|
42
42
|
"@scripts/test-helper": "1.0.1"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"@rsbuild/core": "^
|
|
45
|
+
"@rsbuild/core": "^2.0.0-0"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public",
|