@rsbuild/plugin-babel 0.1.2 → 0.1.4

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { RsbuildPlugin } from '@rsbuild/core';
2
- import { ChainedConfigWithUtils } from '@rsbuild/shared';
2
+ import { ChainedConfigWithUtils, NormalizedConfig } from '@rsbuild/shared';
3
3
  import { PluginItem, TransformOptions } from '@babel/core';
4
4
  export { TransformOptions as BabelTransformOptions } from '@babel/core';
5
5
 
@@ -56,5 +56,6 @@ type PluginBabelOptions = ChainedConfigWithUtils<TransformOptions, BabelConfigUt
56
56
  declare const pluginBabel: (options?: PluginBabelOptions) => RsbuildPlugin;
57
57
 
58
58
  declare const getBabelUtils: (config: TransformOptions) => BabelConfigUtils;
59
+ declare const getUseBuiltIns: (config: NormalizedConfig) => false | "usage" | "entry";
59
60
 
60
- export { BabelConfigUtils, PresetEnvBuiltIns, PresetEnvOptions, PresetEnvTargets, getBabelUtils, pluginBabel };
61
+ export { BabelConfigUtils, PresetEnvBuiltIns, PresetEnvOptions, PresetEnvTargets, getBabelUtils, getUseBuiltIns, pluginBabel };
package/dist/index.js CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var src_exports = {};
32
32
  __export(src_exports, {
33
33
  getBabelUtils: () => getBabelUtils,
34
+ getUseBuiltIns: () => getUseBuiltIns,
34
35
  pluginBabel: () => pluginBabel
35
36
  });
36
37
  module.exports = __toCommonJS(src_exports);
@@ -145,6 +146,13 @@ var applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) =>
145
146
  }
146
147
  return defaultOptions;
147
148
  };
149
+ var getUseBuiltIns = (config) => {
150
+ const { polyfill } = config.output;
151
+ if (polyfill === "ua" || polyfill === "off") {
152
+ return false;
153
+ }
154
+ return polyfill;
155
+ };
148
156
 
149
157
  // src/plugin.ts
150
158
  var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
@@ -224,5 +232,6 @@ var pluginBabel = (options = {}) => ({
224
232
  // Annotate the CommonJS export names for ESM import in node:
225
233
  0 && (module.exports = {
226
234
  getBabelUtils,
235
+ getUseBuiltIns,
227
236
  pluginBabel
228
237
  });
package/dist/index.mjs CHANGED
@@ -20,7 +20,10 @@ import { cloneDeep } from "lodash";
20
20
 
21
21
  // src/helper.ts
22
22
  import { isAbsolute, normalize, sep } from "path";
23
- import { castArray, mergeChainedOptions } from "@rsbuild/shared";
23
+ import {
24
+ castArray,
25
+ mergeChainedOptions
26
+ } from "@rsbuild/shared";
24
27
  import upath from "upath";
25
28
  var normalizeToPosixPath = (p) => upath.normalizeSafe(normalize(p || "")).replace(/^([a-zA-Z]+):/, (_, m) => `/${m.toLowerCase()}`);
26
29
  var formatPath = (originPath) => {
@@ -124,6 +127,13 @@ var applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) =>
124
127
  }
125
128
  return defaultOptions;
126
129
  };
130
+ var getUseBuiltIns = (config) => {
131
+ const { polyfill } = config.output;
132
+ if (polyfill === "ua" || polyfill === "off") {
133
+ return false;
134
+ }
135
+ return polyfill;
136
+ };
127
137
 
128
138
  // src/plugin.ts
129
139
  var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
@@ -202,5 +212,6 @@ var pluginBabel = (options = {}) => ({
202
212
  });
203
213
  export {
204
214
  getBabelUtils,
215
+ getUseBuiltIns,
205
216
  pluginBabel
206
217
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-babel",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Babel plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,14 +27,14 @@
27
27
  "babel-loader": "9.1.3",
28
28
  "lodash": "^4.17.21",
29
29
  "upath": "2.0.1",
30
- "@rsbuild/shared": "0.1.2"
30
+ "@rsbuild/shared": "0.1.4"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/lodash": "^4.14.200",
34
34
  "@types/node": "^16",
35
35
  "typescript": "^5.3.0",
36
- "@rsbuild/core": "0.1.2",
37
- "@rsbuild/test-helper": "0.1.2"
36
+ "@rsbuild/test-helper": "0.1.4",
37
+ "@rsbuild/core": "0.1.4"
38
38
  },
39
39
  "publishConfig": {
40
40
  "access": "public",