@rsbuild/plugin-babel 1.0.5 → 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.
package/README.md CHANGED
@@ -12,7 +12,7 @@ An Rsbuild plugin to use Babel to transpile the code.
12
12
 
13
13
  ## Documentation
14
14
 
15
- See [Documentation](https://rsbuild.dev/plugins/list/plugin-babel).
15
+ See [Documentation](https://rsbuild.rs/plugins/list/plugin-babel).
16
16
 
17
17
  ## License
18
18
 
@@ -1,6 +1,6 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 272: (module) => {
3
+ 698: (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
- 124: (module, __unused_webpack_exports, __nccwpck_require__) => {
29
+ 846: (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__(609);
36
36
  const { env } = process;
37
- const transform = __nccwpck_require__(790);
38
- const serialize = __nccwpck_require__(436);
37
+ const transform = __nccwpck_require__(80);
38
+ const serialize = __nccwpck_require__(786);
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
- 674: (module, __unused_webpack_exports, __nccwpck_require__) => {
168
+ 448: (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__(124);
188
- const transform = __nccwpck_require__(790);
189
- const injectCaller = __nccwpck_require__(846);
190
- const schema = __nccwpck_require__(348);
187
+ const cache = __nccwpck_require__(846);
188
+ const transform = __nccwpck_require__(80);
189
+ const injectCaller = __nccwpck_require__(976);
190
+ const schema = __nccwpck_require__(690);
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
- 846: (module) => {
376
+ 976: (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
- 436: (module) => {
392
+ 786: (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
- 790: (module, __unused_webpack_exports, __nccwpck_require__) => {
458
+ 80: (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__(272);
461
+ const LoaderError = __nccwpck_require__(698);
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
- 348: (module) => {
812
+ 690: (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__(674);
841
+ var __webpack_exports__ = __nccwpck_require__(448);
842
842
  module.exports = __webpack_exports__;
843
843
  })();
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) {
@@ -33,41 +35,19 @@ __webpack_require__.n = (module)=>{
33
35
  var __webpack_exports__ = {};
34
36
  for(var __webpack_i__ in (()=>{
35
37
  __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
36
- getBabelUtils: ()=>getBabelUtils,
37
- getDefaultBabelOptions: ()=>getDefaultBabelOptions,
38
+ PLUGIN_BABEL_NAME: ()=>PLUGIN_BABEL_NAME,
38
39
  pluginBabel: ()=>pluginBabel,
39
40
  modifyBabelLoaderOptions: ()=>modifyBabelLoaderOptions,
40
- PLUGIN_BABEL_NAME: ()=>PLUGIN_BABEL_NAME
41
+ getBabelUtils: ()=>getBabelUtils,
42
+ getDefaultBabelOptions: ()=>getDefaultBabelOptions
41
43
  });
42
- let external_node_fs_namespaceObject = require("node:fs");
43
- var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
44
- let external_node_module_namespaceObject = require("node:module"), external_node_path_namespaceObject = require("node:path");
44
+ let external_node_path_namespaceObject = require("node:path");
45
45
  var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
46
- let external_node_url_namespaceObject = require("node:url"), external_deepmerge_namespaceObject = require("deepmerge");
47
- var external_deepmerge_default = __webpack_require__.n(external_deepmerge_namespaceObject);
48
46
  let external_reduce_configs_namespaceObject = require("reduce-configs"), external_upath_namespaceObject = require("upath");
49
47
  var external_upath_default = __webpack_require__.n(external_upath_namespaceObject);
50
48
  let BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
51
49
  arr
52
- ], 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)=>{
53
- config.plugins ? config.plugins.push(...plugins) : config.plugins = plugins;
54
- }, addPresets = (presets, config)=>{
55
- config.presets ? config.presets.push(...presets) : config.presets = presets;
56
- }, removePlugins = (plugins, config)=>{
57
- if (!config.plugins) return;
58
- let removeList = castArray(plugins);
59
- config.plugins = config.plugins.filter((item)=>{
60
- let name = getPluginItemName(item);
61
- return !name || !removeList.find((removeItem)=>name.includes(removeItem));
62
- });
63
- }, removePresets = (presets, config)=>{
64
- if (!config.presets) return;
65
- let removeList = castArray(presets);
66
- config.presets = config.presets.filter((item)=>{
67
- let name = getPluginItemName(item);
68
- return !name || !removeList.find((removeItem)=>name.includes(removeItem));
69
- });
70
- }, 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 = [])=>{
71
51
  presets.forEach((preset, index)=>{
72
52
  Array.isArray(preset) ? 'string' == typeof preset[0] && normalizeToPosixPath(preset[0]).includes(presetName) && (preset[1] = {
73
53
  ...preset[1] || {},
@@ -80,28 +60,45 @@ for(var __webpack_i__ in (()=>{
80
60
  }, getBabelUtils = (config)=>{
81
61
  let noop = ()=>{};
82
62
  return {
83
- addPlugins: (plugins)=>addPlugins(plugins, config),
84
- addPresets: (presets)=>addPresets(presets, config),
85
- removePlugins: (plugins)=>removePlugins(plugins, config),
86
- 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
+ },
87
93
  addIncludes: noop,
88
94
  addExcludes: noop,
89
- modifyPresetEnvOptions: (options)=>modifyPresetOptions('@babel/preset-env', options, config.presets || []),
90
- 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
+ }
91
101
  };
92
- }, applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils)=>{
93
- if (userBabelConfig) {
94
- let babelUtils = {
95
- ...getBabelUtils(defaultOptions),
96
- ...extraBabelUtils
97
- };
98
- return (0, external_reduce_configs_namespaceObject.reduceConfigsWithContext)({
99
- initial: defaultOptions,
100
- config: userBabelConfig,
101
- ctx: babelUtils
102
- });
103
- }
104
- return defaultOptions;
105
102
  }, modifyBabelLoaderOptions = ({ chain, CHAIN_ID, modifier })=>{
106
103
  for (let ruleId of [
107
104
  CHAIN_ID.RULE.JS,
@@ -111,7 +108,11 @@ for(var __webpack_i__ in (()=>{
111
108
  let rule = chain.module.rule(ruleId);
112
109
  rule.uses.has(CHAIN_ID.USE.BABEL) && rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
113
110
  }
114
- }, 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 = {
115
116
  allowNamespaces: !0,
116
117
  allExtensions: !0,
117
118
  allowDeclareFields: !0,
@@ -154,7 +155,20 @@ for(var __webpack_i__ in (()=>{
154
155
  name: PLUGIN_BABEL_NAME,
155
156
  setup (api) {
156
157
  let getBabelOptions = async (environment)=>{
157
- 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);
158
172
  return mergedOptions.cacheDirectory && !mergedOptions.cacheIdentifier && (mergedOptions.cacheIdentifier = await getCacheIdentifier(mergedOptions)), mergedOptions;
159
173
  };
160
174
  api.modifyBundlerChain({
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.5",
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.10",
27
- "@babel/plugin-proposal-decorators": "^7.25.9",
28
- "@babel/plugin-transform-class-properties": "^7.25.9",
29
- "@babel/preset-typescript": "^7.27.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.6.1",
37
- "@types/node": "^22.14.0",
36
+ "@rslib/core": "0.11.1",
37
+ "@types/node": "^22.17.0",
38
38
  "babel-loader": "10.0.0",
39
- "prebundle": "1.3.3",
40
- "typescript": "^5.8.3",
41
- "@rsbuild/core": "1.3.5",
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
  }