@rsbuild/plugin-babel 1.0.1-rc.5 → 1.0.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/compiled/babel-loader/index.js +51 -37
- package/compiled/babel-loader/package.json +1 -1
- package/{dist-types → dist}/helper.d.ts +1 -1
- package/dist/index.cjs +313 -268
- package/{dist-types → dist}/index.d.ts +3 -3
- package/dist/index.js +192 -248
- package/{dist-types → dist}/plugin.d.ts +1 -1
- package/package.json +15 -16
- package/dist-types/package.json +0 -1
- /package/{dist-types → dist}/types.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,268 +1,212 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
16
|
-
var getDirname = () => path.dirname(getFilename());
|
|
17
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
18
|
-
|
|
19
|
-
// src/plugin.ts
|
|
20
|
-
import fs from "fs";
|
|
21
|
-
import path2, { isAbsolute as isAbsolute2, join } from "path";
|
|
22
|
-
import deepmerge from "deepmerge";
|
|
23
|
-
|
|
24
|
-
// src/helper.ts
|
|
25
|
-
import { isAbsolute, normalize, sep } from "path";
|
|
26
|
-
import { reduceConfigsWithContext } from "reduce-configs";
|
|
27
|
-
import upath from "upath";
|
|
28
|
-
var BABEL_JS_RULE = "babel-js";
|
|
29
|
-
var castArray = (arr) => {
|
|
30
|
-
if (arr === void 0) {
|
|
31
|
-
return [];
|
|
32
|
-
}
|
|
33
|
-
return Array.isArray(arr) ? arr : [arr];
|
|
1
|
+
import { fileURLToPath as __webpack_fileURLToPath__ } from "url";
|
|
2
|
+
import { dirname as __webpack_dirname__ } from "path";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs__ from "node:fs";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_module__ from "node:module";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
|
|
6
|
+
import * as __WEBPACK_EXTERNAL_MODULE_deepmerge__ from "deepmerge";
|
|
7
|
+
import * as __WEBPACK_EXTERNAL_MODULE_reduce_configs__ from "reduce-configs";
|
|
8
|
+
import * as __WEBPACK_EXTERNAL_MODULE_upath__ from "upath";
|
|
9
|
+
const BABEL_JS_RULE = 'babel-js';
|
|
10
|
+
const castArray = (arr)=>{
|
|
11
|
+
if (void 0 === arr) return [];
|
|
12
|
+
return Array.isArray(arr) ? arr : [
|
|
13
|
+
arr
|
|
14
|
+
];
|
|
34
15
|
};
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return originPath.split(sep).join(
|
|
39
|
-
|
|
40
|
-
return originPath;
|
|
16
|
+
const normalizeToPosixPath = (p)=>__WEBPACK_EXTERNAL_MODULE_upath__["default"].normalizeSafe((0, __WEBPACK_EXTERNAL_MODULE_node_path__.normalize)(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
|
|
17
|
+
// compatible with windows path
|
|
18
|
+
const formatPath = (originPath)=>{
|
|
19
|
+
if ((0, __WEBPACK_EXTERNAL_MODULE_node_path__.isAbsolute)(originPath)) return originPath.split(__WEBPACK_EXTERNAL_MODULE_node_path__.sep).join('/');
|
|
20
|
+
return originPath;
|
|
41
21
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return formatPath(item);
|
|
45
|
-
|
|
46
|
-
if (Array.isArray(item) && typeof item[0] === "string") {
|
|
47
|
-
return formatPath(item[0]);
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
22
|
+
const getPluginItemName = (item)=>{
|
|
23
|
+
if ('string' == typeof item) return formatPath(item);
|
|
24
|
+
if (Array.isArray(item) && 'string' == typeof item[0]) return formatPath(item[0]);
|
|
25
|
+
return null;
|
|
50
26
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
config.plugins
|
|
54
|
-
} else {
|
|
55
|
-
config.plugins = plugins;
|
|
56
|
-
}
|
|
27
|
+
const addPlugins = (plugins, config)=>{
|
|
28
|
+
if (config.plugins) config.plugins.push(...plugins);
|
|
29
|
+
else config.plugins = plugins;
|
|
57
30
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
config.presets
|
|
61
|
-
} else {
|
|
62
|
-
config.presets = presets;
|
|
63
|
-
}
|
|
31
|
+
const addPresets = (presets, config)=>{
|
|
32
|
+
if (config.presets) config.presets.push(...presets);
|
|
33
|
+
else config.presets = presets;
|
|
64
34
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
return !removeList.find((removeItem) => name.includes(removeItem));
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
var removePresets = (presets, config) => {
|
|
79
|
-
if (!config.presets) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
const removeList = castArray(presets);
|
|
83
|
-
config.presets = config.presets.filter((item) => {
|
|
84
|
-
const name = getPluginItemName(item);
|
|
85
|
-
if (name) {
|
|
86
|
-
return !removeList.find((removeItem) => name.includes(removeItem));
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
});
|
|
35
|
+
const removePlugins = (plugins, config)=>{
|
|
36
|
+
if (!config.plugins) return;
|
|
37
|
+
const removeList = castArray(plugins);
|
|
38
|
+
config.plugins = config.plugins.filter((item)=>{
|
|
39
|
+
const name = getPluginItemName(item);
|
|
40
|
+
if (name) return !removeList.find((removeItem)=>name.includes(removeItem));
|
|
41
|
+
return true;
|
|
42
|
+
});
|
|
90
43
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
} else if (typeof preset === "string" && normalizeToPosixPath(preset).includes(presetName)) {
|
|
102
|
-
presets[index] = [preset, options];
|
|
103
|
-
}
|
|
104
|
-
});
|
|
44
|
+
const removePresets = (presets, config)=>{
|
|
45
|
+
if (!config.presets) return;
|
|
46
|
+
const removeList = castArray(presets);
|
|
47
|
+
config.presets = config.presets.filter((item)=>{
|
|
48
|
+
const name = getPluginItemName(item);
|
|
49
|
+
if (name) return !removeList.find((removeItem)=>name.includes(removeItem));
|
|
50
|
+
return true;
|
|
51
|
+
});
|
|
105
52
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
};
|
|
53
|
+
const modifyPresetOptions = function(presetName, options) {
|
|
54
|
+
let presets = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : [];
|
|
55
|
+
presets.forEach((preset, index)=>{
|
|
56
|
+
// 1. ['@babel/preset-env', ...]
|
|
57
|
+
if (Array.isArray(preset)) {
|
|
58
|
+
if ('string' == typeof preset[0] && normalizeToPosixPath(preset[0]).includes(presetName)) preset[1] = {
|
|
59
|
+
...preset[1] || {},
|
|
60
|
+
...options
|
|
61
|
+
};
|
|
62
|
+
} else if ('string' == typeof preset && normalizeToPosixPath(preset).includes(presetName)) // 2. '@babel/preset-env'
|
|
63
|
+
presets[index] = [
|
|
64
|
+
preset,
|
|
65
|
+
options
|
|
66
|
+
];
|
|
67
|
+
});
|
|
122
68
|
};
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
69
|
+
const getBabelUtils = (config)=>{
|
|
70
|
+
const noop = ()=>{};
|
|
71
|
+
return {
|
|
72
|
+
addPlugins: (plugins)=>addPlugins(plugins, config),
|
|
73
|
+
addPresets: (presets)=>addPresets(presets, config),
|
|
74
|
+
removePlugins: (plugins)=>removePlugins(plugins, config),
|
|
75
|
+
removePresets: (presets)=>removePresets(presets, config),
|
|
76
|
+
// `addIncludes` and `addExcludes` are noop functions by default,
|
|
77
|
+
// It can be overridden by `extraBabelUtils`.
|
|
78
|
+
addIncludes: noop,
|
|
79
|
+
addExcludes: noop,
|
|
80
|
+
// Compat `presetEnvOptions` and `presetReactOptions` in Modern.js
|
|
81
|
+
modifyPresetEnvOptions: (options)=>modifyPresetOptions('@babel/preset-env', options, config.presets || []),
|
|
82
|
+
modifyPresetReactOptions: (options)=>modifyPresetOptions('@babel/preset-react', options, config.presets || [])
|
|
128
83
|
};
|
|
129
|
-
return reduceConfigsWithContext({
|
|
130
|
-
initial: defaultOptions,
|
|
131
|
-
config: userBabelConfig,
|
|
132
|
-
ctx: babelUtils
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
return defaultOptions;
|
|
136
84
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
85
|
+
const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils)=>{
|
|
86
|
+
if (userBabelConfig) {
|
|
87
|
+
const babelUtils = {
|
|
88
|
+
...getBabelUtils(defaultOptions),
|
|
89
|
+
...extraBabelUtils
|
|
90
|
+
};
|
|
91
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_reduce_configs__.reduceConfigsWithContext)({
|
|
92
|
+
initial: defaultOptions,
|
|
93
|
+
config: userBabelConfig,
|
|
94
|
+
ctx: babelUtils
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
return defaultOptions;
|
|
98
|
+
};
|
|
99
|
+
const modifyBabelLoaderOptions = (param)=>{
|
|
100
|
+
let { chain, CHAIN_ID, modifier } = param;
|
|
101
|
+
const ruleIds = [
|
|
102
|
+
CHAIN_ID.RULE.JS,
|
|
103
|
+
CHAIN_ID.RULE.JS_DATA_URI,
|
|
104
|
+
BABEL_JS_RULE
|
|
105
|
+
];
|
|
106
|
+
for (const ruleId of ruleIds)if (chain.module.rules.has(ruleId)) {
|
|
107
|
+
const rule = chain.module.rule(ruleId);
|
|
108
|
+
if (rule.uses.has(CHAIN_ID.USE.BABEL)) rule.use(CHAIN_ID.USE.BABEL).tap(modifier);
|
|
149
109
|
}
|
|
150
|
-
}
|
|
151
110
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
111
|
+
var plugin_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
112
|
+
const plugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module__.createRequire)(import.meta.url);
|
|
113
|
+
const PLUGIN_BABEL_NAME = 'rsbuild:babel';
|
|
114
|
+
const SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/;
|
|
115
|
+
/**
|
|
116
|
+
* The `@babel/preset-typescript` default options.
|
|
117
|
+
*/ const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
|
118
|
+
allowNamespaces: true,
|
|
119
|
+
allExtensions: true,
|
|
120
|
+
allowDeclareFields: true,
|
|
121
|
+
// aligns Babel's behavior with TypeScript's default behavior.
|
|
122
|
+
// https://babeljs.io/docs/en/babel-preset-typescript#optimizeconstenums
|
|
123
|
+
optimizeConstEnums: true,
|
|
124
|
+
isTSX: true
|
|
164
125
|
};
|
|
165
126
|
function getCacheDirectory(context, cacheDirectory) {
|
|
166
|
-
|
|
167
|
-
return
|
|
168
|
-
}
|
|
169
|
-
return join(context.cachePath);
|
|
127
|
+
if (cacheDirectory) return (0, __WEBPACK_EXTERNAL_MODULE_node_path__.isAbsolute)(cacheDirectory) ? cacheDirectory : (0, __WEBPACK_EXTERNAL_MODULE_node_path__.join)(context.rootPath, cacheDirectory);
|
|
128
|
+
return (0, __WEBPACK_EXTERNAL_MODULE_node_path__.join)(context.cachePath);
|
|
170
129
|
}
|
|
171
130
|
async function getCacheIdentifier(options) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
identifier += `@babel/core@${coreVersion}`;
|
|
180
|
-
identifier += `babel-loader@${loaderVersion}`;
|
|
181
|
-
return identifier;
|
|
131
|
+
let identifier = `${process.env.NODE_ENV}${JSON.stringify(options)}`;
|
|
132
|
+
const { version: coreVersion } = await import("@babel/core");
|
|
133
|
+
const rawPkgJson = await __WEBPACK_EXTERNAL_MODULE_node_fs__["default"].promises.readFile((0, __WEBPACK_EXTERNAL_MODULE_node_path__.join)(plugin_dirname, '../compiled/babel-loader/package.json'), 'utf-8');
|
|
134
|
+
const loaderVersion = JSON.parse(rawPkgJson).version ?? '';
|
|
135
|
+
identifier += `@babel/core@${coreVersion}`;
|
|
136
|
+
identifier += `babel-loader@${loaderVersion}`;
|
|
137
|
+
return identifier;
|
|
182
138
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (buildCache && context.bundlerType === "rspack") {
|
|
208
|
-
const cacheDirectory = getCacheDirectory(
|
|
209
|
-
context,
|
|
210
|
-
typeof buildCache === "boolean" ? void 0 : buildCache.cacheDirectory
|
|
211
|
-
);
|
|
212
|
-
options.cacheCompression = false;
|
|
213
|
-
options.cacheDirectory = join(cacheDirectory, "babel-loader");
|
|
214
|
-
}
|
|
215
|
-
return options;
|
|
216
|
-
};
|
|
217
|
-
var pluginBabel = (options = {}) => ({
|
|
218
|
-
name: PLUGIN_BABEL_NAME,
|
|
219
|
-
setup(api) {
|
|
220
|
-
const getBabelOptions = async (environment) => {
|
|
221
|
-
const { config } = environment;
|
|
222
|
-
const baseOptions = getDefaultBabelOptions(config, api.context);
|
|
223
|
-
const mergedOptions = applyUserBabelConfig(
|
|
224
|
-
deepmerge({}, baseOptions),
|
|
225
|
-
options.babelLoaderOptions
|
|
226
|
-
);
|
|
227
|
-
if (mergedOptions.cacheDirectory && !mergedOptions.cacheIdentifier) {
|
|
228
|
-
mergedOptions.cacheIdentifier = await getCacheIdentifier(mergedOptions);
|
|
229
|
-
}
|
|
230
|
-
return mergedOptions;
|
|
139
|
+
const getDefaultBabelOptions = (config, context)=>{
|
|
140
|
+
const isLegacyDecorators = 'legacy' === config.source.decorators.version;
|
|
141
|
+
const options = {
|
|
142
|
+
babelrc: false,
|
|
143
|
+
configFile: false,
|
|
144
|
+
compact: 'production' === config.mode,
|
|
145
|
+
plugins: [
|
|
146
|
+
[
|
|
147
|
+
plugin_require.resolve('@babel/plugin-proposal-decorators'),
|
|
148
|
+
config.source.decorators
|
|
149
|
+
],
|
|
150
|
+
// 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:
|
|
151
|
+
// see https://babeljs.io/docs/babel-plugin-proposal-decorators#legacy
|
|
152
|
+
...isLegacyDecorators ? [
|
|
153
|
+
plugin_require.resolve('@babel/plugin-transform-class-properties')
|
|
154
|
+
] : []
|
|
155
|
+
],
|
|
156
|
+
presets: [
|
|
157
|
+
// TODO: only apply preset-typescript for ts file (isTSX & allExtensions false)
|
|
158
|
+
[
|
|
159
|
+
plugin_require.resolve('@babel/preset-typescript'),
|
|
160
|
+
DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS
|
|
161
|
+
]
|
|
162
|
+
]
|
|
231
163
|
};
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
164
|
+
const { buildCache } = config.performance;
|
|
165
|
+
// Rspack does not yet support persistent cache
|
|
166
|
+
// so we use babel-loader's cache to improve rebuild performance
|
|
167
|
+
if (buildCache && 'rspack' === context.bundlerType) {
|
|
168
|
+
const cacheDirectory = getCacheDirectory(context, 'boolean' == typeof buildCache ? void 0 : buildCache.cacheDirectory);
|
|
169
|
+
// turn off compression to reduce overhead
|
|
170
|
+
options.cacheCompression = false;
|
|
171
|
+
options.cacheDirectory = (0, __WEBPACK_EXTERNAL_MODULE_node_path__.join)(cacheDirectory, 'babel-loader');
|
|
172
|
+
}
|
|
173
|
+
return options;
|
|
174
|
+
};
|
|
175
|
+
const pluginBabel = function() {
|
|
176
|
+
let options = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
|
|
177
|
+
return {
|
|
178
|
+
name: PLUGIN_BABEL_NAME,
|
|
179
|
+
setup (api) {
|
|
180
|
+
const getBabelOptions = async (environment)=>{
|
|
181
|
+
const { config } = environment;
|
|
182
|
+
const baseOptions = getDefaultBabelOptions(config, api.context);
|
|
183
|
+
const mergedOptions = applyUserBabelConfig((0, __WEBPACK_EXTERNAL_MODULE_deepmerge__["default"])({}, baseOptions), options.babelLoaderOptions);
|
|
184
|
+
// calculate cacheIdentifier with the merged options
|
|
185
|
+
if (mergedOptions.cacheDirectory && !mergedOptions.cacheIdentifier) mergedOptions.cacheIdentifier = await getCacheIdentifier(mergedOptions);
|
|
186
|
+
return mergedOptions;
|
|
187
|
+
};
|
|
188
|
+
api.modifyBundlerChain({
|
|
189
|
+
order: 'pre',
|
|
190
|
+
handler: async (chain, param)=>{
|
|
191
|
+
let { CHAIN_ID, environment } = param;
|
|
192
|
+
const babelOptions = await getBabelOptions(environment);
|
|
193
|
+
const babelLoader = __WEBPACK_EXTERNAL_MODULE_node_path__["default"].resolve(plugin_dirname, '../compiled/babel-loader/index.js');
|
|
194
|
+
const { include, exclude } = options;
|
|
195
|
+
if (include || exclude) {
|
|
196
|
+
const rule = chain.module.rule(BABEL_JS_RULE) // run babel loader before the builtin SWC loader
|
|
197
|
+
// https://stackoverflow.com/questions/32234329/what-is-the-loader-order-for-webpack
|
|
198
|
+
.after(CHAIN_ID.RULE.JS);
|
|
199
|
+
if (include) for (const condition of castArray(include))rule.include.add(condition);
|
|
200
|
+
if (exclude) for (const condition of castArray(exclude))rule.exclude.add(condition);
|
|
201
|
+
rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).loader(babelLoader).options(babelOptions);
|
|
202
|
+
} else {
|
|
203
|
+
// already set source.include / exclude in plugin-swc
|
|
204
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
205
|
+
rule.test(SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).after(CHAIN_ID.USE.SWC).loader(babelLoader).options(babelOptions);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
});
|
|
257
209
|
}
|
|
258
|
-
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
export {
|
|
263
|
-
PLUGIN_BABEL_NAME,
|
|
264
|
-
getBabelUtils,
|
|
265
|
-
getDefaultBabelOptions,
|
|
266
|
-
modifyBabelLoaderOptions,
|
|
267
|
-
pluginBabel
|
|
210
|
+
};
|
|
268
211
|
};
|
|
212
|
+
export { PLUGIN_BABEL_NAME, getBabelUtils, getDefaultBabelOptions, modifyBabelLoaderOptions, pluginBabel };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NormalizedEnvironmentConfig, RsbuildContext, RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
import type { BabelLoaderOptions, PluginBabelOptions } from './types';
|
|
2
|
+
import type { BabelLoaderOptions, PluginBabelOptions } from './types.js';
|
|
3
3
|
export declare const PLUGIN_BABEL_NAME = "rsbuild:babel";
|
|
4
4
|
/**
|
|
5
5
|
* The `@babel/preset-typescript` default options.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/plugin-babel",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Babel plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,23 +11,22 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./dist
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
15
|
"import": "./dist/index.js",
|
|
16
16
|
"require": "./dist/index.cjs"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"main": "./dist/index.cjs",
|
|
20
|
-
"types": "./dist
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
21
|
"files": [
|
|
22
22
|
"dist",
|
|
23
|
-
"compiled"
|
|
24
|
-
"dist-types"
|
|
23
|
+
"compiled"
|
|
25
24
|
],
|
|
26
25
|
"dependencies": {
|
|
27
|
-
"@babel/core": "^7.25.
|
|
28
|
-
"@babel/plugin-proposal-decorators": "^7.
|
|
29
|
-
"@babel/plugin-transform-class-properties": "^7.25.
|
|
30
|
-
"@babel/preset-typescript": "^7.
|
|
26
|
+
"@babel/core": "^7.25.8",
|
|
27
|
+
"@babel/plugin-proposal-decorators": "^7.25.7",
|
|
28
|
+
"@babel/plugin-transform-class-properties": "^7.25.7",
|
|
29
|
+
"@babel/preset-typescript": "^7.25.7",
|
|
31
30
|
"@types/babel__core": "^7.20.5",
|
|
32
31
|
"deepmerge": "^4.3.1",
|
|
33
32
|
"reduce-configs": "^1.0.0",
|
|
@@ -35,14 +34,14 @@
|
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@types/node": "18.x",
|
|
38
|
-
"babel-loader": "9.1
|
|
37
|
+
"babel-loader": "9.2.1",
|
|
39
38
|
"prebundle": "1.2.2",
|
|
40
|
-
"typescript": "^5.
|
|
41
|
-
"@rsbuild/core": "1.0.
|
|
42
|
-
"@scripts/test-helper": "1.0.1
|
|
39
|
+
"typescript": "^5.6.3",
|
|
40
|
+
"@rsbuild/core": "1.0.14",
|
|
41
|
+
"@scripts/test-helper": "1.0.1"
|
|
43
42
|
},
|
|
44
43
|
"peerDependencies": {
|
|
45
|
-
"@rsbuild/core": "^1.0.1-rc.
|
|
44
|
+
"@rsbuild/core": "1.x || ^1.0.1-rc.0"
|
|
46
45
|
},
|
|
47
46
|
"publishConfig": {
|
|
48
47
|
"access": "public",
|
|
@@ -50,8 +49,8 @@
|
|
|
50
49
|
"registry": "https://registry.npmjs.org/"
|
|
51
50
|
},
|
|
52
51
|
"scripts": {
|
|
53
|
-
"build": "
|
|
54
|
-
"dev": "
|
|
52
|
+
"build": "rslib build",
|
|
53
|
+
"dev": "rslib build --watch",
|
|
55
54
|
"prebundle": "prebundle"
|
|
56
55
|
}
|
|
57
56
|
}
|
package/dist-types/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"//":"This file is for making TypeScript work with moduleResolution node16+.","version":"1.0.0"}
|
|
File without changes
|