@rsbuild/plugin-babel 0.7.0-beta.0 → 0.7.0-beta.2

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,3 +1,112 @@
1
- export { pluginBabel, getDefaultBabelOptions } from './plugin';
2
- export { getBabelUtils, getUseBuiltIns, modifyBabelLoaderOptions, } from './helper';
3
- export type { PresetEnvOptions, PresetEnvTargets, PresetEnvBuiltIns, BabelConfigUtils, BabelTransformOptions, PluginBabelOptions, } from './types';
1
+ import { NormalizedConfig, RsbuildContext, RsbuildPlugin } from '@rsbuild/core';
2
+ import { PluginItem, TransformOptions } from '@babel/core';
3
+ export { TransformOptions as BabelTransformOptions } from '@babel/core';
4
+ import { ChainedConfigWithUtils, NormalizedConfig as NormalizedConfig$1, BundlerChain, ChainIdentifier } from '@rsbuild/shared';
5
+
6
+ type PresetEnvTargets = string | string[] | Record<string, string>;
7
+ type PresetEnvBuiltIns = 'usage' | 'entry' | false;
8
+ type PresetEnvOptions = {
9
+ targets?: PresetEnvTargets;
10
+ bugfixes?: boolean;
11
+ spec?: boolean;
12
+ loose?: boolean;
13
+ modules?: 'amd' | 'umd' | 'systemjs' | 'commonjs' | 'cjs' | 'auto' | false;
14
+ debug?: boolean;
15
+ include?: string[];
16
+ exclude?: string[];
17
+ useBuiltIns?: PresetEnvBuiltIns;
18
+ corejs?: string | {
19
+ version: string;
20
+ proposals: boolean;
21
+ };
22
+ forceAllTransforms?: boolean;
23
+ configPath?: string;
24
+ ignoreBrowserslistConfig?: boolean;
25
+ browserslistEnv?: string;
26
+ shippedProposals?: boolean;
27
+ };
28
+ interface SharedBabelPresetReactOptions {
29
+ development?: boolean;
30
+ throwIfNamespace?: boolean;
31
+ }
32
+ interface AutomaticRuntimePresetReactOptions extends SharedBabelPresetReactOptions {
33
+ runtime?: 'automatic';
34
+ importSource?: string;
35
+ }
36
+ interface ClassicRuntimePresetReactOptions extends SharedBabelPresetReactOptions {
37
+ runtime?: 'classic';
38
+ pragma?: string;
39
+ pragmaFrag?: string;
40
+ useBuiltIns?: boolean;
41
+ useSpread?: boolean;
42
+ }
43
+ type PresetReactOptions = AutomaticRuntimePresetReactOptions | ClassicRuntimePresetReactOptions;
44
+ type RuleCondition = string | RegExp | (string | RegExp)[];
45
+ type BabelConfigUtils = {
46
+ addPlugins: (plugins: PluginItem[]) => void;
47
+ addPresets: (presets: PluginItem[]) => void;
48
+ removePlugins: (plugins: string | string[]) => void;
49
+ removePresets: (presets: string | string[]) => void;
50
+ modifyPresetEnvOptions: (options: PresetEnvOptions) => void;
51
+ modifyPresetReactOptions: (options: PresetReactOptions) => void;
52
+ /**
53
+ * use `source.include` instead
54
+ * @deprecated
55
+ */
56
+ addIncludes: (includes: RuleCondition) => void;
57
+ /**
58
+ * use `source.exclude` instead
59
+ * @deprecated
60
+ */
61
+ addExcludes: (excludes: RuleCondition) => void;
62
+ };
63
+ type BabelLoaderOptions = TransformOptions & {
64
+ /**
65
+ * When set, the given directory will be used to cache the results of the loader.
66
+ */
67
+ cacheDirectory?: string | boolean;
68
+ /**
69
+ * Can be set to a custom value to force cache busting if the identifier changes.
70
+ */
71
+ cacheIdentifier?: string;
72
+ /**
73
+ * When set, each Babel transform output will be compressed with Gzip.
74
+ */
75
+ cacheCompression?: boolean;
76
+ /**
77
+ * The path of a module that exports a custom callback.
78
+ */
79
+ customize?: string | null;
80
+ /**
81
+ * Takes an array of context function names. E.g.
82
+ */
83
+ metadataSubscribers?: string[];
84
+ };
85
+ type PluginBabelOptions = {
86
+ /**
87
+ * Used to specify the files that need to be compiled by Babel.
88
+ */
89
+ include?: RuleCondition;
90
+ /**
91
+ * Used to specify the files that do not need to be compiled by Babel.
92
+ */
93
+ exclude?: RuleCondition;
94
+ /**
95
+ * Options passed to `babel-loader`.
96
+ * @see https://github.com/babel/babel-loader
97
+ */
98
+ babelLoaderOptions?: ChainedConfigWithUtils<BabelLoaderOptions, BabelConfigUtils>;
99
+ };
100
+
101
+ declare const getDefaultBabelOptions: (config: NormalizedConfig, context: RsbuildContext) => BabelLoaderOptions;
102
+ declare const pluginBabel: (options?: PluginBabelOptions) => RsbuildPlugin;
103
+
104
+ declare const getBabelUtils: (config: TransformOptions) => BabelConfigUtils;
105
+ declare const getUseBuiltIns: (config: NormalizedConfig$1) => false | "usage" | "entry";
106
+ declare const modifyBabelLoaderOptions: ({ chain, CHAIN_ID, modifier, }: {
107
+ chain: BundlerChain;
108
+ CHAIN_ID: ChainIdentifier;
109
+ modifier: (config: TransformOptions) => TransformOptions;
110
+ }) => void;
111
+
112
+ export { type BabelConfigUtils, type PluginBabelOptions, type PresetEnvBuiltIns, type PresetEnvOptions, type PresetEnvTargets, getBabelUtils, getDefaultBabelOptions, getUseBuiltIns, modifyBabelLoaderOptions, pluginBabel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rsbuild/plugin-babel",
3
- "version": "0.7.0-beta.0",
3
+ "version": "0.7.0-beta.2",
4
4
  "description": "Babel plugin for Rsbuild",
5
5
  "repository": {
6
6
  "type": "git",
@@ -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.7.0-beta.0"
32
+ "@rsbuild/shared": "0.7.0-beta.2"
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.7.0-beta.0",
40
- "@scripts/test-helper": "0.7.0-beta.0"
39
+ "@rsbuild/core": "0.7.0-beta.2",
40
+ "@scripts/test-helper": "0.7.0-beta.2"
41
41
  },
42
42
  "peerDependencies": {
43
- "@rsbuild/core": "^0.7.0-beta.0"
43
+ "@rsbuild/core": "^0.7.0-beta.2"
44
44
  },
45
45
  "publishConfig": {
46
46
  "access": "public",
package/dist/helper.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { type BundlerChain, type ChainIdentifier, type NormalizedConfig } from '@rsbuild/shared';
2
- import type { BabelConfigUtils, BabelLoaderOptions, BabelTransformOptions, PluginBabelOptions } from './types';
3
- export declare const BABEL_JS_RULE = "babel-js";
4
- export declare const getBabelUtils: (config: BabelTransformOptions) => BabelConfigUtils;
5
- export declare const applyUserBabelConfig: (defaultOptions: BabelLoaderOptions, userBabelConfig?: PluginBabelOptions['babelLoaderOptions'], extraBabelUtils?: Partial<BabelConfigUtils>) => BabelLoaderOptions;
6
- export declare const getUseBuiltIns: (config: NormalizedConfig) => false | "usage" | "entry";
7
- export declare const modifyBabelLoaderOptions: ({ chain, CHAIN_ID, modifier, }: {
8
- chain: BundlerChain;
9
- CHAIN_ID: ChainIdentifier;
10
- modifier: (config: BabelTransformOptions) => BabelTransformOptions;
11
- }) => void;
package/dist/plugin.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import type { NormalizedConfig, RsbuildContext, RsbuildPlugin } from '@rsbuild/core';
2
- import type { BabelLoaderOptions, PluginBabelOptions } from './types';
3
- export declare const PLUGIN_BABEL_NAME = "rsbuild:babel";
4
- /**
5
- * The `@babel/preset-typescript` default options.
6
- */
7
- export declare const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS: {
8
- allowNamespaces: boolean;
9
- allExtensions: boolean;
10
- allowDeclareFields: boolean;
11
- optimizeConstEnums: boolean;
12
- isTSX: boolean;
13
- };
14
- export declare const getDefaultBabelOptions: (config: NormalizedConfig, context: RsbuildContext) => BabelLoaderOptions;
15
- export declare const pluginBabel: (options?: PluginBabelOptions) => RsbuildPlugin;
package/dist/types.d.ts DELETED
@@ -1,97 +0,0 @@
1
- import type { PluginItem as BabelPlugin, TransformOptions as BabelTransformOptions } from '@babel/core';
2
- import type { ChainedConfigWithUtils } from '@rsbuild/shared';
3
- export type { BabelPlugin, BabelTransformOptions };
4
- export type PresetEnvTargets = string | string[] | Record<string, string>;
5
- export type PresetEnvBuiltIns = 'usage' | 'entry' | false;
6
- export type PresetEnvOptions = {
7
- targets?: PresetEnvTargets;
8
- bugfixes?: boolean;
9
- spec?: boolean;
10
- loose?: boolean;
11
- modules?: 'amd' | 'umd' | 'systemjs' | 'commonjs' | 'cjs' | 'auto' | false;
12
- debug?: boolean;
13
- include?: string[];
14
- exclude?: string[];
15
- useBuiltIns?: PresetEnvBuiltIns;
16
- corejs?: string | {
17
- version: string;
18
- proposals: boolean;
19
- };
20
- forceAllTransforms?: boolean;
21
- configPath?: string;
22
- ignoreBrowserslistConfig?: boolean;
23
- browserslistEnv?: string;
24
- shippedProposals?: boolean;
25
- };
26
- export interface SharedBabelPresetReactOptions {
27
- development?: boolean;
28
- throwIfNamespace?: boolean;
29
- }
30
- export interface AutomaticRuntimePresetReactOptions extends SharedBabelPresetReactOptions {
31
- runtime?: 'automatic';
32
- importSource?: string;
33
- }
34
- export interface ClassicRuntimePresetReactOptions extends SharedBabelPresetReactOptions {
35
- runtime?: 'classic';
36
- pragma?: string;
37
- pragmaFrag?: string;
38
- useBuiltIns?: boolean;
39
- useSpread?: boolean;
40
- }
41
- export type PresetReactOptions = AutomaticRuntimePresetReactOptions | ClassicRuntimePresetReactOptions;
42
- export type RuleCondition = string | RegExp | (string | RegExp)[];
43
- export type BabelConfigUtils = {
44
- addPlugins: (plugins: BabelPlugin[]) => void;
45
- addPresets: (presets: BabelPlugin[]) => void;
46
- removePlugins: (plugins: string | string[]) => void;
47
- removePresets: (presets: string | string[]) => void;
48
- modifyPresetEnvOptions: (options: PresetEnvOptions) => void;
49
- modifyPresetReactOptions: (options: PresetReactOptions) => void;
50
- /**
51
- * use `source.include` instead
52
- * @deprecated
53
- */
54
- addIncludes: (includes: RuleCondition) => void;
55
- /**
56
- * use `source.exclude` instead
57
- * @deprecated
58
- */
59
- addExcludes: (excludes: RuleCondition) => void;
60
- };
61
- export type BabelLoaderOptions = BabelTransformOptions & {
62
- /**
63
- * When set, the given directory will be used to cache the results of the loader.
64
- */
65
- cacheDirectory?: string | boolean;
66
- /**
67
- * Can be set to a custom value to force cache busting if the identifier changes.
68
- */
69
- cacheIdentifier?: string;
70
- /**
71
- * When set, each Babel transform output will be compressed with Gzip.
72
- */
73
- cacheCompression?: boolean;
74
- /**
75
- * The path of a module that exports a custom callback.
76
- */
77
- customize?: string | null;
78
- /**
79
- * Takes an array of context function names. E.g.
80
- */
81
- metadataSubscribers?: string[];
82
- };
83
- export type PluginBabelOptions = {
84
- /**
85
- * Used to specify the files that need to be compiled by Babel.
86
- */
87
- include?: RuleCondition;
88
- /**
89
- * Used to specify the files that do not need to be compiled by Babel.
90
- */
91
- exclude?: RuleCondition;
92
- /**
93
- * Options passed to `babel-loader`.
94
- * @see https://github.com/babel/babel-loader
95
- */
96
- babelLoaderOptions?: ChainedConfigWithUtils<BabelLoaderOptions, BabelConfigUtils>;
97
- };