@rsbuild/plugin-babel 1.0.4 → 1.0.6

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 @@
1
- {"name":"babel-loader","author":"Luis Couto <hello@luiscouto.pt>","version":"9.2.1","license":"MIT","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"babel-loader","author":"Luis Couto <hello@luiscouto.pt>","version":"10.0.0","license":"MIT","types":"index.d.ts","type":"commonjs"}
package/dist/index.cjs CHANGED
@@ -2,7 +2,9 @@
2
2
  let __rslib_import_meta_url__ = 'undefined' == typeof document ? new (require('url'.replace('', ''))).URL('file:' + __filename).href : document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href;
3
3
  var __webpack_modules__ = {
4
4
  "@babel/core": function(module) {
5
- module.exports = import("@babel/core");
5
+ module.exports = import("@babel/core").then(function(module) {
6
+ return module;
7
+ });
6
8
  }
7
9
  }, __webpack_module_cache__ = {};
8
10
  function __webpack_require__(moduleId) {
@@ -13,23 +15,17 @@ function __webpack_require__(moduleId) {
13
15
  };
14
16
  return __webpack_modules__[moduleId](module, module.exports, __webpack_require__), module.exports;
15
17
  }
16
- __webpack_require__.n = function(module) {
17
- var getter = module && module.__esModule ? function() {
18
- return module.default;
19
- } : function() {
20
- return module;
21
- };
18
+ __webpack_require__.n = (module)=>{
19
+ var getter = module && module.__esModule ? ()=>module.default : ()=>module;
22
20
  return __webpack_require__.d(getter, {
23
21
  a: getter
24
22
  }), getter;
25
- }, __webpack_require__.d = function(exports1, definition) {
23
+ }, __webpack_require__.d = (exports1, definition)=>{
26
24
  for(var key in definition)__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key) && Object.defineProperty(exports1, key, {
27
25
  enumerable: !0,
28
26
  get: definition[key]
29
27
  });
30
- }, __webpack_require__.o = function(obj, prop) {
31
- return Object.prototype.hasOwnProperty.call(obj, prop);
32
- }, __webpack_require__.r = function(exports1) {
28
+ }, __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop), __webpack_require__.r = (exports1)=>{
33
29
  'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(exports1, Symbol.toStringTag, {
34
30
  value: 'Module'
35
31
  }), Object.defineProperty(exports1, '__esModule', {
@@ -37,43 +33,21 @@ __webpack_require__.n = function(module) {
37
33
  });
38
34
  };
39
35
  var __webpack_exports__ = {};
40
- (()=>{
36
+ for(var __webpack_i__ in (()=>{
41
37
  __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
42
38
  PLUGIN_BABEL_NAME: ()=>PLUGIN_BABEL_NAME,
43
- getDefaultBabelOptions: ()=>getDefaultBabelOptions,
39
+ pluginBabel: ()=>pluginBabel,
44
40
  modifyBabelLoaderOptions: ()=>modifyBabelLoaderOptions,
45
41
  getBabelUtils: ()=>getBabelUtils,
46
- pluginBabel: ()=>pluginBabel
42
+ getDefaultBabelOptions: ()=>getDefaultBabelOptions
47
43
  });
48
- let external_node_fs_namespaceObject = require("node:fs");
49
- var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
50
- let external_node_module_namespaceObject = require("node:module"), external_node_path_namespaceObject = require("node:path");
44
+ let external_node_path_namespaceObject = require("node:path");
51
45
  var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
52
- let external_node_url_namespaceObject = require("node:url"), external_deepmerge_namespaceObject = require("deepmerge");
53
- var external_deepmerge_default = __webpack_require__.n(external_deepmerge_namespaceObject);
54
46
  let external_reduce_configs_namespaceObject = require("reduce-configs"), external_upath_namespaceObject = require("upath");
55
47
  var external_upath_default = __webpack_require__.n(external_upath_namespaceObject);
56
48
  let BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
57
49
  arr
58
- ], normalizeToPosixPath = (p)=>external_upath_default().normalizeSafe((0, external_node_path_namespaceObject.normalize)(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`), formatPath = (originPath)=>(0, external_node_path_namespaceObject.isAbsolute)(originPath) ? originPath.split(external_node_path_namespaceObject.sep).join('/') : originPath, getPluginItemName = (item)=>'string' == typeof item ? formatPath(item) : Array.isArray(item) && 'string' == typeof item[0] ? formatPath(item[0]) : null, addPlugins = (plugins, config)=>{
59
- config.plugins ? config.plugins.push(...plugins) : config.plugins = plugins;
60
- }, addPresets = (presets, config)=>{
61
- config.presets ? config.presets.push(...presets) : config.presets = presets;
62
- }, removePlugins = (plugins, config)=>{
63
- if (!config.plugins) return;
64
- let removeList = castArray(plugins);
65
- config.plugins = config.plugins.filter((item)=>{
66
- let name = getPluginItemName(item);
67
- return !name || !removeList.find((removeItem)=>name.includes(removeItem));
68
- });
69
- }, removePresets = (presets, config)=>{
70
- if (!config.presets) return;
71
- let removeList = castArray(presets);
72
- config.presets = config.presets.filter((item)=>{
73
- let name = getPluginItemName(item);
74
- return !name || !removeList.find((removeItem)=>name.includes(removeItem));
75
- });
76
- }, modifyPresetOptions = (presetName, options, presets = [])=>{
50
+ ], normalizeToPosixPath = (p)=>external_upath_default().normalizeSafe((0, external_node_path_namespaceObject.normalize)(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`), formatPath = (originPath)=>(0, external_node_path_namespaceObject.isAbsolute)(originPath) ? originPath.split(external_node_path_namespaceObject.sep).join('/') : originPath, getPluginItemName = (item)=>'string' == typeof item ? formatPath(item) : Array.isArray(item) && 'string' == typeof item[0] ? formatPath(item[0]) : null, modifyPresetOptions = (presetName, options, presets = [])=>{
77
51
  presets.forEach((preset, index)=>{
78
52
  Array.isArray(preset) ? 'string' == typeof preset[0] && normalizeToPosixPath(preset[0]).includes(presetName) && (preset[1] = {
79
53
  ...preset[1] || {},
@@ -86,28 +60,45 @@ var __webpack_exports__ = {};
86
60
  }, getBabelUtils = (config)=>{
87
61
  let noop = ()=>{};
88
62
  return {
89
- addPlugins: (plugins)=>addPlugins(plugins, config),
90
- addPresets: (presets)=>addPresets(presets, config),
91
- removePlugins: (plugins)=>removePlugins(plugins, config),
92
- removePresets: (presets)=>removePresets(presets, config),
63
+ addPlugins: (plugins)=>{
64
+ ((plugins, config)=>{
65
+ config.plugins ? config.plugins.push(...plugins) : config.plugins = plugins;
66
+ })(plugins, config);
67
+ },
68
+ addPresets: (presets)=>{
69
+ ((presets, config)=>{
70
+ config.presets ? config.presets.push(...presets) : config.presets = presets;
71
+ })(presets, config);
72
+ },
73
+ removePlugins: (plugins)=>{
74
+ ((plugins, config)=>{
75
+ if (!config.plugins) return;
76
+ let removeList = castArray(plugins);
77
+ config.plugins = config.plugins.filter((item)=>{
78
+ let name = getPluginItemName(item);
79
+ return !name || !removeList.find((removeItem)=>name.includes(removeItem));
80
+ });
81
+ })(plugins, config);
82
+ },
83
+ removePresets: (presets)=>{
84
+ ((presets, config)=>{
85
+ if (!config.presets) return;
86
+ let removeList = castArray(presets);
87
+ config.presets = config.presets.filter((item)=>{
88
+ let name = getPluginItemName(item);
89
+ return !name || !removeList.find((removeItem)=>name.includes(removeItem));
90
+ });
91
+ })(presets, config);
92
+ },
93
93
  addIncludes: noop,
94
94
  addExcludes: noop,
95
- modifyPresetEnvOptions: (options)=>modifyPresetOptions('@babel/preset-env', options, config.presets || []),
96
- modifyPresetReactOptions: (options)=>modifyPresetOptions('@babel/preset-react', options, config.presets || [])
95
+ modifyPresetEnvOptions: (options)=>{
96
+ modifyPresetOptions('@babel/preset-env', options, config.presets || []);
97
+ },
98
+ modifyPresetReactOptions: (options)=>{
99
+ modifyPresetOptions('@babel/preset-react', options, config.presets || []);
100
+ }
97
101
  };
98
- }, applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils)=>{
99
- if (userBabelConfig) {
100
- let babelUtils = {
101
- ...getBabelUtils(defaultOptions),
102
- ...extraBabelUtils
103
- };
104
- return (0, external_reduce_configs_namespaceObject.reduceConfigsWithContext)({
105
- initial: defaultOptions,
106
- config: userBabelConfig,
107
- ctx: babelUtils
108
- });
109
- }
110
- return defaultOptions;
111
102
  }, modifyBabelLoaderOptions = ({ chain, CHAIN_ID, modifier })=>{
112
103
  for (let ruleId of [
113
104
  CHAIN_ID.RULE.JS,
@@ -117,7 +108,11 @@ var __webpack_exports__ = {};
117
108
  let rule = chain.module.rule(ruleId);
118
109
  rule.uses.has(CHAIN_ID.USE.BABEL) && rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
119
110
  }
120
- }, plugin_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__)), plugin_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_BABEL_NAME = 'rsbuild:babel', SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
111
+ }, external_node_fs_namespaceObject = require("node:fs");
112
+ var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
113
+ let external_node_module_namespaceObject = require("node:module"), external_node_url_namespaceObject = require("node:url"), external_deepmerge_namespaceObject = require("deepmerge");
114
+ var external_deepmerge_default = __webpack_require__.n(external_deepmerge_namespaceObject);
115
+ let plugin_dirname = external_node_path_default().dirname((0, external_node_url_namespaceObject.fileURLToPath)(__rslib_import_meta_url__)), plugin_require = (0, external_node_module_namespaceObject.createRequire)(__rslib_import_meta_url__), PLUGIN_BABEL_NAME = 'rsbuild:babel', SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
121
116
  allowNamespaces: !0,
122
117
  allExtensions: !0,
123
118
  allowDeclareFields: !0,
@@ -126,7 +121,7 @@ var __webpack_exports__ = {};
126
121
  };
127
122
  async function getCacheIdentifier(options) {
128
123
  let identifier = `${process.env.NODE_ENV}${JSON.stringify(options)}`, { version: coreVersion } = await Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "@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 ?? '';
129
- return identifier + `@babel/core@${coreVersion}babel-loader@${loaderVersion}`;
124
+ return identifier += `@babel/core@${coreVersion}babel-loader@${loaderVersion}`;
130
125
  }
131
126
  let getDefaultBabelOptions = (config, context)=>{
132
127
  let isLegacyDecorators = 'legacy' === config.source.decorators.version, options = {
@@ -160,7 +155,20 @@ var __webpack_exports__ = {};
160
155
  name: PLUGIN_BABEL_NAME,
161
156
  setup (api) {
162
157
  let getBabelOptions = async (environment)=>{
163
- let { config } = environment, baseOptions = getDefaultBabelOptions(config, api.context), mergedOptions = applyUserBabelConfig(external_deepmerge_default()({}, baseOptions), options.babelLoaderOptions);
158
+ let { config } = environment, baseOptions = getDefaultBabelOptions(config, api.context), mergedOptions = ((defaultOptions, userBabelConfig, extraBabelUtils)=>{
159
+ if (userBabelConfig) {
160
+ let babelUtils = {
161
+ ...getBabelUtils(defaultOptions),
162
+ ...void 0
163
+ };
164
+ return (0, external_reduce_configs_namespaceObject.reduceConfigsWithContext)({
165
+ initial: defaultOptions,
166
+ config: userBabelConfig,
167
+ ctx: babelUtils
168
+ });
169
+ }
170
+ return defaultOptions;
171
+ })(external_deepmerge_default()({}, baseOptions), options.babelLoaderOptions);
164
172
  return mergedOptions.cacheDirectory && !mergedOptions.cacheIdentifier && (mergedOptions.cacheIdentifier = await getCacheIdentifier(mergedOptions)), mergedOptions;
165
173
  };
166
174
  api.modifyBundlerChain({
@@ -177,9 +185,13 @@ var __webpack_exports__ = {};
177
185
  });
178
186
  }
179
187
  });
180
- })();
181
- var __webpack_export_target__ = exports;
182
- for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
183
- __webpack_exports__.__esModule && Object.defineProperty(__webpack_export_target__, '__esModule', {
188
+ })(), exports.PLUGIN_BABEL_NAME = __webpack_exports__.PLUGIN_BABEL_NAME, exports.getBabelUtils = __webpack_exports__.getBabelUtils, exports.getDefaultBabelOptions = __webpack_exports__.getDefaultBabelOptions, exports.modifyBabelLoaderOptions = __webpack_exports__.modifyBabelLoaderOptions, exports.pluginBabel = __webpack_exports__.pluginBabel, __webpack_exports__)-1 === [
189
+ "PLUGIN_BABEL_NAME",
190
+ "getBabelUtils",
191
+ "getDefaultBabelOptions",
192
+ "modifyBabelLoaderOptions",
193
+ "pluginBabel"
194
+ ].indexOf(__webpack_i__) && (exports[__webpack_i__] = __webpack_exports__[__webpack_i__]);
195
+ Object.defineProperty(exports, '__esModule', {
184
196
  value: !0
185
197
  });
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { pluginBabel, getDefaultBabelOptions, PLUGIN_BABEL_NAME, } from './plugin.js';
2
1
  export { getBabelUtils, modifyBabelLoaderOptions } from './helper.js';
3
- export type { PresetEnvOptions, PresetEnvTargets, PresetEnvBuiltIns, BabelConfigUtils, BabelTransformOptions, PluginBabelOptions, } from './types.js';
2
+ export { getDefaultBabelOptions, PLUGIN_BABEL_NAME, pluginBabel, } from './plugin.js';
3
+ export type { BabelConfigUtils, BabelTransformOptions, PluginBabelOptions, PresetEnvBuiltIns, PresetEnvOptions, PresetEnvTargets, } from './types.js';
package/dist/index.js CHANGED
@@ -1,31 +1,13 @@
1
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
2
- import * as __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__ from "node:module";
3
- import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
4
- import * as __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__ from "node:url";
5
- import * as __WEBPACK_EXTERNAL_MODULE_deepmerge__ from "deepmerge";
6
- import * as __WEBPACK_EXTERNAL_MODULE_reduce_configs_02786df6__ from "reduce-configs";
7
- import * as __WEBPACK_EXTERNAL_MODULE_upath__ from "upath";
1
+ import node_path, { isAbsolute, join, normalize, sep } from "node:path";
2
+ import { reduceConfigsWithContext } from "reduce-configs";
3
+ import upath from "upath";
4
+ import node_fs from "node:fs";
5
+ import { createRequire } from "node:module";
6
+ import { fileURLToPath } from "node:url";
7
+ import deepmerge from "deepmerge";
8
8
  let BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
9
9
  arr
10
- ], normalizeToPosixPath = (p)=>__WEBPACK_EXTERNAL_MODULE_upath__.default.normalizeSafe((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.normalize)(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`), formatPath = (originPath)=>(0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(originPath) ? originPath.split(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.sep).join('/') : originPath, getPluginItemName = (item)=>'string' == typeof item ? formatPath(item) : Array.isArray(item) && 'string' == typeof item[0] ? formatPath(item[0]) : null, addPlugins = (plugins, config)=>{
11
- config.plugins ? config.plugins.push(...plugins) : config.plugins = plugins;
12
- }, addPresets = (presets, config)=>{
13
- config.presets ? config.presets.push(...presets) : config.presets = presets;
14
- }, removePlugins = (plugins, config)=>{
15
- if (!config.plugins) return;
16
- let removeList = castArray(plugins);
17
- config.plugins = config.plugins.filter((item)=>{
18
- let name = getPluginItemName(item);
19
- return !name || !removeList.find((removeItem)=>name.includes(removeItem));
20
- });
21
- }, removePresets = (presets, config)=>{
22
- if (!config.presets) return;
23
- let removeList = castArray(presets);
24
- config.presets = config.presets.filter((item)=>{
25
- let name = getPluginItemName(item);
26
- return !name || !removeList.find((removeItem)=>name.includes(removeItem));
27
- });
28
- }, modifyPresetOptions = (presetName, options, presets = [])=>{
10
+ ], normalizeToPosixPath = (p)=>upath.normalizeSafe(normalize(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`), formatPath = (originPath)=>isAbsolute(originPath) ? originPath.split(sep).join('/') : originPath, getPluginItemName = (item)=>'string' == typeof item ? formatPath(item) : Array.isArray(item) && 'string' == typeof item[0] ? formatPath(item[0]) : null, modifyPresetOptions = (presetName, options, presets = [])=>{
29
11
  presets.forEach((preset, index)=>{
30
12
  Array.isArray(preset) ? 'string' == typeof preset[0] && normalizeToPosixPath(preset[0]).includes(presetName) && (preset[1] = {
31
13
  ...preset[1] || {},
@@ -38,28 +20,41 @@ let BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.i
38
20
  }, getBabelUtils = (config)=>{
39
21
  let noop = ()=>{};
40
22
  return {
41
- addPlugins: (plugins)=>addPlugins(plugins, config),
42
- addPresets: (presets)=>addPresets(presets, config),
43
- removePlugins: (plugins)=>removePlugins(plugins, config),
44
- removePresets: (presets)=>removePresets(presets, config),
23
+ addPlugins: (plugins)=>{
24
+ config.plugins ? config.plugins.push(...plugins) : config.plugins = plugins;
25
+ },
26
+ addPresets: (presets)=>{
27
+ config.presets ? config.presets.push(...presets) : config.presets = presets;
28
+ },
29
+ removePlugins: (plugins)=>{
30
+ ((plugins, config)=>{
31
+ if (!config.plugins) return;
32
+ let removeList = castArray(plugins);
33
+ config.plugins = config.plugins.filter((item)=>{
34
+ let name = getPluginItemName(item);
35
+ return !name || !removeList.find((removeItem)=>name.includes(removeItem));
36
+ });
37
+ })(plugins, config);
38
+ },
39
+ removePresets: (presets)=>{
40
+ ((presets, config)=>{
41
+ if (!config.presets) return;
42
+ let removeList = castArray(presets);
43
+ config.presets = config.presets.filter((item)=>{
44
+ let name = getPluginItemName(item);
45
+ return !name || !removeList.find((removeItem)=>name.includes(removeItem));
46
+ });
47
+ })(presets, config);
48
+ },
45
49
  addIncludes: noop,
46
50
  addExcludes: noop,
47
- modifyPresetEnvOptions: (options)=>modifyPresetOptions('@babel/preset-env', options, config.presets || []),
48
- modifyPresetReactOptions: (options)=>modifyPresetOptions('@babel/preset-react', options, config.presets || [])
51
+ modifyPresetEnvOptions: (options)=>{
52
+ modifyPresetOptions('@babel/preset-env', options, config.presets || []);
53
+ },
54
+ modifyPresetReactOptions: (options)=>{
55
+ modifyPresetOptions('@babel/preset-react', options, config.presets || []);
56
+ }
49
57
  };
50
- }, applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils)=>{
51
- if (userBabelConfig) {
52
- let babelUtils = {
53
- ...getBabelUtils(defaultOptions),
54
- ...extraBabelUtils
55
- };
56
- return (0, __WEBPACK_EXTERNAL_MODULE_reduce_configs_02786df6__.reduceConfigsWithContext)({
57
- initial: defaultOptions,
58
- config: userBabelConfig,
59
- ctx: babelUtils
60
- });
61
- }
62
- return defaultOptions;
63
58
  }, modifyBabelLoaderOptions = ({ chain, CHAIN_ID, modifier })=>{
64
59
  for (let ruleId of [
65
60
  CHAIN_ID.RULE.JS,
@@ -69,7 +64,7 @@ let BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.i
69
64
  let rule = chain.module.rule(ruleId);
70
65
  rule.uses.has(CHAIN_ID.USE.BABEL) && rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
71
66
  }
72
- }, plugin_dirname = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.dirname((0, __WEBPACK_EXTERNAL_MODULE_node_url_e96de089__.fileURLToPath)(import.meta.url)), plugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url), PLUGIN_BABEL_NAME = 'rsbuild:babel', SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/, DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
67
+ }, 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 = {
73
68
  allowNamespaces: !0,
74
69
  allExtensions: !0,
75
70
  allowDeclareFields: !0,
@@ -77,7 +72,7 @@ let BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.i
77
72
  isTSX: !0
78
73
  };
79
74
  async function getCacheIdentifier(options) {
80
- let identifier = `${process.env.NODE_ENV}${JSON.stringify(options)}`, { version: coreVersion } = await import("@babel/core"), loaderVersion = JSON.parse(await __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.default.promises.readFile((0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(plugin_dirname, '../compiled/babel-loader/package.json'), 'utf-8')).version ?? '';
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 ?? '';
81
76
  return identifier + `@babel/core@${coreVersion}babel-loader@${loaderVersion}`;
82
77
  }
83
78
  let getDefaultBabelOptions = (config, context)=>{
@@ -103,21 +98,34 @@ let getDefaultBabelOptions = (config, context)=>{
103
98
  }, { buildCache = !0 } = config.performance;
104
99
  if (buildCache && 'rspack' === context.bundlerType) {
105
100
  var cacheDirectory;
106
- let cacheDirectory1 = (cacheDirectory = 'boolean' == typeof buildCache ? void 0 : buildCache.cacheDirectory) ? (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.rootPath, cacheDirectory) : (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(context.cachePath);
107
- options.cacheCompression = !1, options.cacheDirectory = (0, __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.join)(cacheDirectory1, 'babel-loader');
101
+ let cacheDirectory1 = (cacheDirectory = 'boolean' == typeof buildCache ? void 0 : buildCache.cacheDirectory) ? isAbsolute(cacheDirectory) ? cacheDirectory : join(context.rootPath, cacheDirectory) : join(context.cachePath);
102
+ options.cacheCompression = !1, options.cacheDirectory = join(cacheDirectory1, 'babel-loader');
108
103
  }
109
104
  return options;
110
105
  }, pluginBabel = (options = {})=>({
111
106
  name: PLUGIN_BABEL_NAME,
112
107
  setup (api) {
113
108
  let getBabelOptions = async (environment)=>{
114
- let { config } = environment, baseOptions = getDefaultBabelOptions(config, api.context), mergedOptions = applyUserBabelConfig((0, __WEBPACK_EXTERNAL_MODULE_deepmerge__.default)({}, baseOptions), options.babelLoaderOptions);
109
+ let { config } = environment, mergedOptions = ((defaultOptions, userBabelConfig, extraBabelUtils)=>{
110
+ if (userBabelConfig) {
111
+ let babelUtils = {
112
+ ...getBabelUtils(defaultOptions),
113
+ ...void 0
114
+ };
115
+ return reduceConfigsWithContext({
116
+ initial: defaultOptions,
117
+ config: userBabelConfig,
118
+ ctx: babelUtils
119
+ });
120
+ }
121
+ return defaultOptions;
122
+ })(deepmerge({}, getDefaultBabelOptions(config, api.context)), options.babelLoaderOptions);
115
123
  return mergedOptions.cacheDirectory && !mergedOptions.cacheIdentifier && (mergedOptions.cacheIdentifier = await getCacheIdentifier(mergedOptions)), mergedOptions;
116
124
  };
117
125
  api.modifyBundlerChain({
118
126
  order: 'pre',
119
127
  handler: async (chain, { CHAIN_ID, environment })=>{
120
- let babelOptions = await getBabelOptions(environment), babelLoader = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__.default.resolve(plugin_dirname, '../compiled/babel-loader/index.js'), { include, exclude } = options;
128
+ let babelOptions = await getBabelOptions(environment), babelLoader = node_path.resolve(plugin_dirname, '../compiled/babel-loader/index.js'), { include, exclude } = options;
121
129
  if (include || exclude) {
122
130
  let rule = chain.module.rule(BABEL_JS_RULE).after(CHAIN_ID.RULE.JS);
123
131
  if (include) for (let condition of castArray(include))rule.include.add(condition);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-babel",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "Babel plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,22 +23,22 @@
23
23
  "compiled"
24
24
  ],
25
25
  "dependencies": {
26
- "@babel/core": "^7.26.9",
27
- "@babel/plugin-proposal-decorators": "^7.25.9",
28
- "@babel/plugin-transform-class-properties": "^7.25.9",
29
- "@babel/preset-typescript": "^7.26.0",
26
+ "@babel/core": "^7.28.0",
27
+ "@babel/plugin-proposal-decorators": "^7.28.0",
28
+ "@babel/plugin-transform-class-properties": "^7.27.1",
29
+ "@babel/preset-typescript": "^7.27.1",
30
30
  "@types/babel__core": "^7.20.5",
31
31
  "deepmerge": "^4.3.1",
32
32
  "reduce-configs": "^1.1.0",
33
33
  "upath": "2.0.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@rslib/core": "0.4.1",
37
- "@types/node": "^22.13.4",
38
- "babel-loader": "9.2.1",
39
- "prebundle": "1.2.7",
40
- "typescript": "^5.7.3",
41
- "@rsbuild/core": "1.2.9",
36
+ "@rslib/core": "0.11.1",
37
+ "@types/node": "^22.17.0",
38
+ "babel-loader": "10.0.0",
39
+ "prebundle": "1.4.0",
40
+ "typescript": "^5.9.2",
41
+ "@rsbuild/core": "1.4.14",
42
42
  "@scripts/test-helper": "1.0.1"
43
43
  },
44
44
  "peerDependencies": {
@@ -46,12 +46,12 @@
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public",
49
- "provenance": true,
50
49
  "registry": "https://registry.npmjs.org/"
51
50
  },
52
51
  "scripts": {
53
52
  "build": "rslib build",
54
53
  "dev": "rslib build --watch",
55
- "prebundle": "prebundle"
54
+ "prebundle": "prebundle",
55
+ "bump": "npx bumpp --no-tag"
56
56
  }
57
57
  }