@rsbuild/plugin-babel 0.3.10 → 0.3.11
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 +3 -3
- package/dist/index.js +6 -3
- package/dist/index.mjs +12 -4
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
import { ChainedConfigWithUtils, NormalizedConfig, BundlerChain, ChainIdentifier } from '@rsbuild/shared';
|
|
2
|
+
import { ChainedConfigWithUtils, Decorators, NormalizedConfig, BundlerChain, ChainIdentifier } from '@rsbuild/shared';
|
|
3
3
|
import { PluginItem, TransformOptions } from '@babel/core';
|
|
4
4
|
export { TransformOptions as BabelTransformOptions } from '@babel/core';
|
|
5
5
|
|
|
@@ -76,11 +76,11 @@ type PluginBabelOptions = {
|
|
|
76
76
|
babelLoaderOptions?: ChainedConfigWithUtils<TransformOptions, BabelConfigUtils>;
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
declare const getDefaultBabelOptions: () => {
|
|
79
|
+
declare const getDefaultBabelOptions: (decorators: Decorators) => {
|
|
80
80
|
babelrc: boolean;
|
|
81
81
|
configFile: boolean;
|
|
82
82
|
compact: boolean;
|
|
83
|
-
plugins:
|
|
83
|
+
plugins: (string | Decorators)[][];
|
|
84
84
|
presets: (string | {
|
|
85
85
|
allowNamespaces: boolean;
|
|
86
86
|
allExtensions: boolean;
|
package/dist/index.js
CHANGED
|
@@ -183,12 +183,14 @@ var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
|
|
183
183
|
optimizeConstEnums: true,
|
|
184
184
|
isTSX: true
|
|
185
185
|
};
|
|
186
|
-
var getDefaultBabelOptions = () => {
|
|
186
|
+
var getDefaultBabelOptions = (decorators) => {
|
|
187
187
|
return {
|
|
188
188
|
babelrc: false,
|
|
189
189
|
configFile: false,
|
|
190
190
|
compact: (0, import_shared2.isProd)(),
|
|
191
|
-
plugins: [
|
|
191
|
+
plugins: [
|
|
192
|
+
[require.resolve("@babel/plugin-proposal-decorators"), decorators]
|
|
193
|
+
],
|
|
192
194
|
presets: [
|
|
193
195
|
// TODO: only apply preset-typescript for ts file (isTSX & allExtensions false)
|
|
194
196
|
[
|
|
@@ -202,8 +204,9 @@ var pluginBabel = (options = {}) => ({
|
|
|
202
204
|
name: import_core.PLUGIN_BABEL_NAME,
|
|
203
205
|
setup(api) {
|
|
204
206
|
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
207
|
+
const config = api.getNormalizedConfig();
|
|
205
208
|
const getBabelOptions = () => {
|
|
206
|
-
const baseConfig = getDefaultBabelOptions();
|
|
209
|
+
const baseConfig = getDefaultBabelOptions(config.source.decorators);
|
|
207
210
|
const userBabelConfig = applyUserBabelConfig(
|
|
208
211
|
(0, import_shared2.cloneDeep)(baseConfig),
|
|
209
212
|
options.babelLoaderOptions
|
package/dist/index.mjs
CHANGED
|
@@ -19,7 +19,12 @@ var __dirname = /* @__PURE__ */ getDirname();
|
|
|
19
19
|
// src/plugin.ts
|
|
20
20
|
import path2 from "path";
|
|
21
21
|
import { PLUGIN_BABEL_NAME } from "@rsbuild/core";
|
|
22
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
castArray as castArray2,
|
|
24
|
+
cloneDeep,
|
|
25
|
+
SCRIPT_REGEX,
|
|
26
|
+
isProd
|
|
27
|
+
} from "@rsbuild/shared";
|
|
23
28
|
|
|
24
29
|
// src/helper.ts
|
|
25
30
|
import { isAbsolute, normalize, sep } from "path";
|
|
@@ -164,12 +169,14 @@ var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
|
|
164
169
|
optimizeConstEnums: true,
|
|
165
170
|
isTSX: true
|
|
166
171
|
};
|
|
167
|
-
var getDefaultBabelOptions = () => {
|
|
172
|
+
var getDefaultBabelOptions = (decorators) => {
|
|
168
173
|
return {
|
|
169
174
|
babelrc: false,
|
|
170
175
|
configFile: false,
|
|
171
176
|
compact: isProd(),
|
|
172
|
-
plugins: [
|
|
177
|
+
plugins: [
|
|
178
|
+
[__require.resolve("@babel/plugin-proposal-decorators"), decorators]
|
|
179
|
+
],
|
|
173
180
|
presets: [
|
|
174
181
|
// TODO: only apply preset-typescript for ts file (isTSX & allExtensions false)
|
|
175
182
|
[
|
|
@@ -183,8 +190,9 @@ var pluginBabel = (options = {}) => ({
|
|
|
183
190
|
name: PLUGIN_BABEL_NAME,
|
|
184
191
|
setup(api) {
|
|
185
192
|
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
193
|
+
const config = api.getNormalizedConfig();
|
|
186
194
|
const getBabelOptions = () => {
|
|
187
|
-
const baseConfig = getDefaultBabelOptions();
|
|
195
|
+
const baseConfig = getDefaultBabelOptions(config.source.decorators);
|
|
188
196
|
const userBabelConfig = applyUserBabelConfig(
|
|
189
197
|
cloneDeep(baseConfig),
|
|
190
198
|
options.babelLoaderOptions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-babel",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "Babel plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,18 +25,19 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/core": "^7.23.2",
|
|
27
27
|
"@babel/preset-typescript": "^7.23.2",
|
|
28
|
+
"@babel/plugin-proposal-decorators": "^7.23.2",
|
|
28
29
|
"@types/babel__core": "^7.20.3",
|
|
29
30
|
"upath": "2.0.1",
|
|
30
|
-
"@rsbuild/shared": "0.3.
|
|
31
|
+
"@rsbuild/shared": "0.3.11"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@types/node": "16.x",
|
|
34
35
|
"typescript": "^5.3.0",
|
|
35
|
-
"@rsbuild/core": "0.3.
|
|
36
|
-
"@scripts/test-helper": "0.3.
|
|
36
|
+
"@rsbuild/core": "0.3.11",
|
|
37
|
+
"@scripts/test-helper": "0.3.11"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
39
|
-
"@rsbuild/core": "^0.3.
|
|
40
|
+
"@rsbuild/core": "^0.3.11"
|
|
40
41
|
},
|
|
41
42
|
"publishConfig": {
|
|
42
43
|
"access": "public",
|