@rsbuild/plugin-babel 1.1.0 → 1.1.1

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,6 +1,6 @@
1
1
  (() => {
2
2
  var __webpack_modules__ = {
3
- 605: (module) => {
3
+ 297: (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
- 329: (module, __unused_webpack_exports, __nccwpck_require__) => {
29
+ 69: (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__(703);
38
- const serialize = __nccwpck_require__(725);
37
+ const transform = __nccwpck_require__(499);
38
+ const serialize = __nccwpck_require__(641);
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
- 799: (module, __unused_webpack_exports, __nccwpck_require__) => {
168
+ 523: (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__(329);
188
- const transform = __nccwpck_require__(703);
189
- const injectCaller = __nccwpck_require__(714);
190
- const schema = __nccwpck_require__(280);
187
+ const cache = __nccwpck_require__(69);
188
+ const transform = __nccwpck_require__(499);
189
+ const injectCaller = __nccwpck_require__(257);
190
+ const schema = __nccwpck_require__(652);
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
- 714: (module) => {
376
+ 257: (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
- 725: (module) => {
392
+ 641: (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
- 703: (module, __unused_webpack_exports, __nccwpck_require__) => {
458
+ 499: (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__(605);
461
+ const LoaderError = __nccwpck_require__(297);
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
- 280: (module) => {
812
+ 652: (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__(799);
841
+ var __webpack_exports__ = __nccwpck_require__(523);
842
842
  module.exports = __webpack_exports__;
843
843
  })();
package/dist/index.cjs CHANGED
@@ -28,11 +28,9 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
28
28
  });
29
29
  const external_node_path_namespaceObject = require("node:path");
30
30
  var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
31
- const external_reduce_configs_namespaceObject = require("reduce-configs"), external_upath_namespaceObject = require("upath");
32
- var external_upath_default = __webpack_require__.n(external_upath_namespaceObject);
33
- const BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
31
+ const external_reduce_configs_namespaceObject = require("reduce-configs"), BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
34
32
  arr
35
- ], 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)=>{
33
+ ], normalizeToPosixPath = (p)=>(0, external_node_path_namespaceObject.normalize)(p || '').replace(/\\/g, '/').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)=>{
36
34
  config.plugins ? config.plugins.push(...plugins) : config.plugins = plugins;
37
35
  }, addPresets = (presets, config)=>{
38
36
  config.presets ? config.presets.push(...presets) : config.presets = presets;
@@ -105,9 +103,7 @@ const BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array
105
103
  ].filter(Boolean))rule.uses.has(CHAIN_ID.USE.BABEL) && rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
106
104
  }, external_node_fs_namespaceObject = require("node:fs");
107
105
  var external_node_fs_default = __webpack_require__.n(external_node_fs_namespaceObject);
108
- const external_node_module_namespaceObject = require("node:module"), external_node_url_namespaceObject = require("node:url"), external_deepmerge_namespaceObject = require("deepmerge");
109
- var external_deepmerge_default = __webpack_require__.n(external_deepmerge_namespaceObject);
110
- const 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 = {
106
+ const external_node_module_namespaceObject = require("node:module"), external_node_url_namespaceObject = require("node:url"), 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
107
  allowNamespaces: !0,
112
108
  allExtensions: !0,
113
109
  allowDeclareFields: !0,
@@ -129,7 +125,9 @@ function getDefaultBabelOptions(config, context) {
129
125
  plugins: [
130
126
  [
131
127
  plugin_require.resolve('@babel/plugin-proposal-decorators'),
132
- config.source.decorators
128
+ {
129
+ ...config.source.decorators
130
+ }
133
131
  ],
134
132
  ...isLegacyDecorators ? [
135
133
  plugin_require.resolve('@babel/plugin-transform-class-properties')
@@ -138,7 +136,9 @@ function getDefaultBabelOptions(config, context) {
138
136
  presets: [
139
137
  [
140
138
  plugin_require.resolve("@babel/preset-typescript"),
141
- DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
139
+ {
140
+ ...DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
141
+ }
142
142
  ]
143
143
  ]
144
144
  }, { buildCache = !0 } = config.performance;
@@ -152,7 +152,7 @@ const pluginBabel = (options = {})=>({
152
152
  name: PLUGIN_BABEL_NAME,
153
153
  setup (api) {
154
154
  let getBabelOptions = async (environment)=>{
155
- let { config } = environment, baseOptions = getDefaultBabelOptions(config, api.context), mergedOptions = applyUserBabelConfig(external_deepmerge_default()({}, baseOptions), options.babelLoaderOptions);
155
+ let { config } = environment, mergedOptions = applyUserBabelConfig(getDefaultBabelOptions(config, api.context), options.babelLoaderOptions);
156
156
  return mergedOptions.cacheDirectory && !mergedOptions.cacheIdentifier && (mergedOptions.cacheIdentifier = await getCacheIdentifier(mergedOptions)), mergedOptions;
157
157
  };
158
158
  api.modifyBundlerChain({
package/dist/index.js CHANGED
@@ -1,13 +1,11 @@
1
1
  import node_path, { isAbsolute, join, normalize, sep } from "node:path";
2
2
  import { reduceConfigsWithContext } from "reduce-configs";
3
- import upath from "upath";
4
3
  import node_fs from "node:fs";
5
4
  import { createRequire } from "node:module";
6
5
  import { fileURLToPath } from "node:url";
7
- import deepmerge from "deepmerge";
8
6
  let BABEL_JS_RULE = 'babel-js', castArray = (arr)=>void 0 === arr ? [] : Array.isArray(arr) ? arr : [
9
7
  arr
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 = [])=>{
8
+ ], normalizeToPosixPath = (p)=>normalize(p || '').replace(/\\/g, '/').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 = [])=>{
11
9
  presets.forEach((preset, index)=>{
12
10
  Array.isArray(preset) ? 'string' == typeof preset[0] && normalizeToPosixPath(preset[0]).includes(presetName) && (preset[1] = {
13
11
  ...preset[1] || {},
@@ -83,7 +81,9 @@ function getDefaultBabelOptions(config, context) {
83
81
  plugins: [
84
82
  [
85
83
  plugin_require.resolve('@babel/plugin-proposal-decorators'),
86
- config.source.decorators
84
+ {
85
+ ...config.source.decorators
86
+ }
87
87
  ],
88
88
  ...isLegacyDecorators ? [
89
89
  plugin_require.resolve('@babel/plugin-transform-class-properties')
@@ -92,7 +92,9 @@ function getDefaultBabelOptions(config, context) {
92
92
  presets: [
93
93
  [
94
94
  plugin_require.resolve("@babel/preset-typescript"),
95
- DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
95
+ {
96
+ ...DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
97
+ }
96
98
  ]
97
99
  ]
98
100
  }, { buildCache = !0 } = config.performance;
@@ -119,7 +121,7 @@ let pluginBabel = (options = {})=>({
119
121
  });
120
122
  }
121
123
  return defaultOptions;
122
- })(deepmerge({}, getDefaultBabelOptions(config, api.context)), options.babelLoaderOptions);
124
+ })(getDefaultBabelOptions(config, api.context), options.babelLoaderOptions);
123
125
  return mergedOptions.cacheDirectory && !mergedOptions.cacheIdentifier && (mergedOptions.cacheIdentifier = await getCacheIdentifier(mergedOptions)), mergedOptions;
124
126
  };
125
127
  api.modifyBundlerChain({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-babel",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Babel plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,24 +23,22 @@
23
23
  "compiled"
24
24
  ],
25
25
  "dependencies": {
26
- "@babel/core": "^7.28.6",
27
- "@babel/plugin-proposal-decorators": "^7.28.6",
26
+ "@babel/core": "^7.29.0",
27
+ "@babel/plugin-proposal-decorators": "^7.29.0",
28
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
- "deepmerge": "^4.3.1",
32
- "reduce-configs": "^1.1.1",
33
- "upath": "2.0.1"
31
+ "reduce-configs": "^1.1.1"
34
32
  },
35
33
  "devDependencies": {
36
- "@rsbuild/core-v1": "npm:@rsbuild/core@^1.7.2",
37
- "@rslib/core": "0.19.3",
38
- "@types/node": "^24.10.9",
34
+ "@rsbuild/core-v1": "npm:@rsbuild/core@^1.7.3",
35
+ "@rslib/core": "0.19.6",
36
+ "@types/node": "^24.11.0",
39
37
  "babel-loader": "10.0.0",
40
38
  "prebundle": "1.6.2",
41
39
  "typescript": "^5.9.3",
42
- "@scripts/test-helper": "1.0.1",
43
- "@rsbuild/core": "2.0.0-alpha.3"
40
+ "@rsbuild/core": "2.0.0-beta.6",
41
+ "@scripts/test-helper": "1.0.1"
44
42
  },
45
43
  "peerDependencies": {
46
44
  "@rsbuild/core": "^1.0.0 || ^2.0.0-0"