@rsbuild/plugin-babel 1.0.2 → 1.0.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 +13 -13
- package/dist/index.cjs +13 -15
- package/dist/index.js +8 -15
- package/package.json +7 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(() => {
|
|
2
2
|
var __webpack_modules__ = {
|
|
3
|
-
|
|
3
|
+
666: (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
|
+
598: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
30
30
|
const os = __nccwpck_require__(37);
|
|
31
31
|
const path = __nccwpck_require__(17);
|
|
32
32
|
const zlib = __nccwpck_require__(796);
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
const findCacheDirP = __nccwpck_require__
|
|
37
37
|
.e(672)
|
|
38
38
|
.then(__nccwpck_require__.bind(__nccwpck_require__, 672));
|
|
39
|
-
const transform = __nccwpck_require__(
|
|
39
|
+
const transform = __nccwpck_require__(470);
|
|
40
40
|
let defaultCacheDirectory = null;
|
|
41
41
|
let hashType = "sha256";
|
|
42
42
|
try {
|
|
@@ -122,7 +122,7 @@
|
|
|
122
122
|
return await handleCache(directory, params);
|
|
123
123
|
};
|
|
124
124
|
},
|
|
125
|
-
|
|
125
|
+
769: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
126
126
|
let babel;
|
|
127
127
|
try {
|
|
128
128
|
babel = __nccwpck_require__(718);
|
|
@@ -141,10 +141,10 @@
|
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
const { version } = __nccwpck_require__(684);
|
|
144
|
-
const cache = __nccwpck_require__(
|
|
145
|
-
const transform = __nccwpck_require__(
|
|
146
|
-
const injectCaller = __nccwpck_require__(
|
|
147
|
-
const schema = __nccwpck_require__(
|
|
144
|
+
const cache = __nccwpck_require__(598);
|
|
145
|
+
const transform = __nccwpck_require__(470);
|
|
146
|
+
const injectCaller = __nccwpck_require__(172);
|
|
147
|
+
const schema = __nccwpck_require__(383);
|
|
148
148
|
const { isAbsolute } = __nccwpck_require__(17);
|
|
149
149
|
const validateOptions = __nccwpck_require__(14).validate;
|
|
150
150
|
function subscribe(subscriber, metadata, context) {
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
return [source, inputSourceMap];
|
|
328
328
|
}
|
|
329
329
|
},
|
|
330
|
-
|
|
330
|
+
172: (module) => {
|
|
331
331
|
module.exports = function injectCaller(opts, target) {
|
|
332
332
|
return Object.assign({}, opts, {
|
|
333
333
|
caller: Object.assign(
|
|
@@ -343,10 +343,10 @@
|
|
|
343
343
|
});
|
|
344
344
|
};
|
|
345
345
|
},
|
|
346
|
-
|
|
346
|
+
470: (module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
347
347
|
const babel = __nccwpck_require__(718);
|
|
348
348
|
const { promisify } = __nccwpck_require__(837);
|
|
349
|
-
const LoaderError = __nccwpck_require__(
|
|
349
|
+
const LoaderError = __nccwpck_require__(666);
|
|
350
350
|
const transform = promisify(babel.transform);
|
|
351
351
|
module.exports = async function (source, options) {
|
|
352
352
|
let result;
|
|
@@ -424,7 +424,7 @@
|
|
|
424
424
|
"use strict";
|
|
425
425
|
module.exports = require("zlib");
|
|
426
426
|
},
|
|
427
|
-
|
|
427
|
+
383: (module) => {
|
|
428
428
|
"use strict";
|
|
429
429
|
module.exports = JSON.parse(
|
|
430
430
|
'{"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}',
|
|
@@ -517,6 +517,6 @@
|
|
|
517
517
|
}
|
|
518
518
|
};
|
|
519
519
|
})();
|
|
520
|
-
var __webpack_exports__ = __nccwpck_require__(
|
|
520
|
+
var __webpack_exports__ = __nccwpck_require__(769);
|
|
521
521
|
module.exports = __webpack_exports__;
|
|
522
522
|
})();
|
package/dist/index.cjs
CHANGED
|
@@ -22,7 +22,7 @@ function __webpack_require__(moduleId) {
|
|
|
22
22
|
}
|
|
23
23
|
/************************************************************************/ // webpack/runtime/compat_get_default_export
|
|
24
24
|
(()=>{
|
|
25
|
-
// getDefaultExport function for compatibility with non-
|
|
25
|
+
// getDefaultExport function for compatibility with non-ESM modules
|
|
26
26
|
__webpack_require__.n = function(module1) {
|
|
27
27
|
var getter = module1 && module1.__esModule ? function() {
|
|
28
28
|
return module1['default'];
|
|
@@ -120,6 +120,7 @@ var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node
|
|
|
120
120
|
const external_node_module_namespaceObject = require("node:module");
|
|
121
121
|
const external_node_path_namespaceObject = require("node:path");
|
|
122
122
|
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
123
|
+
const external_node_url_namespaceObject = require("node:url");
|
|
123
124
|
const external_deepmerge_namespaceObject = require("deepmerge");
|
|
124
125
|
var external_deepmerge_default = /*#__PURE__*/ __webpack_require__.n(external_deepmerge_namespaceObject);
|
|
125
126
|
const external_reduce_configs_namespaceObject = require("reduce-configs");
|
|
@@ -133,7 +134,7 @@ const castArray = (arr)=>{
|
|
|
133
134
|
];
|
|
134
135
|
};
|
|
135
136
|
const normalizeToPosixPath = (p)=>external_upath_default().normalizeSafe((0, external_node_path_namespaceObject.normalize)(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
|
|
136
|
-
// compatible with
|
|
137
|
+
// compatible with Windows path
|
|
137
138
|
const formatPath = (originPath)=>{
|
|
138
139
|
if ((0, external_node_path_namespaceObject.isAbsolute)(originPath)) return originPath.split(external_node_path_namespaceObject.sep).join('/');
|
|
139
140
|
return originPath;
|
|
@@ -169,8 +170,7 @@ const removePresets = (presets, config)=>{
|
|
|
169
170
|
return true;
|
|
170
171
|
});
|
|
171
172
|
};
|
|
172
|
-
const modifyPresetOptions =
|
|
173
|
-
let presets = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : [];
|
|
173
|
+
const modifyPresetOptions = (presetName, options, presets = [])=>{
|
|
174
174
|
presets.forEach((preset, index)=>{
|
|
175
175
|
// 1. ['@babel/preset-env', ...]
|
|
176
176
|
if (Array.isArray(preset)) {
|
|
@@ -215,8 +215,7 @@ const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils)=
|
|
|
215
215
|
}
|
|
216
216
|
return defaultOptions;
|
|
217
217
|
};
|
|
218
|
-
const modifyBabelLoaderOptions = (
|
|
219
|
-
let { chain, CHAIN_ID, modifier } = param;
|
|
218
|
+
const modifyBabelLoaderOptions = ({ chain, CHAIN_ID, modifier })=>{
|
|
220
219
|
const ruleIds = [
|
|
221
220
|
CHAIN_ID.RULE.JS,
|
|
222
221
|
CHAIN_ID.RULE.JS_DATA_URI,
|
|
@@ -227,6 +226,9 @@ const modifyBabelLoaderOptions = (param)=>{
|
|
|
227
226
|
if (rule.uses.has(CHAIN_ID.USE.BABEL)) rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
|
|
228
227
|
}
|
|
229
228
|
};
|
|
229
|
+
const plugin_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(/*#__PURE__*/ function() {
|
|
230
|
+
return 'undefined' == typeof document ? new (module.require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
231
|
+
}()));
|
|
230
232
|
const plugin_require = (0, external_node_module_namespaceObject.createRequire)(/*#__PURE__*/ function() {
|
|
231
233
|
return 'undefined' == typeof document ? new (module.require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
|
|
232
234
|
}());
|
|
@@ -250,7 +252,7 @@ function getCacheDirectory(context, cacheDirectory) {
|
|
|
250
252
|
async function getCacheIdentifier(options) {
|
|
251
253
|
let identifier = `${process.env.NODE_ENV}${JSON.stringify(options)}`;
|
|
252
254
|
const { version: coreVersion } = await Promise.resolve().then(__webpack_require__.t.bind(__webpack_require__, "@babel/core", 23));
|
|
253
|
-
const rawPkgJson = await external_node_fs_default().promises.readFile((0, external_node_path_namespaceObject.join)(
|
|
255
|
+
const rawPkgJson = await external_node_fs_default().promises.readFile((0, external_node_path_namespaceObject.join)(plugin_dirname, '../compiled/babel-loader/package.json'), 'utf-8');
|
|
254
256
|
const loaderVersion = JSON.parse(rawPkgJson).version ?? '';
|
|
255
257
|
identifier += `@babel/core@${coreVersion}`;
|
|
256
258
|
identifier += `babel-loader@${loaderVersion}`;
|
|
@@ -292,9 +294,7 @@ const getDefaultBabelOptions = (config, context)=>{
|
|
|
292
294
|
}
|
|
293
295
|
return options;
|
|
294
296
|
};
|
|
295
|
-
const pluginBabel =
|
|
296
|
-
let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
297
|
-
return {
|
|
297
|
+
const pluginBabel = (options = {})=>({
|
|
298
298
|
name: PLUGIN_BABEL_NAME,
|
|
299
299
|
setup (api) {
|
|
300
300
|
const getBabelOptions = async (environment)=>{
|
|
@@ -307,10 +307,9 @@ const pluginBabel = function() {
|
|
|
307
307
|
};
|
|
308
308
|
api.modifyBundlerChain({
|
|
309
309
|
order: 'pre',
|
|
310
|
-
handler: async (chain,
|
|
311
|
-
let { CHAIN_ID, environment } = param;
|
|
310
|
+
handler: async (chain, { CHAIN_ID, environment })=>{
|
|
312
311
|
const babelOptions = await getBabelOptions(environment);
|
|
313
|
-
const babelLoader = external_node_path_default().resolve(
|
|
312
|
+
const babelLoader = external_node_path_default().resolve(plugin_dirname, '../compiled/babel-loader/index.js');
|
|
314
313
|
const { include, exclude } = options;
|
|
315
314
|
if (include || exclude) {
|
|
316
315
|
const rule = chain.module.rule(BABEL_JS_RULE) // run babel loader before the builtin SWC loader
|
|
@@ -327,8 +326,7 @@ const pluginBabel = function() {
|
|
|
327
326
|
}
|
|
328
327
|
});
|
|
329
328
|
}
|
|
330
|
-
};
|
|
331
|
-
};
|
|
329
|
+
});
|
|
332
330
|
var __webpack_export_target__ = exports;
|
|
333
331
|
for(var i in __webpack_exports__)__webpack_export_target__[i] = __webpack_exports__[i];
|
|
334
332
|
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { fileURLToPath as __webpack_fileURLToPath__ } from "url";
|
|
2
|
-
import { dirname as __webpack_dirname__ } from "path";
|
|
3
1
|
import * as __WEBPACK_EXTERNAL_MODULE_node_fs__ from "node:fs";
|
|
4
2
|
import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
|
|
5
3
|
import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_url__ from "node:url";
|
|
6
5
|
import * as __WEBPACK_EXTERNAL_MODULE_deepmerge__ from "deepmerge";
|
|
7
6
|
import * as __WEBPACK_EXTERNAL_MODULE_reduce_configs__ from "reduce-configs";
|
|
8
7
|
import * as __WEBPACK_EXTERNAL_MODULE_upath__ from "upath";
|
|
@@ -14,7 +13,7 @@ const castArray = (arr)=>{
|
|
|
14
13
|
];
|
|
15
14
|
};
|
|
16
15
|
const normalizeToPosixPath = (p)=>__WEBPACK_EXTERNAL_MODULE_upath__["default"].normalizeSafe((0, __WEBPACK_EXTERNAL_MODULE_node_path__.normalize)(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
|
|
17
|
-
// compatible with
|
|
16
|
+
// compatible with Windows path
|
|
18
17
|
const formatPath = (originPath)=>{
|
|
19
18
|
if ((0, __WEBPACK_EXTERNAL_MODULE_node_path__.isAbsolute)(originPath)) return originPath.split(__WEBPACK_EXTERNAL_MODULE_node_path__.sep).join('/');
|
|
20
19
|
return originPath;
|
|
@@ -50,8 +49,7 @@ const removePresets = (presets, config)=>{
|
|
|
50
49
|
return true;
|
|
51
50
|
});
|
|
52
51
|
};
|
|
53
|
-
const modifyPresetOptions =
|
|
54
|
-
let presets = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : [];
|
|
52
|
+
const modifyPresetOptions = (presetName, options, presets = [])=>{
|
|
55
53
|
presets.forEach((preset, index)=>{
|
|
56
54
|
// 1. ['@babel/preset-env', ...]
|
|
57
55
|
if (Array.isArray(preset)) {
|
|
@@ -96,8 +94,7 @@ const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils)=
|
|
|
96
94
|
}
|
|
97
95
|
return defaultOptions;
|
|
98
96
|
};
|
|
99
|
-
const modifyBabelLoaderOptions = (
|
|
100
|
-
let { chain, CHAIN_ID, modifier } = param;
|
|
97
|
+
const modifyBabelLoaderOptions = ({ chain, CHAIN_ID, modifier })=>{
|
|
101
98
|
const ruleIds = [
|
|
102
99
|
CHAIN_ID.RULE.JS,
|
|
103
100
|
CHAIN_ID.RULE.JS_DATA_URI,
|
|
@@ -108,7 +105,7 @@ const modifyBabelLoaderOptions = (param)=>{
|
|
|
108
105
|
if (rule.uses.has(CHAIN_ID.USE.BABEL)) rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
|
|
109
106
|
}
|
|
110
107
|
};
|
|
111
|
-
|
|
108
|
+
const plugin_dirname = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url__.fileURLToPath)(import.meta.url));
|
|
112
109
|
const plugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
|
|
113
110
|
const PLUGIN_BABEL_NAME = 'rsbuild:babel';
|
|
114
111
|
const SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/;
|
|
@@ -172,9 +169,7 @@ const getDefaultBabelOptions = (config, context)=>{
|
|
|
172
169
|
}
|
|
173
170
|
return options;
|
|
174
171
|
};
|
|
175
|
-
const pluginBabel =
|
|
176
|
-
let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
177
|
-
return {
|
|
172
|
+
const pluginBabel = (options = {})=>({
|
|
178
173
|
name: PLUGIN_BABEL_NAME,
|
|
179
174
|
setup (api) {
|
|
180
175
|
const getBabelOptions = async (environment)=>{
|
|
@@ -187,8 +182,7 @@ const pluginBabel = function() {
|
|
|
187
182
|
};
|
|
188
183
|
api.modifyBundlerChain({
|
|
189
184
|
order: 'pre',
|
|
190
|
-
handler: async (chain,
|
|
191
|
-
let { CHAIN_ID, environment } = param;
|
|
185
|
+
handler: async (chain, { CHAIN_ID, environment })=>{
|
|
192
186
|
const babelOptions = await getBabelOptions(environment);
|
|
193
187
|
const babelLoader = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].resolve(plugin_dirname, '../compiled/babel-loader/index.js');
|
|
194
188
|
const { include, exclude } = options;
|
|
@@ -207,6 +201,5 @@ const pluginBabel = function() {
|
|
|
207
201
|
}
|
|
208
202
|
});
|
|
209
203
|
}
|
|
210
|
-
};
|
|
211
|
-
};
|
|
204
|
+
});
|
|
212
205
|
export { PLUGIN_BABEL_NAME, getBabelUtils, getDefaultBabelOptions, modifyBabelLoaderOptions, pluginBabel };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-babel",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "Babel plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"compiled"
|
|
24
24
|
],
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@babel/core": "^7.
|
|
27
|
-
"@babel/plugin-proposal-decorators": "^7.25.
|
|
28
|
-
"@babel/plugin-transform-class-properties": "^7.25.
|
|
29
|
-
"@babel/preset-typescript": "^7.
|
|
26
|
+
"@babel/core": "^7.26.0",
|
|
27
|
+
"@babel/plugin-proposal-decorators": "^7.25.9",
|
|
28
|
+
"@babel/plugin-transform-class-properties": "^7.25.9",
|
|
29
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
30
30
|
"@types/babel__core": "^7.20.5",
|
|
31
31
|
"deepmerge": "^4.3.1",
|
|
32
32
|
"reduce-configs": "^1.0.0",
|
|
@@ -37,11 +37,11 @@
|
|
|
37
37
|
"babel-loader": "9.2.1",
|
|
38
38
|
"prebundle": "1.2.2",
|
|
39
39
|
"typescript": "^5.6.3",
|
|
40
|
-
"@rsbuild/core": "1.0.
|
|
40
|
+
"@rsbuild/core": "1.0.19",
|
|
41
41
|
"@scripts/test-helper": "1.0.1"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@rsbuild/core": "1.x
|
|
44
|
+
"@rsbuild/core": "1.x"
|
|
45
45
|
},
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public",
|