@modern-js/uni-builder 2.46.1 → 2.47.0
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/rspack/plugins/babel-post.js +11 -9
- package/dist/shared/parseCommonConfig.js +95 -86
- package/dist/shared/plugins/antd.d.ts +2 -0
- package/dist/shared/plugins/antd.js +69 -0
- package/dist/shared/plugins/arco.d.ts +2 -0
- package/dist/shared/plugins/arco.js +61 -0
- package/dist/shared/plugins/fallback.js +5 -2
- package/dist/shared/plugins/postcssLegacy.js +1 -0
- package/dist/shared/plugins/splitChunk.js +5 -4
- package/dist/types.d.ts +17 -0
- package/dist/webpack/index.js +4 -1
- package/dist/webpack/plugins/babel.d.ts +14 -1
- package/dist/webpack/plugins/babel.js +114 -102
- package/dist/webpack/plugins/styledComponents.js +5 -0
- package/dist/webpack/plugins/tsLoader.js +65 -53
- package/package.json +25 -25
|
@@ -35,17 +35,19 @@ var import_isEqual = __toESM(require("lodash/isEqual"));
|
|
|
35
35
|
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
36
36
|
const pluginBabelPost = () => ({
|
|
37
37
|
name: "uni-builder:babel-post",
|
|
38
|
-
pre: [
|
|
39
|
-
"rsbuild:babel"
|
|
40
|
-
],
|
|
41
38
|
setup(api) {
|
|
42
|
-
api.modifyBundlerChain(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
39
|
+
api.modifyBundlerChain({
|
|
40
|
+
handler: async (chain, { CHAIN_ID }) => {
|
|
41
|
+
if (chain.module.rules.get(CHAIN_ID.RULE.JS)) {
|
|
42
|
+
const babelLoaderOptions = chain.module.rule(CHAIN_ID.RULE.JS).use(CHAIN_ID.USE.BABEL).get("options");
|
|
43
|
+
const config = api.getNormalizedConfig();
|
|
44
|
+
if (babelLoaderOptions && (0, import_isEqual.default)((0, import_plugin_babel.getDefaultBabelOptions)(config.source.decorators), babelLoaderOptions)) {
|
|
45
|
+
chain.module.rule(CHAIN_ID.RULE.JS).uses.delete(CHAIN_ID.USE.BABEL);
|
|
46
|
+
}
|
|
47
47
|
}
|
|
48
|
-
}
|
|
48
|
+
},
|
|
49
|
+
// other plugins can modify babel config in modifyBundlerChain 'default order'
|
|
50
|
+
order: "post"
|
|
49
51
|
});
|
|
50
52
|
}
|
|
51
53
|
});
|
|
@@ -45,6 +45,8 @@ var import_plugin_css_minimizer = require("@rsbuild/plugin-css-minimizer");
|
|
|
45
45
|
var import_postcssLegacy = require("./plugins/postcssLegacy");
|
|
46
46
|
var import_devtools = require("./plugins/devtools");
|
|
47
47
|
var import_emitRouteFile = require("./plugins/emitRouteFile");
|
|
48
|
+
var import_antd = require("./plugins/antd");
|
|
49
|
+
var import_arco = require("./plugins/arco");
|
|
48
50
|
const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
|
|
49
51
|
const isLooseCssModules = (path) => {
|
|
50
52
|
if (import_shared.NODE_MODULES_REGEX.test(path)) {
|
|
@@ -92,17 +94,48 @@ async function getBrowserslistWithDefault(path, config, target) {
|
|
|
92
94
|
}
|
|
93
95
|
return DEFAULT_BROWSERSLIST[target];
|
|
94
96
|
}
|
|
97
|
+
const isUseCssSourceMap = (disableSourceMap = {}) => {
|
|
98
|
+
if (typeof disableSourceMap === "boolean") {
|
|
99
|
+
return !disableSourceMap;
|
|
100
|
+
}
|
|
101
|
+
if (disableSourceMap.css === void 0) {
|
|
102
|
+
return process.env.NODE_ENV !== "production";
|
|
103
|
+
}
|
|
104
|
+
return !disableSourceMap.css;
|
|
105
|
+
};
|
|
95
106
|
async function parseCommonConfig(uniBuilderConfig, options) {
|
|
96
|
-
var
|
|
107
|
+
var _newDevServerConfig_devMiddleware, _uniBuilderConfig_output, _uniBuilderConfig_tools;
|
|
97
108
|
var _output, _output_distPath, _output_distPath1, _output1, _extraConfig, _html, _extraConfig1;
|
|
98
109
|
const { cwd, frameworkConfigPath, entry, target } = options;
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
110
|
+
const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { disableFilenameHash, enableLatestDecorators, cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, disableSourceMap, convertToRem, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, ...sourceConfig } = {}, dev: { port, host, https, ...devConfig } = {}, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, ...toolsConfig } = {} } = uniBuilderConfig;
|
|
111
|
+
const rsbuildConfig = {
|
|
112
|
+
plugins,
|
|
113
|
+
output: outputConfig,
|
|
114
|
+
source: {
|
|
115
|
+
alias,
|
|
116
|
+
...sourceConfig
|
|
117
|
+
},
|
|
118
|
+
performance: performanceConfig,
|
|
119
|
+
html: htmlConfig,
|
|
120
|
+
tools: toolsConfig,
|
|
121
|
+
dev: devConfig,
|
|
122
|
+
security: securityConfig
|
|
123
|
+
};
|
|
124
|
+
const { dev = {}, html = {}, output = {}, source = {} } = rsbuildConfig;
|
|
125
|
+
if (enableLatestDecorators) {
|
|
126
|
+
source.decorators = {
|
|
127
|
+
version: "2022-03"
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
if (cssModuleLocalIdentName) {
|
|
102
131
|
var _output2;
|
|
103
132
|
(_output2 = output).cssModules || (_output2.cssModules = {});
|
|
104
|
-
output.cssModules.localIdentName =
|
|
105
|
-
|
|
133
|
+
output.cssModules.localIdentName = cssModuleLocalIdentName;
|
|
134
|
+
}
|
|
135
|
+
if (isUseCssSourceMap(disableSourceMap)) {
|
|
136
|
+
var _output3;
|
|
137
|
+
(_output3 = output).sourceMap || (_output3.sourceMap = {});
|
|
138
|
+
output.sourceMap.css = true;
|
|
106
139
|
}
|
|
107
140
|
var _distPath;
|
|
108
141
|
(_distPath = (_output = output).distPath) !== null && _distPath !== void 0 ? _distPath : _output.distPath = {};
|
|
@@ -112,22 +145,17 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
112
145
|
(_server = (_output_distPath1 = output.distPath).server) !== null && _server !== void 0 ? _server : _output_distPath1.server = "bundles";
|
|
113
146
|
var _polyfill;
|
|
114
147
|
(_polyfill = (_output1 = output).polyfill) !== null && _polyfill !== void 0 ? _polyfill : _output1.polyfill = "entry";
|
|
115
|
-
if (
|
|
116
|
-
var
|
|
117
|
-
(
|
|
148
|
+
if (disableCssModuleExtension) {
|
|
149
|
+
var _output4, _output_cssModules;
|
|
150
|
+
(_output4 = output).cssModules || (_output4.cssModules = {});
|
|
118
151
|
var _auto;
|
|
119
152
|
(_auto = (_output_cssModules = output.cssModules).auto) !== null && _auto !== void 0 ? _auto : _output_cssModules.auto = isLooseCssModules;
|
|
120
|
-
delete output.cssModuleLocalIdentName;
|
|
121
153
|
}
|
|
122
|
-
if (
|
|
123
|
-
|
|
124
|
-
output.inlineScripts = (_uniBuilderConfig_output10 = uniBuilderConfig.output) === null || _uniBuilderConfig_output10 === void 0 ? void 0 : _uniBuilderConfig_output10.enableInlineScripts;
|
|
125
|
-
delete output.enableInlineScripts;
|
|
154
|
+
if (enableInlineScripts) {
|
|
155
|
+
output.inlineScripts = enableInlineScripts;
|
|
126
156
|
}
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
output.injectStyles = (_uniBuilderConfig_output11 = uniBuilderConfig.output) === null || _uniBuilderConfig_output11 === void 0 ? void 0 : _uniBuilderConfig_output11.disableCssExtract;
|
|
130
|
-
delete output.disableCssExtract;
|
|
157
|
+
if (disableCssExtract) {
|
|
158
|
+
output.injectStyles = disableCssExtract;
|
|
131
159
|
}
|
|
132
160
|
const targets = Array.isArray(target) ? target : [
|
|
133
161
|
target || "web"
|
|
@@ -138,40 +166,34 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
138
166
|
overrideBrowserslist[target2] = await getBrowserslistWithDefault(cwd, uniBuilderConfig, target2);
|
|
139
167
|
}
|
|
140
168
|
output.overrideBrowserslist = overrideBrowserslist;
|
|
141
|
-
if (
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
169
|
+
if (enableInlineStyles) {
|
|
170
|
+
output.inlineStyles = enableInlineStyles;
|
|
171
|
+
}
|
|
172
|
+
if (disableFilenameHash !== void 0) {
|
|
173
|
+
output.filenameHash = !disableFilenameHash;
|
|
145
174
|
}
|
|
146
175
|
const extraConfig = {};
|
|
147
176
|
(_extraConfig = extraConfig).html || (_extraConfig.html = {});
|
|
148
|
-
extraConfig.html.outputStructure =
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
extraConfig.html.meta = ({ entryName }) => uniBuilderConfig.html.metaByEntries[entryName];
|
|
152
|
-
delete html.metaByEntries;
|
|
177
|
+
extraConfig.html.outputStructure = disableHtmlFolder ? "flat" : "nested";
|
|
178
|
+
if (metaByEntries) {
|
|
179
|
+
extraConfig.html.meta = ({ entryName }) => metaByEntries[entryName];
|
|
153
180
|
}
|
|
154
181
|
var _title;
|
|
155
182
|
(_title = (_html = html).title) !== null && _title !== void 0 ? _title : _html.title = "";
|
|
156
|
-
if (
|
|
157
|
-
extraConfig.html.title = ({ entryName }) =>
|
|
158
|
-
delete html.titleByEntries;
|
|
183
|
+
if (titleByEntries) {
|
|
184
|
+
extraConfig.html.title = ({ entryName }) => titleByEntries[entryName];
|
|
159
185
|
}
|
|
160
|
-
if (
|
|
161
|
-
extraConfig.html.favicon = ({ entryName }) =>
|
|
162
|
-
delete html.faviconByEntries;
|
|
186
|
+
if (faviconByEntries) {
|
|
187
|
+
extraConfig.html.favicon = ({ entryName }) => faviconByEntries[entryName];
|
|
163
188
|
}
|
|
164
|
-
if (
|
|
165
|
-
extraConfig.html.inject = ({ entryName }) =>
|
|
166
|
-
delete html.injectByEntries;
|
|
189
|
+
if (injectByEntries) {
|
|
190
|
+
extraConfig.html.inject = ({ entryName }) => injectByEntries[entryName];
|
|
167
191
|
}
|
|
168
|
-
if (
|
|
169
|
-
extraConfig.html.template = ({ entryName }) =>
|
|
170
|
-
delete html.templateByEntries;
|
|
192
|
+
if (templateByEntries) {
|
|
193
|
+
extraConfig.html.template = ({ entryName }) => templateByEntries[entryName];
|
|
171
194
|
}
|
|
172
|
-
if (
|
|
173
|
-
extraConfig.html.templateParameters = (_, { entryName }) =>
|
|
174
|
-
delete html.templateParametersByEntries;
|
|
195
|
+
if (templateParametersByEntries) {
|
|
196
|
+
extraConfig.html.templateParameters = (_, { entryName }) => templateParametersByEntries[entryName];
|
|
175
197
|
}
|
|
176
198
|
var _tools;
|
|
177
199
|
(_tools = (_extraConfig1 = extraConfig).tools) !== null && _tools !== void 0 ? _tools : _extraConfig1.tools = {};
|
|
@@ -192,7 +214,7 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
192
214
|
dev.progressBar = true;
|
|
193
215
|
}
|
|
194
216
|
var _dev_hmr;
|
|
195
|
-
const
|
|
217
|
+
const newDevServerConfig = (0, import_shared.mergeChainedOptions)({
|
|
196
218
|
defaults: {
|
|
197
219
|
devMiddleware: {
|
|
198
220
|
writeToDisk: (file) => !file.includes(".hot-update.")
|
|
@@ -203,25 +225,21 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
203
225
|
path: "/webpack-hmr"
|
|
204
226
|
}
|
|
205
227
|
},
|
|
206
|
-
options:
|
|
228
|
+
options: devServer,
|
|
207
229
|
mergeFn: import_shared.deepmerge
|
|
208
230
|
});
|
|
209
|
-
dev.writeToDisk = (
|
|
210
|
-
dev.hmr =
|
|
211
|
-
dev.client =
|
|
212
|
-
dev.liveReload =
|
|
231
|
+
dev.writeToDisk = (_newDevServerConfig_devMiddleware = newDevServerConfig.devMiddleware) === null || _newDevServerConfig_devMiddleware === void 0 ? void 0 : _newDevServerConfig_devMiddleware.writeToDisk;
|
|
232
|
+
dev.hmr = newDevServerConfig.hot;
|
|
233
|
+
dev.client = newDevServerConfig.client;
|
|
234
|
+
dev.liveReload = newDevServerConfig.liveReload;
|
|
213
235
|
const server = (0, import_shared.isProd)() ? {
|
|
214
236
|
publicDir: false
|
|
215
237
|
} : {
|
|
216
238
|
publicDir: false,
|
|
217
|
-
port
|
|
218
|
-
host
|
|
219
|
-
https:
|
|
239
|
+
port,
|
|
240
|
+
host,
|
|
241
|
+
https: https ? https : void 0
|
|
220
242
|
};
|
|
221
|
-
delete tools.devServer;
|
|
222
|
-
delete dev.https;
|
|
223
|
-
delete dev.port;
|
|
224
|
-
delete dev.host;
|
|
225
243
|
rsbuildConfig.server = removeUndefinedKey(server);
|
|
226
244
|
rsbuildConfig.dev = removeUndefinedKey(dev);
|
|
227
245
|
rsbuildConfig.html = html;
|
|
@@ -234,58 +252,50 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
234
252
|
}
|
|
235
253
|
const rsbuildPlugins = [
|
|
236
254
|
(0, import_splitChunk.pluginSplitChunks)(),
|
|
237
|
-
(0, import_globalVars.pluginGlobalVars)(
|
|
255
|
+
(0, import_globalVars.pluginGlobalVars)(globalVars),
|
|
238
256
|
(0, import_devtools.pluginDevtool)({
|
|
239
|
-
disableSourceMap
|
|
257
|
+
disableSourceMap
|
|
240
258
|
}),
|
|
241
259
|
(0, import_emitRouteFile.pluginEmitRouteFile)(),
|
|
242
260
|
(0, import_plugin_toml.pluginToml)(),
|
|
243
|
-
(0, import_plugin_yaml.pluginYaml)()
|
|
261
|
+
(0, import_plugin_yaml.pluginYaml)(),
|
|
262
|
+
(0, import_antd.pluginAntd)(),
|
|
263
|
+
(0, import_arco.pluginArco)()
|
|
244
264
|
];
|
|
245
|
-
|
|
246
|
-
if (checkSyntaxOptions) {
|
|
265
|
+
if (checkSyntax) {
|
|
247
266
|
const { pluginCheckSyntax } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-check-syntax")));
|
|
248
|
-
rsbuildPlugins.push(pluginCheckSyntax(typeof
|
|
267
|
+
rsbuildPlugins.push(pluginCheckSyntax(typeof checkSyntax === "boolean" ? {} : checkSyntax));
|
|
249
268
|
}
|
|
250
|
-
if (!
|
|
251
|
-
var _uniBuilderConfig_tools2;
|
|
269
|
+
if (!disableTsChecker) {
|
|
252
270
|
const { pluginTypeCheck } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-type-check")));
|
|
253
271
|
rsbuildPlugins.push(pluginTypeCheck({
|
|
254
|
-
forkTsCheckerOptions:
|
|
272
|
+
forkTsCheckerOptions: tsChecker
|
|
255
273
|
}));
|
|
256
|
-
delete output.disableTsChecker;
|
|
257
|
-
delete tools.tsChecker;
|
|
258
274
|
}
|
|
259
|
-
if (
|
|
260
|
-
var _uniBuilderConfig_source3;
|
|
275
|
+
if (resolveMainFields) {
|
|
261
276
|
const { pluginMainFields } = await Promise.resolve().then(() => __toESM(require("./plugins/mainFields")));
|
|
262
|
-
rsbuildPlugins.push(pluginMainFields(
|
|
277
|
+
rsbuildPlugins.push(pluginMainFields(resolveMainFields));
|
|
263
278
|
}
|
|
264
|
-
if (
|
|
265
|
-
var _uniBuilderConfig_source4;
|
|
279
|
+
if (resolveExtensionPrefix) {
|
|
266
280
|
const { pluginExtensionPrefix } = await Promise.resolve().then(() => __toESM(require("./plugins/extensionPrefix")));
|
|
267
|
-
rsbuildPlugins.push(pluginExtensionPrefix(
|
|
281
|
+
rsbuildPlugins.push(pluginExtensionPrefix(resolveExtensionPrefix));
|
|
268
282
|
}
|
|
269
|
-
|
|
270
|
-
if (remOptions) {
|
|
283
|
+
if (convertToRem) {
|
|
271
284
|
const { pluginRem } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-rem")));
|
|
272
|
-
rsbuildPlugins.push(pluginRem(typeof
|
|
285
|
+
rsbuildPlugins.push(pluginRem(typeof convertToRem === "boolean" ? {} : convertToRem));
|
|
273
286
|
}
|
|
274
|
-
rsbuildPlugins.push((0, import_runtimeChunk.pluginRuntimeChunk)((
|
|
287
|
+
rsbuildPlugins.push((0, import_runtimeChunk.pluginRuntimeChunk)((_uniBuilderConfig_output = uniBuilderConfig.output) === null || _uniBuilderConfig_output === void 0 ? void 0 : _uniBuilderConfig_output.disableInlineRuntimeChunk));
|
|
275
288
|
const { sourceBuild } = uniBuilderConfig.experiments || {};
|
|
276
289
|
if (sourceBuild) {
|
|
277
290
|
const { pluginSourceBuild } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-source-build")));
|
|
278
291
|
rsbuildPlugins.push(pluginSourceBuild(sourceBuild === true ? {} : sourceBuild));
|
|
279
292
|
}
|
|
280
293
|
rsbuildPlugins.push((0, import_plugin_react.pluginReact)());
|
|
281
|
-
if (!
|
|
282
|
-
var _uniBuilderConfig_output13;
|
|
294
|
+
if (!disableSvgr) {
|
|
283
295
|
const { pluginSvgr } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-svgr")));
|
|
284
296
|
rsbuildPlugins.push(pluginSvgr({
|
|
285
|
-
svgDefaultExport:
|
|
297
|
+
svgDefaultExport: svgDefaultExport || "url"
|
|
286
298
|
}));
|
|
287
|
-
delete output.disableSvgr;
|
|
288
|
-
delete output.svgDefaultExport;
|
|
289
299
|
}
|
|
290
300
|
const pugOptions = (_uniBuilderConfig_tools = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools === void 0 ? void 0 : _uniBuilderConfig_tools.pug;
|
|
291
301
|
if (pugOptions) {
|
|
@@ -294,12 +304,11 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
294
304
|
pugOptions
|
|
295
305
|
}));
|
|
296
306
|
}
|
|
297
|
-
if (
|
|
298
|
-
var _uniBuilderConfig_output14;
|
|
307
|
+
if (assetsRetry) {
|
|
299
308
|
const { pluginAssetsRetry } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-assets-retry")));
|
|
300
|
-
rsbuildPlugins.push(pluginAssetsRetry(
|
|
309
|
+
rsbuildPlugins.push(pluginAssetsRetry(assetsRetry));
|
|
301
310
|
}
|
|
302
|
-
if (
|
|
311
|
+
if (enableAssetFallback) {
|
|
303
312
|
const { pluginFallback } = await Promise.resolve().then(() => __toESM(require("./plugins/fallback")));
|
|
304
313
|
rsbuildPlugins.push(pluginFallback());
|
|
305
314
|
}
|
|
@@ -307,7 +316,7 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
307
316
|
rsbuildPlugins.push((0, import_frameworkConfig.pluginFrameworkConfig)(frameworkConfigPath));
|
|
308
317
|
}
|
|
309
318
|
rsbuildPlugins.push((0, import_plugin_css_minimizer.pluginCssMinimizer)({
|
|
310
|
-
pluginOptions:
|
|
319
|
+
pluginOptions: minifyCss
|
|
311
320
|
}));
|
|
312
321
|
targets.includes("web") && rsbuildPlugins.push((0, import_postcssLegacy.pluginPostcssLegacy)(overrideBrowserslist.web));
|
|
313
322
|
return {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var antd_exports = {};
|
|
20
|
+
__export(antd_exports, {
|
|
21
|
+
pluginAntd: () => pluginAntd
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(antd_exports);
|
|
24
|
+
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
const getAntdMajorVersion = (appDirectory) => {
|
|
26
|
+
try {
|
|
27
|
+
const pkgJsonPath = require.resolve("antd/package.json", {
|
|
28
|
+
paths: [
|
|
29
|
+
appDirectory
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
const { version } = require(pkgJsonPath);
|
|
33
|
+
return Number(version.split(".")[0]);
|
|
34
|
+
} catch (err) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const pluginAntd = () => ({
|
|
39
|
+
name: "uni-builder:antd",
|
|
40
|
+
setup(api) {
|
|
41
|
+
api.modifyRsbuildConfig((rsbuildConfig) => {
|
|
42
|
+
var _rsbuildConfig_source_transformImport;
|
|
43
|
+
var _rsbuildConfig;
|
|
44
|
+
var _source;
|
|
45
|
+
(_source = (_rsbuildConfig = rsbuildConfig).source) !== null && _source !== void 0 ? _source : _rsbuildConfig.source = {};
|
|
46
|
+
if (rsbuildConfig.source.transformImport === false || ((_rsbuildConfig_source_transformImport = rsbuildConfig.source.transformImport) === null || _rsbuildConfig_source_transformImport === void 0 ? void 0 : _rsbuildConfig_source_transformImport.some((item) => item.libraryName === "antd"))) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const antdMajorVersion = getAntdMajorVersion(api.context.rootPath);
|
|
50
|
+
if (antdMajorVersion && antdMajorVersion < 5) {
|
|
51
|
+
var _rsbuildConfig1;
|
|
52
|
+
var _source1;
|
|
53
|
+
(_source1 = (_rsbuildConfig1 = rsbuildConfig).source) !== null && _source1 !== void 0 ? _source1 : _rsbuildConfig1.source = {};
|
|
54
|
+
rsbuildConfig.source.transformImport = [
|
|
55
|
+
...rsbuildConfig.source.transformImport || [],
|
|
56
|
+
{
|
|
57
|
+
libraryName: "antd",
|
|
58
|
+
libraryDirectory: (0, import_shared.isServerTarget)(api.context.targets) ? "lib" : "es",
|
|
59
|
+
style: true
|
|
60
|
+
}
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
pluginAntd
|
|
69
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var arco_exports = {};
|
|
20
|
+
__export(arco_exports, {
|
|
21
|
+
pluginArco: () => pluginArco
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(arco_exports);
|
|
24
|
+
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
var import_utils = require("@modern-js/utils");
|
|
26
|
+
const pluginArco = () => ({
|
|
27
|
+
name: "uni-builder:arco",
|
|
28
|
+
setup(api) {
|
|
29
|
+
const ARCO_NAME = "@arco-design/web-react";
|
|
30
|
+
const ARCO_ICON = `${ARCO_NAME}/icon`;
|
|
31
|
+
api.modifyRsbuildConfig((rsbuildConfig) => {
|
|
32
|
+
var _rsbuildConfig;
|
|
33
|
+
const { transformImport = [] } = rsbuildConfig.source || {};
|
|
34
|
+
if (transformImport === false || !(0, import_utils.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const isUseSSR = (0, import_shared.isServerTarget)(api.context.targets);
|
|
38
|
+
if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some((item) => item.libraryName === ARCO_NAME))) {
|
|
39
|
+
transformImport.push({
|
|
40
|
+
libraryName: ARCO_NAME,
|
|
41
|
+
libraryDirectory: isUseSSR ? "lib" : "es",
|
|
42
|
+
camelToDashComponentName: false,
|
|
43
|
+
style: true
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (!(transformImport === null || transformImport === void 0 ? void 0 : transformImport.some((item) => item.libraryName === ARCO_ICON))) {
|
|
47
|
+
transformImport.push({
|
|
48
|
+
libraryName: ARCO_ICON,
|
|
49
|
+
libraryDirectory: isUseSSR ? "react-icon-cjs" : "react-icon",
|
|
50
|
+
camelToDashComponentName: false
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
(_rsbuildConfig = rsbuildConfig).source || (_rsbuildConfig.source = {});
|
|
54
|
+
rsbuildConfig.source.transformImport = transformImport;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
pluginArco
|
|
61
|
+
});
|
|
@@ -87,14 +87,17 @@ const pluginFallback = () => ({
|
|
|
87
87
|
} else {
|
|
88
88
|
api.modifyRspackConfig((config, { isProd }) => {
|
|
89
89
|
var _config_module;
|
|
90
|
+
var _config, _config1;
|
|
90
91
|
const rsbuildConfig = api.getNormalizedConfig();
|
|
91
92
|
const distDir = (0, import_shared.getDistPath)(rsbuildConfig, "media");
|
|
92
93
|
const filename = (0, import_shared.getFilename)(rsbuildConfig, "media", isProd);
|
|
93
|
-
(
|
|
94
|
+
(_config = config).output || (_config.output = {});
|
|
95
|
+
config.output.assetModuleFilename = (0, import_path.join)(distDir, filename);
|
|
94
96
|
if (!config.module) {
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
|
-
(
|
|
99
|
+
(_config1 = config).module || (_config1.module = {});
|
|
100
|
+
config.module.rules = resourceRuleFallback((_config_module = config.module) === null || _config_module === void 0 ? void 0 : _config_module.rules);
|
|
98
101
|
});
|
|
99
102
|
}
|
|
100
103
|
}
|
|
@@ -31,6 +31,7 @@ const pluginPostcssLegacy = (webBrowserslist) => ({
|
|
|
31
31
|
const enableExtractCSS = (0, import_shared.isUseCssExtract)(config, "web");
|
|
32
32
|
const enableCssMinify = !enableExtractCSS && import_shared.isProd;
|
|
33
33
|
const plugins = [
|
|
34
|
+
require("postcss-flexbugs-fixes"),
|
|
34
35
|
!cssSupport.customProperties && require("postcss-custom-properties"),
|
|
35
36
|
!cssSupport.initial && require("postcss-initial"),
|
|
36
37
|
!cssSupport.pageBreak && require("postcss-page-break"),
|
|
@@ -22,6 +22,7 @@ __export(splitChunk_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(splitChunk_exports);
|
|
24
24
|
var import_shared = require("@rsbuild/shared");
|
|
25
|
+
var import_utils = require("@modern-js/utils");
|
|
25
26
|
const pluginSplitChunks = () => ({
|
|
26
27
|
name: "uni-builder:split-chunks",
|
|
27
28
|
setup(api) {
|
|
@@ -32,22 +33,22 @@ const pluginSplitChunks = () => ({
|
|
|
32
33
|
return;
|
|
33
34
|
}
|
|
34
35
|
const currentConfig = chain.optimization.splitChunks.values();
|
|
35
|
-
if (!(0,
|
|
36
|
+
if (!(0, import_utils.isPlainObject)(currentConfig)) {
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
39
|
const groups = {};
|
|
39
40
|
const { rootPath } = api.context;
|
|
40
|
-
if ((0,
|
|
41
|
+
if ((0, import_utils.isPackageInstalled)("antd", rootPath)) {
|
|
41
42
|
groups.antd = [
|
|
42
43
|
"antd"
|
|
43
44
|
];
|
|
44
45
|
}
|
|
45
|
-
if ((0,
|
|
46
|
+
if ((0, import_utils.isPackageInstalled)("@arco-design/web-react", rootPath)) {
|
|
46
47
|
groups.arco = [
|
|
47
48
|
/@?arco-design/
|
|
48
49
|
];
|
|
49
50
|
}
|
|
50
|
-
if ((0,
|
|
51
|
+
if ((0, import_utils.isPackageInstalled)("@douyinfe/semi-ui", rootPath)) {
|
|
51
52
|
groups.semi = [
|
|
52
53
|
/@(ies|douyinfe)[\\/]semi-.*/
|
|
53
54
|
];
|
package/dist/types.d.ts
CHANGED
|
@@ -122,6 +122,14 @@ export type UniBuilderExtraConfig = {
|
|
|
122
122
|
resolveExtensionPrefix?: string | Partial<Record<RsbuildTarget, string>>;
|
|
123
123
|
};
|
|
124
124
|
output?: {
|
|
125
|
+
/**
|
|
126
|
+
* @deprecated use `output.filenameHash` instead
|
|
127
|
+
*/
|
|
128
|
+
disableFilenameHash?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* @deprecated use `source.decorators` instead
|
|
131
|
+
*/
|
|
132
|
+
enableLatestDecorators?: boolean;
|
|
125
133
|
/**
|
|
126
134
|
* @deprecated use `output.cssModules.localIdentName` instead
|
|
127
135
|
*/
|
|
@@ -212,6 +220,15 @@ export type UniBuilderExtraConfig = {
|
|
|
212
220
|
*/
|
|
213
221
|
templateParametersByEntries?: Record<string, Record<string, unknown>>;
|
|
214
222
|
};
|
|
223
|
+
performance?: {
|
|
224
|
+
/**
|
|
225
|
+
* Specifies whether to modularize the import of [lodash](https://npmjs.com/package/lodash)
|
|
226
|
+
* and remove unused lodash modules to reduce the code size of lodash.
|
|
227
|
+
*
|
|
228
|
+
* Tips: this configuration is not yet supported in rspack
|
|
229
|
+
*/
|
|
230
|
+
transformLodash?: boolean;
|
|
231
|
+
};
|
|
215
232
|
security?: {
|
|
216
233
|
/**
|
|
217
234
|
* Adding an integrity attribute (`integrity`) to sub-resources introduced by HTML allows the browser to
|
package/dist/webpack/index.js
CHANGED
|
@@ -39,10 +39,13 @@ var import_moduleScopes = require("./plugins/moduleScopes");
|
|
|
39
39
|
var import_babel = require("./plugins/babel");
|
|
40
40
|
var import_react = require("./plugins/react");
|
|
41
41
|
async function parseConfig(uniBuilderConfig, options) {
|
|
42
|
-
var _uniBuilderConfig_tools, _uniBuilderConfig_tools1, _uniBuilderConfig_output, _uniBuilderConfig_security, _uniBuilderConfig_experiments, _uniBuilderConfig_tools2;
|
|
42
|
+
var _uniBuilderConfig_tools, _uniBuilderConfig_performance, _uniBuilderConfig_tools1, _uniBuilderConfig_output, _uniBuilderConfig_security, _uniBuilderConfig_experiments, _uniBuilderConfig_tools2;
|
|
43
43
|
const { rsbuildConfig, rsbuildPlugins } = await (0, import_parseCommonConfig.parseCommonConfig)(uniBuilderConfig, options);
|
|
44
|
+
var _uniBuilderConfig_performance_transformLodash;
|
|
44
45
|
rsbuildPlugins.push((0, import_babel.pluginBabel)({
|
|
45
46
|
babelLoaderOptions: (_uniBuilderConfig_tools = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools === void 0 ? void 0 : _uniBuilderConfig_tools.babel
|
|
47
|
+
}, {
|
|
48
|
+
transformLodash: (_uniBuilderConfig_performance_transformLodash = (_uniBuilderConfig_performance = uniBuilderConfig.performance) === null || _uniBuilderConfig_performance === void 0 ? void 0 : _uniBuilderConfig_performance.transformLodash) !== null && _uniBuilderConfig_performance_transformLodash !== void 0 ? _uniBuilderConfig_performance_transformLodash : true
|
|
46
49
|
}));
|
|
47
50
|
rsbuildPlugins.push((0, import_react.pluginReact)());
|
|
48
51
|
if ((_uniBuilderConfig_tools1 = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools1 === void 0 ? void 0 : _uniBuilderConfig_tools1.tsLoader) {
|
|
@@ -1,3 +1,16 @@
|
|
|
1
1
|
import { type RsbuildPlugin } from '@rsbuild/shared';
|
|
2
2
|
import { type PluginBabelOptions } from '@rsbuild/plugin-babel';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Plugin order:
|
|
5
|
+
* rspack mode: rsbuild:swc -> rsbuild:babel
|
|
6
|
+
* webpack mode: uni-builder:babel -> uni-builder:ts-loader -> rsbuild-webpack:swc
|
|
7
|
+
*/
|
|
8
|
+
export declare const getPresetReact: (rootPath: string, isProd: boolean) => (string | {
|
|
9
|
+
development: boolean;
|
|
10
|
+
useBuiltIns: boolean;
|
|
11
|
+
useSpread: boolean;
|
|
12
|
+
runtime: string;
|
|
13
|
+
})[];
|
|
14
|
+
export declare const pluginBabel: (options: PluginBabelOptions, extraOptions: {
|
|
15
|
+
transformLodash: boolean;
|
|
16
|
+
}) => RsbuildPlugin;
|
|
@@ -28,124 +28,135 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var babel_exports = {};
|
|
30
30
|
__export(babel_exports, {
|
|
31
|
+
getPresetReact: () => getPresetReact,
|
|
31
32
|
pluginBabel: () => pluginBabel
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(babel_exports);
|
|
34
35
|
var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
|
|
35
36
|
var import_web = require("@rsbuild/babel-preset/web");
|
|
36
37
|
var import_node = require("@rsbuild/babel-preset/node");
|
|
37
|
-
var
|
|
38
|
+
var import_utils = require("@modern-js/utils");
|
|
38
39
|
var import_shared = require("@rsbuild/shared");
|
|
39
40
|
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
40
|
-
const
|
|
41
|
+
const getPresetReact = (rootPath, isProd) => {
|
|
42
|
+
const isNewJsx = (0, import_utils.isBeyondReact17)(rootPath);
|
|
43
|
+
const presetReactOptions = {
|
|
44
|
+
development: !isProd,
|
|
45
|
+
// Will use the native built-in instead of trying to polyfill
|
|
46
|
+
useBuiltIns: true,
|
|
47
|
+
useSpread: false,
|
|
48
|
+
runtime: isNewJsx ? "automatic" : "classic"
|
|
49
|
+
};
|
|
50
|
+
return [
|
|
51
|
+
require.resolve("@babel/preset-react"),
|
|
52
|
+
presetReactOptions
|
|
53
|
+
];
|
|
54
|
+
};
|
|
55
|
+
const pluginBabel = (options, extraOptions) => ({
|
|
41
56
|
name: "uni-builder:babel",
|
|
57
|
+
post: [
|
|
58
|
+
// will replace the babel rule
|
|
59
|
+
"rsbuild-webpack:swc",
|
|
60
|
+
// will replace the babel rule
|
|
61
|
+
"rsbuild-webpack:esbuild"
|
|
62
|
+
],
|
|
42
63
|
setup(api) {
|
|
43
|
-
api.modifyBundlerChain(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
api.modifyBundlerChain({
|
|
65
|
+
order: "pre",
|
|
66
|
+
handler: async (chain, { CHAIN_ID, target, isProd, isServer, isServiceWorker }) => {
|
|
67
|
+
const config = api.getNormalizedConfig();
|
|
68
|
+
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(api.context.rootPath, config, target);
|
|
69
|
+
const getBabelOptions = (config2) => {
|
|
70
|
+
var _baseBabelConfig_presets;
|
|
71
|
+
const includes2 = [];
|
|
72
|
+
const excludes2 = [];
|
|
73
|
+
const babelUtils = {
|
|
74
|
+
addIncludes(items) {
|
|
75
|
+
if (Array.isArray(items)) {
|
|
76
|
+
includes2.push(...items);
|
|
77
|
+
} else {
|
|
78
|
+
includes2.push(items);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
addExcludes(items) {
|
|
82
|
+
if (Array.isArray(items)) {
|
|
83
|
+
excludes2.push(...items);
|
|
84
|
+
} else {
|
|
85
|
+
excludes2.push(items);
|
|
86
|
+
}
|
|
64
87
|
}
|
|
88
|
+
};
|
|
89
|
+
const decoratorConfig = config2.source.decorators;
|
|
90
|
+
const baseBabelConfig = isServer || isServiceWorker ? (0, import_node.getBabelConfigForNode)({
|
|
91
|
+
presetEnv: {
|
|
92
|
+
targets: [
|
|
93
|
+
"node >= 14"
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
pluginDecorators: decoratorConfig
|
|
97
|
+
}) : (0, import_web.getBabelConfigForWeb)({
|
|
98
|
+
presetEnv: {
|
|
99
|
+
targets: browserslist,
|
|
100
|
+
useBuiltIns: (0, import_plugin_babel.getUseBuiltIns)(config2)
|
|
101
|
+
},
|
|
102
|
+
pluginDecorators: decoratorConfig
|
|
103
|
+
});
|
|
104
|
+
applyPluginImport(baseBabelConfig, config2.source.transformImport);
|
|
105
|
+
applyPluginLodash(baseBabelConfig, extraOptions.transformLodash);
|
|
106
|
+
(_baseBabelConfig_presets = baseBabelConfig.presets) === null || _baseBabelConfig_presets === void 0 ? void 0 : _baseBabelConfig_presets.push(getPresetReact(api.context.rootPath, isProd));
|
|
107
|
+
if (isProd) {
|
|
108
|
+
var _baseBabelConfig_plugins;
|
|
109
|
+
(_baseBabelConfig_plugins = baseBabelConfig.plugins) === null || _baseBabelConfig_plugins === void 0 ? void 0 : _baseBabelConfig_plugins.push([
|
|
110
|
+
require.resolve("babel-plugin-transform-react-remove-prop-types"),
|
|
111
|
+
{
|
|
112
|
+
removeImport: true
|
|
113
|
+
}
|
|
114
|
+
]);
|
|
65
115
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
targets: [
|
|
73
|
-
"node >= 14"
|
|
74
|
-
]
|
|
75
|
-
},
|
|
76
|
-
pluginDecorators: decoratorConfig
|
|
77
|
-
}) : (0, import_web.getBabelConfigForWeb)({
|
|
78
|
-
presetEnv: {
|
|
79
|
-
targets: browserslist,
|
|
80
|
-
useBuiltIns: (0, import_plugin_babel.getUseBuiltIns)(config2)
|
|
81
|
-
},
|
|
82
|
-
pluginDecorators: decoratorConfig
|
|
83
|
-
});
|
|
84
|
-
applyPluginImport(baseBabelConfig, config2.source.transformImport);
|
|
85
|
-
applyPluginLodash(baseBabelConfig, config2.performance.transformLodash);
|
|
86
|
-
const presetReactOptions = {
|
|
87
|
-
development: !isProd,
|
|
88
|
-
// Will use the native built-in instead of trying to polyfill
|
|
89
|
-
useBuiltIns: true,
|
|
90
|
-
useSpread: false,
|
|
91
|
-
runtime: isNewJsx ? "automatic" : "classic"
|
|
92
|
-
};
|
|
93
|
-
(_baseBabelConfig_presets = baseBabelConfig.presets) === null || _baseBabelConfig_presets === void 0 ? void 0 : _baseBabelConfig_presets.push([
|
|
94
|
-
require.resolve("@babel/preset-react"),
|
|
95
|
-
presetReactOptions
|
|
96
|
-
]);
|
|
97
|
-
if (isProd) {
|
|
98
|
-
var _baseBabelConfig_plugins;
|
|
99
|
-
(_baseBabelConfig_plugins = baseBabelConfig.plugins) === null || _baseBabelConfig_plugins === void 0 ? void 0 : _baseBabelConfig_plugins.push([
|
|
100
|
-
require.resolve("babel-plugin-transform-react-remove-prop-types"),
|
|
101
|
-
{
|
|
102
|
-
removeImport: true
|
|
116
|
+
const babelConfig = (0, import_shared.mergeChainedOptions)({
|
|
117
|
+
defaults: baseBabelConfig,
|
|
118
|
+
options: options === null || options === void 0 ? void 0 : options.babelLoaderOptions,
|
|
119
|
+
utils: {
|
|
120
|
+
...(0, import_plugin_babel.getBabelUtils)(baseBabelConfig),
|
|
121
|
+
...babelUtils
|
|
103
122
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
123
|
+
});
|
|
124
|
+
const finalOptions = {
|
|
125
|
+
babelrc: false,
|
|
126
|
+
configFile: false,
|
|
127
|
+
compact: isProd,
|
|
128
|
+
...babelConfig
|
|
129
|
+
};
|
|
130
|
+
if (config2.output.charset === "utf8") {
|
|
131
|
+
finalOptions.generatorOpts = {
|
|
132
|
+
jsescOption: {
|
|
133
|
+
minimal: true
|
|
134
|
+
}
|
|
135
|
+
};
|
|
112
136
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
compact: isProd,
|
|
118
|
-
...babelConfig
|
|
119
|
-
};
|
|
120
|
-
if (config2.output.charset === "utf8") {
|
|
121
|
-
finalOptions.generatorOpts = {
|
|
122
|
-
jsescOption: {
|
|
123
|
-
minimal: true
|
|
124
|
-
}
|
|
137
|
+
return {
|
|
138
|
+
babelOptions: finalOptions,
|
|
139
|
+
includes: includes2,
|
|
140
|
+
excludes: excludes2
|
|
125
141
|
};
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
babelOptions: finalOptions,
|
|
129
|
-
includes: includes2,
|
|
130
|
-
excludes: excludes2
|
|
131
142
|
};
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
143
|
+
const { babelOptions, includes, excludes } = getBabelOptions(config);
|
|
144
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.JS);
|
|
145
|
+
(0, import_shared.applyScriptCondition)({
|
|
146
|
+
rule,
|
|
147
|
+
config,
|
|
148
|
+
context: api.context,
|
|
149
|
+
includes,
|
|
150
|
+
excludes
|
|
151
|
+
});
|
|
152
|
+
rule.test(import_shared.SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(babelOptions);
|
|
153
|
+
chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
|
|
154
|
+
or: [
|
|
155
|
+
"text/javascript",
|
|
156
|
+
"application/javascript"
|
|
157
|
+
]
|
|
158
|
+
}).resolve.set("fullySpecified", false).end().use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options((0, import_cloneDeep.default)(babelOptions));
|
|
159
|
+
}
|
|
149
160
|
});
|
|
150
161
|
}
|
|
151
162
|
});
|
|
@@ -181,5 +192,6 @@ function applyPluginImport(config, pluginImport) {
|
|
|
181
192
|
}
|
|
182
193
|
// Annotate the CommonJS export names for ESM import in node:
|
|
183
194
|
0 && (module.exports = {
|
|
195
|
+
getPresetReact,
|
|
184
196
|
pluginBabel
|
|
185
197
|
});
|
|
@@ -31,9 +31,14 @@ __export(styledComponents_exports, {
|
|
|
31
31
|
pluginStyledComponents: () => pluginStyledComponents
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(styledComponents_exports);
|
|
34
|
+
var import_core = require("@rsbuild/core");
|
|
34
35
|
var import_shared = require("@rsbuild/shared");
|
|
35
36
|
const pluginStyledComponents = (userConfig = {}) => ({
|
|
36
37
|
name: "uni-builder:styled-components",
|
|
38
|
+
pre: [
|
|
39
|
+
import_core.PLUGIN_SWC_NAME,
|
|
40
|
+
"uni-builder:babel"
|
|
41
|
+
],
|
|
37
42
|
setup(api) {
|
|
38
43
|
api.modifyBundlerChain(async (chain, { CHAIN_ID, isProd }) => {
|
|
39
44
|
const isSSR = (0, import_shared.isServerTarget)(api.context.targets);
|
|
@@ -34,66 +34,78 @@ module.exports = __toCommonJS(tsLoader_exports);
|
|
|
34
34
|
var import_shared = require("@rsbuild/shared");
|
|
35
35
|
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
36
36
|
var import_web = require("@rsbuild/babel-preset/web");
|
|
37
|
+
var import_babel = require("./babel");
|
|
37
38
|
const pluginTsLoader = (options, babelOptions) => {
|
|
38
39
|
return {
|
|
39
40
|
name: "uni-builder:ts-loader",
|
|
40
41
|
pre: [
|
|
41
42
|
"uni-builder:babel"
|
|
42
43
|
],
|
|
43
|
-
post: [
|
|
44
|
-
"uni-builder:react"
|
|
45
|
-
],
|
|
46
44
|
setup(api) {
|
|
47
|
-
api.modifyBundlerChain(
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
45
|
+
api.modifyBundlerChain({
|
|
46
|
+
order: "pre",
|
|
47
|
+
handler: async (chain, { isProd, target, CHAIN_ID }) => {
|
|
48
|
+
var _baseBabelConfig_presets;
|
|
49
|
+
const config = api.getNormalizedConfig();
|
|
50
|
+
const { rootPath } = api.context;
|
|
51
|
+
const browserslist = await (0, import_shared.getBrowserslistWithDefault)(rootPath, config, target);
|
|
52
|
+
const baseBabelConfig = (0, import_web.getBabelConfigForWeb)({
|
|
53
|
+
presetEnv: {
|
|
54
|
+
targets: browserslist,
|
|
55
|
+
useBuiltIns: (0, import_plugin_babel.getUseBuiltIns)(config)
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
(_baseBabelConfig_presets = baseBabelConfig.presets) === null || _baseBabelConfig_presets === void 0 ? void 0 : _baseBabelConfig_presets.push((0, import_babel.getPresetReact)(api.context.rootPath, isProd));
|
|
59
|
+
const babelUtils = (0, import_plugin_babel.getBabelUtils)(baseBabelConfig);
|
|
60
|
+
const babelLoaderOptions = (0, import_shared.mergeChainedOptions)({
|
|
61
|
+
defaults: baseBabelConfig,
|
|
62
|
+
options: babelOptions,
|
|
63
|
+
utils: babelUtils
|
|
64
|
+
});
|
|
65
|
+
const includes = [];
|
|
66
|
+
const excludes = [];
|
|
67
|
+
const tsLoaderUtils = {
|
|
68
|
+
addIncludes(items) {
|
|
69
|
+
includes.push(...(0, import_shared.castArray)(items));
|
|
70
|
+
},
|
|
71
|
+
addExcludes(items) {
|
|
72
|
+
excludes.push(...(0, import_shared.castArray)(items));
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
const tsLoaderDefaultOptions = {
|
|
76
|
+
compilerOptions: {
|
|
77
|
+
target: "esnext",
|
|
78
|
+
module: "esnext"
|
|
79
|
+
},
|
|
80
|
+
transpileOnly: true,
|
|
81
|
+
allowTsInNodeModules: true
|
|
82
|
+
};
|
|
83
|
+
const tsLoaderOptions = (0, import_shared.mergeChainedOptions)({
|
|
84
|
+
defaults: tsLoaderDefaultOptions,
|
|
85
|
+
// @ts-expect-error ts-loader has incorrect types for compilerOptions
|
|
86
|
+
options,
|
|
87
|
+
utils: tsLoaderUtils
|
|
88
|
+
});
|
|
89
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.TS);
|
|
90
|
+
(0, import_shared.applyScriptCondition)({
|
|
91
|
+
rule,
|
|
92
|
+
config,
|
|
93
|
+
context: api.context,
|
|
94
|
+
includes,
|
|
95
|
+
excludes
|
|
96
|
+
});
|
|
97
|
+
chain.module.rule(CHAIN_ID.RULE.JS).test(import_shared.JS_REGEX);
|
|
98
|
+
rule.test(import_shared.TS_REGEX).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options({
|
|
99
|
+
...babelLoaderOptions,
|
|
100
|
+
// fix repeatedly insert babel plugin in some boundary cases
|
|
101
|
+
plugins: [
|
|
102
|
+
...babelLoaderOptions.plugins || []
|
|
103
|
+
],
|
|
104
|
+
presets: [
|
|
105
|
+
...babelLoaderOptions.presets || []
|
|
106
|
+
]
|
|
107
|
+
}).end().use(CHAIN_ID.USE.TS).loader(require.resolve("ts-loader")).options(tsLoaderOptions);
|
|
108
|
+
}
|
|
97
109
|
});
|
|
98
110
|
}
|
|
99
111
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/uni-builder",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.47.0",
|
|
4
4
|
"description": "Unified builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,23 +26,23 @@
|
|
|
26
26
|
"@babel/preset-react": "^7.22.15",
|
|
27
27
|
"@babel/types": "^7.23.0",
|
|
28
28
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
|
|
29
|
-
"@rsbuild/babel-preset": "0.
|
|
30
|
-
"@rsbuild/core": "0.
|
|
31
|
-
"@rsbuild/plugin-assets-retry": "0.
|
|
32
|
-
"@rsbuild/plugin-babel": "0.
|
|
33
|
-
"@rsbuild/plugin-check-syntax": "0.
|
|
34
|
-
"@rsbuild/plugin-css-minimizer": "0.
|
|
35
|
-
"@rsbuild/plugin-pug": "0.
|
|
36
|
-
"@rsbuild/plugin-react": "0.
|
|
37
|
-
"@rsbuild/plugin-rem": "0.
|
|
38
|
-
"@rsbuild/plugin-source-build": "0.
|
|
39
|
-
"@rsbuild/plugin-styled-components": "0.
|
|
40
|
-
"@rsbuild/plugin-svgr": "0.
|
|
41
|
-
"@rsbuild/plugin-type-check": "0.
|
|
42
|
-
"@rsbuild/plugin-toml": "0.
|
|
43
|
-
"@rsbuild/plugin-yaml": "0.
|
|
44
|
-
"@rsbuild/shared": "0.
|
|
45
|
-
"@rsbuild/webpack": "0.
|
|
29
|
+
"@rsbuild/babel-preset": "0.4.4",
|
|
30
|
+
"@rsbuild/core": "0.4.4",
|
|
31
|
+
"@rsbuild/plugin-assets-retry": "0.4.4",
|
|
32
|
+
"@rsbuild/plugin-babel": "0.4.4",
|
|
33
|
+
"@rsbuild/plugin-check-syntax": "0.4.4",
|
|
34
|
+
"@rsbuild/plugin-css-minimizer": "0.4.4",
|
|
35
|
+
"@rsbuild/plugin-pug": "0.4.4",
|
|
36
|
+
"@rsbuild/plugin-react": "0.4.4",
|
|
37
|
+
"@rsbuild/plugin-rem": "0.4.4",
|
|
38
|
+
"@rsbuild/plugin-source-build": "0.4.4",
|
|
39
|
+
"@rsbuild/plugin-styled-components": "0.4.4",
|
|
40
|
+
"@rsbuild/plugin-svgr": "0.4.4",
|
|
41
|
+
"@rsbuild/plugin-type-check": "0.4.4",
|
|
42
|
+
"@rsbuild/plugin-toml": "0.4.4",
|
|
43
|
+
"@rsbuild/plugin-yaml": "0.4.4",
|
|
44
|
+
"@rsbuild/shared": "0.4.4",
|
|
45
|
+
"@rsbuild/webpack": "0.4.4",
|
|
46
46
|
"@swc/helpers": "0.5.3",
|
|
47
47
|
"babel-loader": "9.1.3",
|
|
48
48
|
"babel-plugin-import": "1.13.5",
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"html-webpack-plugin": "5.5.3",
|
|
54
54
|
"lodash": "^4.17.21",
|
|
55
55
|
"postcss-custom-properties": "13.1.5",
|
|
56
|
+
"postcss-flexbugs-fixes": "5.0.2",
|
|
56
57
|
"postcss-font-variant": "5.0.0",
|
|
57
58
|
"postcss-initial": "4.0.1",
|
|
58
59
|
"postcss-media-minmax": "5.0.0",
|
|
@@ -64,19 +65,18 @@
|
|
|
64
65
|
"webpack": "^5.89.0",
|
|
65
66
|
"webpack-manifest-plugin": "5.0.0",
|
|
66
67
|
"webpack-subresource-integrity": "5.1.0",
|
|
67
|
-
"@modern-js/utils": "2.
|
|
68
|
-
"@modern-js/server": "2.
|
|
69
|
-
"@modern-js/prod-server": "2.
|
|
68
|
+
"@modern-js/utils": "2.47.0",
|
|
69
|
+
"@modern-js/server": "2.47.0",
|
|
70
|
+
"@modern-js/prod-server": "2.47.0"
|
|
70
71
|
},
|
|
71
72
|
"devDependencies": {
|
|
72
|
-
"@rsbuild/plugin-swc": "0.
|
|
73
|
+
"@rsbuild/plugin-swc": "0.4.4",
|
|
73
74
|
"@types/lodash": "^4.14.202",
|
|
74
75
|
"react": "^18.2.0",
|
|
75
76
|
"react-dom": "^18.2.0",
|
|
76
77
|
"typescript": "^5.3.0",
|
|
77
|
-
"@
|
|
78
|
-
"@scripts/
|
|
79
|
-
"@scripts/vitest-config": "2.46.1"
|
|
78
|
+
"@scripts/build": "2.47.0",
|
|
79
|
+
"@scripts/vitest-config": "2.47.0"
|
|
80
80
|
},
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public",
|