@rsbuild/plugin-babel 0.6.15 → 0.7.0-beta.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,44 +1,56 @@
1
- import { createRequire } from 'module';
2
- var require = createRequire(import.meta['url']);
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
3
29
 
4
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
- }) : x)(function(x) {
7
- if (typeof require !== "undefined")
8
- return require.apply(this, arguments);
9
- throw Error('Dynamic require of "' + x + '" is not supported');
30
+ // src/index.ts
31
+ var src_exports = {};
32
+ __export(src_exports, {
33
+ getBabelUtils: () => getBabelUtils,
34
+ getDefaultBabelOptions: () => getDefaultBabelOptions,
35
+ getUseBuiltIns: () => getUseBuiltIns,
36
+ modifyBabelLoaderOptions: () => modifyBabelLoaderOptions,
37
+ pluginBabel: () => pluginBabel
10
38
  });
11
-
12
- // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
13
- import { fileURLToPath } from "url";
14
- import path from "path";
15
- var getFilename = () => fileURLToPath(import.meta.url);
16
- var getDirname = () => path.dirname(getFilename());
17
- var __dirname = /* @__PURE__ */ getDirname();
39
+ module.exports = __toCommonJS(src_exports);
18
40
 
19
41
  // src/plugin.ts
20
- import path2, { isAbsolute as isAbsolute2, join } from "path";
21
- import {
22
- SCRIPT_REGEX,
23
- castArray as castArray2,
24
- cloneDeep,
25
- fse,
26
- getNodeEnv,
27
- isProd
28
- } from "@rsbuild/shared";
42
+ var import_node_path2 = __toESM(require("path"));
43
+ var import_shared2 = require("@rsbuild/shared");
29
44
 
30
45
  // src/helper.ts
31
- import { isAbsolute, normalize, sep } from "path";
32
- import {
33
- castArray,
34
- mergeChainedOptions
35
- } from "@rsbuild/shared";
36
- import upath from "upath";
46
+ var import_node_path = require("path");
47
+ var import_shared = require("@rsbuild/shared");
48
+ var import_upath = __toESM(require("upath"));
37
49
  var BABEL_JS_RULE = "babel-js";
38
- var normalizeToPosixPath = (p) => upath.normalizeSafe(normalize(p || "")).replace(/^([a-zA-Z]+):/, (_, m) => `/${m.toLowerCase()}`);
50
+ var normalizeToPosixPath = (p) => import_upath.default.normalizeSafe((0, import_node_path.normalize)(p || "")).replace(/^([a-zA-Z]+):/, (_, m) => `/${m.toLowerCase()}`);
39
51
  var formatPath = (originPath) => {
40
- if (isAbsolute(originPath)) {
41
- return originPath.split(sep).join("/");
52
+ if ((0, import_node_path.isAbsolute)(originPath)) {
53
+ return originPath.split(import_node_path.sep).join("/");
42
54
  }
43
55
  return originPath;
44
56
  };
@@ -69,7 +81,7 @@ var removePlugins = (plugins, config) => {
69
81
  if (!config.plugins) {
70
82
  return;
71
83
  }
72
- const removeList = castArray(plugins);
84
+ const removeList = (0, import_shared.castArray)(plugins);
73
85
  config.plugins = config.plugins.filter((item) => {
74
86
  const name = getPluginItemName(item);
75
87
  if (name) {
@@ -82,7 +94,7 @@ var removePresets = (presets, config) => {
82
94
  if (!config.presets) {
83
95
  return;
84
96
  }
85
- const removeList = castArray(presets);
97
+ const removeList = (0, import_shared.castArray)(presets);
86
98
  config.presets = config.presets.filter((item) => {
87
99
  const name = getPluginItemName(item);
88
100
  if (name) {
@@ -129,7 +141,7 @@ var applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) =>
129
141
  ...getBabelUtils(defaultOptions),
130
142
  ...extraBabelUtils
131
143
  };
132
- return mergeChainedOptions({
144
+ return (0, import_shared.mergeChainedOptions)({
133
145
  defaults: defaultOptions,
134
146
  options: userBabelConfig,
135
147
  utils: babelUtils
@@ -173,14 +185,14 @@ var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
173
185
  };
174
186
  function getCacheDirectory(context, cacheDirectory) {
175
187
  if (cacheDirectory) {
176
- return isAbsolute2(cacheDirectory) ? cacheDirectory : join(context.rootPath, cacheDirectory);
188
+ return (0, import_node_path2.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, import_node_path2.join)(context.rootPath, cacheDirectory);
177
189
  }
178
- return join(context.cachePath);
190
+ return (0, import_node_path2.join)(context.cachePath);
179
191
  }
180
192
  async function getCacheIdentifier(options) {
181
- let identifier = `${getNodeEnv()}${JSON.stringify(options)}`;
193
+ let identifier = `${(0, import_shared2.getNodeEnv)()}${JSON.stringify(options)}`;
182
194
  const { version: coreVersion } = await import("@babel/core");
183
- const loaderVersion = (await fse.readJSON(join(__dirname, "../compiled/babel-loader/package.json"))).version;
195
+ const loaderVersion = (await import_shared2.fse.readJSON((0, import_node_path2.join)(__dirname, "../compiled/babel-loader/package.json"))).version;
184
196
  identifier += `@babel/core@${coreVersion}`;
185
197
  identifier += `babel-loader@${loaderVersion}`;
186
198
  return identifier;
@@ -190,20 +202,20 @@ var getDefaultBabelOptions = (config, context) => {
190
202
  const options = {
191
203
  babelrc: false,
192
204
  configFile: false,
193
- compact: isProd(),
205
+ compact: (0, import_shared2.isProd)(),
194
206
  plugins: [
195
207
  [
196
- __require.resolve("@babel/plugin-proposal-decorators"),
208
+ require.resolve("@babel/plugin-proposal-decorators"),
197
209
  config.source.decorators
198
210
  ],
199
211
  // If you are using @babel/preset-env and legacy decorators, you must ensure the class elements transform is enabled regardless of your targets, because Babel only supports compiling legacy decorators when also compiling class properties:
200
212
  // see https://babeljs.io/docs/babel-plugin-proposal-decorators#legacy
201
- ...isLegacyDecorators ? [__require.resolve("@babel/plugin-transform-class-properties")] : []
213
+ ...isLegacyDecorators ? [require.resolve("@babel/plugin-transform-class-properties")] : []
202
214
  ],
203
215
  presets: [
204
216
  // TODO: only apply preset-typescript for ts file (isTSX & allExtensions false)
205
217
  [
206
- __require.resolve("@babel/preset-typescript"),
218
+ require.resolve("@babel/preset-typescript"),
207
219
  DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
208
220
  ]
209
221
  ]
@@ -215,7 +227,7 @@ var getDefaultBabelOptions = (config, context) => {
215
227
  typeof buildCache === "boolean" ? void 0 : buildCache.cacheDirectory
216
228
  );
217
229
  options.cacheCompression = false;
218
- options.cacheDirectory = join(cacheDirectory, "babel-loader");
230
+ options.cacheDirectory = (0, import_node_path2.join)(cacheDirectory, "babel-loader");
219
231
  }
220
232
  return options;
221
233
  };
@@ -226,7 +238,7 @@ var pluginBabel = (options = {}) => ({
226
238
  const config = api.getNormalizedConfig();
227
239
  const baseOptions = getDefaultBabelOptions(config, api.context);
228
240
  const mergedOptions = applyUserBabelConfig(
229
- cloneDeep(baseOptions),
241
+ (0, import_shared2.cloneDeep)(baseOptions),
230
242
  options.babelLoaderOptions
231
243
  );
232
244
  if (mergedOptions.cacheDirectory && !mergedOptions.cacheIdentifier) {
@@ -238,7 +250,7 @@ var pluginBabel = (options = {}) => ({
238
250
  order: "pre",
239
251
  handler: async (chain, { CHAIN_ID }) => {
240
252
  const babelOptions = await getBabelOptions();
241
- const babelLoader = path2.resolve(
253
+ const babelLoader = import_node_path2.default.resolve(
242
254
  __dirname,
243
255
  "../compiled/babel-loader/index.js"
244
256
  );
@@ -246,31 +258,32 @@ var pluginBabel = (options = {}) => ({
246
258
  if (include || exclude) {
247
259
  const rule = chain.module.rule(BABEL_JS_RULE);
248
260
  if (include) {
249
- for (const condition of castArray2(include)) {
261
+ for (const condition of (0, import_shared2.castArray)(include)) {
250
262
  rule.include.add(condition);
251
263
  }
252
264
  }
253
265
  if (exclude) {
254
- for (const condition of castArray2(exclude)) {
266
+ for (const condition of (0, import_shared2.castArray)(exclude)) {
255
267
  rule.exclude.add(condition);
256
268
  }
257
269
  }
258
270
  const swcRule = chain.module.rules.get(CHAIN_ID.RULE.JS).use(CHAIN_ID.USE.SWC);
259
271
  const swcLoader = swcRule.get("loader");
260
272
  const swcOptions = swcRule.get("options");
261
- rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.SWC).loader(swcLoader).options(swcOptions).end().use(CHAIN_ID.USE.BABEL).loader(babelLoader).options(babelOptions);
273
+ rule.test(import_shared2.SCRIPT_REGEX).use(CHAIN_ID.USE.SWC).loader(swcLoader).options(swcOptions).end().use(CHAIN_ID.USE.BABEL).loader(babelLoader).options(babelOptions);
262
274
  } else {
263
275
  const rule = chain.module.rule(CHAIN_ID.RULE.JS);
264
- rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(babelLoader).options(babelOptions);
276
+ rule.test(import_shared2.SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(babelLoader).options(babelOptions);
265
277
  }
266
278
  }
267
279
  });
268
280
  }
269
281
  });
270
- export {
282
+ // Annotate the CommonJS export names for ESM import in node:
283
+ 0 && (module.exports = {
271
284
  getBabelUtils,
272
285
  getDefaultBabelOptions,
273
286
  getUseBuiltIns,
274
287
  modifyBabelLoaderOptions,
275
288
  pluginBabel
276
- };
289
+ });
package/dist/index.js CHANGED
@@ -1,56 +1,44 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ import { createRequire } from 'module';
2
+ var require = createRequire(import.meta['url']);
29
3
 
30
- // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
33
- getBabelUtils: () => getBabelUtils,
34
- getDefaultBabelOptions: () => getDefaultBabelOptions,
35
- getUseBuiltIns: () => getUseBuiltIns,
36
- modifyBabelLoaderOptions: () => modifyBabelLoaderOptions,
37
- pluginBabel: () => pluginBabel
4
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
5
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
6
+ }) : x)(function(x) {
7
+ if (typeof require !== "undefined")
8
+ return require.apply(this, arguments);
9
+ throw Error('Dynamic require of "' + x + '" is not supported');
38
10
  });
39
- module.exports = __toCommonJS(src_exports);
11
+
12
+ // ../../node_modules/.pnpm/@modern-js+module-tools@2.49.3_eslint@8.57.0_typescript@5.4.5/node_modules/@modern-js/module-tools/shims/esm.js
13
+ import { fileURLToPath } from "url";
14
+ import path from "path";
15
+ var getFilename = () => fileURLToPath(import.meta.url);
16
+ var getDirname = () => path.dirname(getFilename());
17
+ var __dirname = /* @__PURE__ */ getDirname();
40
18
 
41
19
  // src/plugin.ts
42
- var import_node_path2 = __toESM(require("path"));
43
- var import_shared2 = require("@rsbuild/shared");
20
+ import path2, { isAbsolute as isAbsolute2, join } from "path";
21
+ import {
22
+ SCRIPT_REGEX,
23
+ castArray as castArray2,
24
+ cloneDeep,
25
+ fse,
26
+ getNodeEnv,
27
+ isProd
28
+ } from "@rsbuild/shared";
44
29
 
45
30
  // src/helper.ts
46
- var import_node_path = require("path");
47
- var import_shared = require("@rsbuild/shared");
48
- var import_upath = __toESM(require("upath"));
31
+ import { isAbsolute, normalize, sep } from "path";
32
+ import {
33
+ castArray,
34
+ mergeChainedOptions
35
+ } from "@rsbuild/shared";
36
+ import upath from "upath";
49
37
  var BABEL_JS_RULE = "babel-js";
50
- var normalizeToPosixPath = (p) => import_upath.default.normalizeSafe((0, import_node_path.normalize)(p || "")).replace(/^([a-zA-Z]+):/, (_, m) => `/${m.toLowerCase()}`);
38
+ var normalizeToPosixPath = (p) => upath.normalizeSafe(normalize(p || "")).replace(/^([a-zA-Z]+):/, (_, m) => `/${m.toLowerCase()}`);
51
39
  var formatPath = (originPath) => {
52
- if ((0, import_node_path.isAbsolute)(originPath)) {
53
- return originPath.split(import_node_path.sep).join("/");
40
+ if (isAbsolute(originPath)) {
41
+ return originPath.split(sep).join("/");
54
42
  }
55
43
  return originPath;
56
44
  };
@@ -81,7 +69,7 @@ var removePlugins = (plugins, config) => {
81
69
  if (!config.plugins) {
82
70
  return;
83
71
  }
84
- const removeList = (0, import_shared.castArray)(plugins);
72
+ const removeList = castArray(plugins);
85
73
  config.plugins = config.plugins.filter((item) => {
86
74
  const name = getPluginItemName(item);
87
75
  if (name) {
@@ -94,7 +82,7 @@ var removePresets = (presets, config) => {
94
82
  if (!config.presets) {
95
83
  return;
96
84
  }
97
- const removeList = (0, import_shared.castArray)(presets);
85
+ const removeList = castArray(presets);
98
86
  config.presets = config.presets.filter((item) => {
99
87
  const name = getPluginItemName(item);
100
88
  if (name) {
@@ -141,7 +129,7 @@ var applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) =>
141
129
  ...getBabelUtils(defaultOptions),
142
130
  ...extraBabelUtils
143
131
  };
144
- return (0, import_shared.mergeChainedOptions)({
132
+ return mergeChainedOptions({
145
133
  defaults: defaultOptions,
146
134
  options: userBabelConfig,
147
135
  utils: babelUtils
@@ -185,14 +173,14 @@ var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
185
173
  };
186
174
  function getCacheDirectory(context, cacheDirectory) {
187
175
  if (cacheDirectory) {
188
- return (0, import_node_path2.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, import_node_path2.join)(context.rootPath, cacheDirectory);
176
+ return isAbsolute2(cacheDirectory) ? cacheDirectory : join(context.rootPath, cacheDirectory);
189
177
  }
190
- return (0, import_node_path2.join)(context.cachePath);
178
+ return join(context.cachePath);
191
179
  }
192
180
  async function getCacheIdentifier(options) {
193
- let identifier = `${(0, import_shared2.getNodeEnv)()}${JSON.stringify(options)}`;
181
+ let identifier = `${getNodeEnv()}${JSON.stringify(options)}`;
194
182
  const { version: coreVersion } = await import("@babel/core");
195
- const loaderVersion = (await import_shared2.fse.readJSON((0, import_node_path2.join)(__dirname, "../compiled/babel-loader/package.json"))).version;
183
+ const loaderVersion = (await fse.readJSON(join(__dirname, "../compiled/babel-loader/package.json"))).version;
196
184
  identifier += `@babel/core@${coreVersion}`;
197
185
  identifier += `babel-loader@${loaderVersion}`;
198
186
  return identifier;
@@ -202,20 +190,20 @@ var getDefaultBabelOptions = (config, context) => {
202
190
  const options = {
203
191
  babelrc: false,
204
192
  configFile: false,
205
- compact: (0, import_shared2.isProd)(),
193
+ compact: isProd(),
206
194
  plugins: [
207
195
  [
208
- require.resolve("@babel/plugin-proposal-decorators"),
196
+ __require.resolve("@babel/plugin-proposal-decorators"),
209
197
  config.source.decorators
210
198
  ],
211
199
  // If you are using @babel/preset-env and legacy decorators, you must ensure the class elements transform is enabled regardless of your targets, because Babel only supports compiling legacy decorators when also compiling class properties:
212
200
  // see https://babeljs.io/docs/babel-plugin-proposal-decorators#legacy
213
- ...isLegacyDecorators ? [require.resolve("@babel/plugin-transform-class-properties")] : []
201
+ ...isLegacyDecorators ? [__require.resolve("@babel/plugin-transform-class-properties")] : []
214
202
  ],
215
203
  presets: [
216
204
  // TODO: only apply preset-typescript for ts file (isTSX & allExtensions false)
217
205
  [
218
- require.resolve("@babel/preset-typescript"),
206
+ __require.resolve("@babel/preset-typescript"),
219
207
  DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
220
208
  ]
221
209
  ]
@@ -227,7 +215,7 @@ var getDefaultBabelOptions = (config, context) => {
227
215
  typeof buildCache === "boolean" ? void 0 : buildCache.cacheDirectory
228
216
  );
229
217
  options.cacheCompression = false;
230
- options.cacheDirectory = (0, import_node_path2.join)(cacheDirectory, "babel-loader");
218
+ options.cacheDirectory = join(cacheDirectory, "babel-loader");
231
219
  }
232
220
  return options;
233
221
  };
@@ -238,7 +226,7 @@ var pluginBabel = (options = {}) => ({
238
226
  const config = api.getNormalizedConfig();
239
227
  const baseOptions = getDefaultBabelOptions(config, api.context);
240
228
  const mergedOptions = applyUserBabelConfig(
241
- (0, import_shared2.cloneDeep)(baseOptions),
229
+ cloneDeep(baseOptions),
242
230
  options.babelLoaderOptions
243
231
  );
244
232
  if (mergedOptions.cacheDirectory && !mergedOptions.cacheIdentifier) {
@@ -250,7 +238,7 @@ var pluginBabel = (options = {}) => ({
250
238
  order: "pre",
251
239
  handler: async (chain, { CHAIN_ID }) => {
252
240
  const babelOptions = await getBabelOptions();
253
- const babelLoader = import_node_path2.default.resolve(
241
+ const babelLoader = path2.resolve(
254
242
  __dirname,
255
243
  "../compiled/babel-loader/index.js"
256
244
  );
@@ -258,32 +246,31 @@ var pluginBabel = (options = {}) => ({
258
246
  if (include || exclude) {
259
247
  const rule = chain.module.rule(BABEL_JS_RULE);
260
248
  if (include) {
261
- for (const condition of (0, import_shared2.castArray)(include)) {
249
+ for (const condition of castArray2(include)) {
262
250
  rule.include.add(condition);
263
251
  }
264
252
  }
265
253
  if (exclude) {
266
- for (const condition of (0, import_shared2.castArray)(exclude)) {
254
+ for (const condition of castArray2(exclude)) {
267
255
  rule.exclude.add(condition);
268
256
  }
269
257
  }
270
258
  const swcRule = chain.module.rules.get(CHAIN_ID.RULE.JS).use(CHAIN_ID.USE.SWC);
271
259
  const swcLoader = swcRule.get("loader");
272
260
  const swcOptions = swcRule.get("options");
273
- rule.test(import_shared2.SCRIPT_REGEX).use(CHAIN_ID.USE.SWC).loader(swcLoader).options(swcOptions).end().use(CHAIN_ID.USE.BABEL).loader(babelLoader).options(babelOptions);
261
+ rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.SWC).loader(swcLoader).options(swcOptions).end().use(CHAIN_ID.USE.BABEL).loader(babelLoader).options(babelOptions);
274
262
  } else {
275
263
  const rule = chain.module.rule(CHAIN_ID.RULE.JS);
276
- rule.test(import_shared2.SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(babelLoader).options(babelOptions);
264
+ rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(babelLoader).options(babelOptions);
277
265
  }
278
266
  }
279
267
  });
280
268
  }
281
269
  });
282
- // Annotate the CommonJS export names for ESM import in node:
283
- 0 && (module.exports = {
270
+ export {
284
271
  getBabelUtils,
285
272
  getDefaultBabelOptions,
286
273
  getUseBuiltIns,
287
274
  modifyBabelLoaderOptions,
288
275
  pluginBabel
289
- });
276
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-babel",
3
- "version": "0.6.15",
3
+ "version": "0.7.0-beta.1",
4
4
  "description": "Babel plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,15 +8,15 @@
8
8
  "directory": "packages/plugin-babel"
9
9
  },
10
10
  "license": "MIT",
11
- "type": "commonjs",
11
+ "type": "module",
12
12
  "exports": {
13
13
  ".": {
14
14
  "types": "./dist/index.d.ts",
15
- "import": "./dist/index.mjs",
16
- "default": "./dist/index.js"
15
+ "import": "./dist/index.js",
16
+ "require": "./dist/index.cjs"
17
17
  }
18
18
  },
19
- "main": "./dist/index.js",
19
+ "main": "./dist/index.cjs",
20
20
  "types": "./dist/index.d.ts",
21
21
  "files": [
22
22
  "dist",
@@ -29,18 +29,18 @@
29
29
  "@babel/preset-typescript": "^7.24.1",
30
30
  "@types/babel__core": "^7.20.5",
31
31
  "upath": "2.0.1",
32
- "@rsbuild/shared": "0.6.15"
32
+ "@rsbuild/shared": "0.7.0-beta.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@types/node": "18.x",
36
36
  "babel-loader": "9.1.3",
37
37
  "prebundle": "1.1.0",
38
38
  "typescript": "^5.4.2",
39
- "@rsbuild/core": "0.6.15",
40
- "@scripts/test-helper": "0.6.15"
39
+ "@rsbuild/core": "0.7.0-beta.1",
40
+ "@scripts/test-helper": "0.7.0-beta.1"
41
41
  },
42
42
  "peerDependencies": {
43
- "@rsbuild/core": "^0.6.15"
43
+ "@rsbuild/core": "^0.7.0-beta.1"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public",