@modern-js/uni-builder 2.58.3 → 2.60.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/index.js +14 -0
- package/dist/shared/devServer.js +3 -2
- package/dist/shared/parseCommonConfig.js +16 -13
- package/dist/shared/plugins/antd.d.ts +2 -2
- package/dist/shared/plugins/antd.js +14 -11
- package/dist/shared/plugins/arco.d.ts +2 -2
- package/dist/shared/plugins/arco.js +13 -9
- package/dist/shared/plugins/environmentDefaults.js +8 -1
- package/dist/shared/utils.d.ts +1 -1
- package/dist/shared/utils.js +1 -1
- package/dist/types.d.ts +9 -10
- package/dist/webpack/plugins/babel.js +28 -4
- package/package.json +17 -17
package/dist/rspack/index.js
CHANGED
|
@@ -42,6 +42,20 @@ async function parseConfig(uniBuilderConfig, options) {
|
|
|
42
42
|
if ((_uniBuilderConfig_experiments = uniBuilderConfig.experiments) === null || _uniBuilderConfig_experiments === void 0 ? void 0 : _uniBuilderConfig_experiments.lazyCompilation) {
|
|
43
43
|
rsbuildConfig.dev.lazyCompilation = uniBuilderConfig.experiments.lazyCompilation;
|
|
44
44
|
}
|
|
45
|
+
const { sri } = uniBuilderConfig.security || {};
|
|
46
|
+
if (sri) {
|
|
47
|
+
if (sri === true) {
|
|
48
|
+
rsbuildConfig.security.sri = {
|
|
49
|
+
enable: "auto"
|
|
50
|
+
};
|
|
51
|
+
} else {
|
|
52
|
+
const algorithm = Array.isArray(sri.hashFuncNames) ? sri.hashFuncNames[0] : void 0;
|
|
53
|
+
rsbuildConfig.security.sri = {
|
|
54
|
+
enable: sri.enabled,
|
|
55
|
+
algorithm
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
45
59
|
if ((_uniBuilderConfig_tools = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools === void 0 ? void 0 : _uniBuilderConfig_tools.babel) {
|
|
46
60
|
var _uniBuilderConfig_tools2;
|
|
47
61
|
const { pluginBabel } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-babel")));
|
package/dist/shared/devServer.js
CHANGED
|
@@ -39,7 +39,7 @@ const transformDevSetupMiddlewares = (seuptMiddlewares) => {
|
|
|
39
39
|
};
|
|
40
40
|
const transformToRsbuildServerOptions = (dev, devServer) => {
|
|
41
41
|
var _newDevServerConfig_devMiddleware;
|
|
42
|
-
const { port = 8080, host, https, startUrl, beforeStartUrl, ...devConfig } = dev;
|
|
42
|
+
const { port = 8080, host, https, startUrl, beforeStartUrl, setupMiddlewares, ...devConfig } = dev;
|
|
43
43
|
var _dev_hmr;
|
|
44
44
|
const newDevServerConfig = (0, import_utils.applyOptionsChain)({
|
|
45
45
|
devMiddleware: {
|
|
@@ -52,7 +52,8 @@ const transformToRsbuildServerOptions = (dev, devServer) => {
|
|
|
52
52
|
overlay: false,
|
|
53
53
|
port: "<port>",
|
|
54
54
|
...devConfig.client || {}
|
|
55
|
-
}
|
|
55
|
+
},
|
|
56
|
+
setupMiddlewares
|
|
56
57
|
}, devServer, {}, import_ts_deepmerge.merge);
|
|
57
58
|
const rsbuildDev = {
|
|
58
59
|
writeToDisk: (_newDevServerConfig_devMiddleware = newDevServerConfig.devMiddleware) === null || _newDevServerConfig_devMiddleware === void 0 ? void 0 : _newDevServerConfig_devMiddleware.writeToDisk,
|
|
@@ -80,9 +80,9 @@ const isUseCssSourceMap = (disableSourceMap = {}) => {
|
|
|
80
80
|
};
|
|
81
81
|
async function parseCommonConfig(uniBuilderConfig, options) {
|
|
82
82
|
var _uniBuilderConfig_output, _uniBuilderConfig_tools;
|
|
83
|
-
var _rsbuildConfig_tools, _output_distPath,
|
|
83
|
+
var _rsbuildConfig_tools, _output, _output_distPath, _output1, _extraConfig, _html, _extraConfig1;
|
|
84
84
|
const { frameworkConfigPath } = options;
|
|
85
|
-
const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { disableFilenameHash, enableLatestDecorators, cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, enableAssetManifest, disableSourceMap, convertToRem, disableMinimize, polyfill, dataUriLimit = 1e4, distPath = {}, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, tagsByEntries, appIcon, tags, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, ...sourceConfig } = {}, dev, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {} } = uniBuilderConfig;
|
|
85
|
+
const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { disableFilenameHash, enableLatestDecorators, cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, enableCssModuleTSDeclaration, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, enableAssetManifest, disableSourceMap, convertToRem, disableMinimize, polyfill, dataUriLimit = 1e4, distPath = {}, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, tagsByEntries, appIcon, tags, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, transformImport, ...sourceConfig } = {}, dev, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, less, sass, htmlPlugin, autoprefixer, ...toolsConfig } = {}, environments = {} } = uniBuilderConfig;
|
|
86
86
|
const rsbuildConfig = {
|
|
87
87
|
plugins,
|
|
88
88
|
output: {
|
|
@@ -104,6 +104,7 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
104
104
|
var _lightningcssLoader;
|
|
105
105
|
(_lightningcssLoader = (_rsbuildConfig_tools = rsbuildConfig.tools).lightningcssLoader) !== null && _lightningcssLoader !== void 0 ? _lightningcssLoader : _rsbuildConfig_tools.lightningcssLoader = false;
|
|
106
106
|
const { html = {}, output = {}, source = {} } = rsbuildConfig;
|
|
107
|
+
source.transformImport = transformImport === false ? () => [] : transformImport;
|
|
107
108
|
if (enableLatestDecorators) {
|
|
108
109
|
source.decorators = {
|
|
109
110
|
version: "2022-03"
|
|
@@ -115,18 +116,20 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
115
116
|
version: "legacy"
|
|
116
117
|
};
|
|
117
118
|
}
|
|
119
|
+
var _charset;
|
|
120
|
+
(_charset = (_output = output).charset) !== null && _charset !== void 0 ? _charset : _output.charset = "ascii";
|
|
118
121
|
if (disableMinimize) {
|
|
119
|
-
var
|
|
120
|
-
(
|
|
122
|
+
var _output2;
|
|
123
|
+
(_output2 = output).minify || (_output2.minify = false);
|
|
121
124
|
}
|
|
122
125
|
if (cssModuleLocalIdentName) {
|
|
123
|
-
var
|
|
124
|
-
(
|
|
126
|
+
var _output3;
|
|
127
|
+
(_output3 = output).cssModules || (_output3.cssModules = {});
|
|
125
128
|
output.cssModules.localIdentName = cssModuleLocalIdentName;
|
|
126
129
|
}
|
|
127
130
|
if (isUseCssSourceMap(disableSourceMap)) {
|
|
128
|
-
var
|
|
129
|
-
(
|
|
131
|
+
var _output4;
|
|
132
|
+
(_output4 = output).sourceMap || (_output4.sourceMap = {});
|
|
130
133
|
output.sourceMap.css = true;
|
|
131
134
|
}
|
|
132
135
|
const { server: _server, worker, ...rsbuildDistPath } = distPath;
|
|
@@ -134,10 +137,10 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
134
137
|
var _html1;
|
|
135
138
|
(_html1 = (_output_distPath = output.distPath).html) !== null && _html1 !== void 0 ? _html1 : _output_distPath.html = "html";
|
|
136
139
|
var _polyfill;
|
|
137
|
-
(_polyfill = (
|
|
140
|
+
(_polyfill = (_output1 = output).polyfill) !== null && _polyfill !== void 0 ? _polyfill : _output1.polyfill = "entry";
|
|
138
141
|
if (disableCssModuleExtension) {
|
|
139
|
-
var
|
|
140
|
-
(
|
|
142
|
+
var _output5, _output_cssModules;
|
|
143
|
+
(_output5 = output).cssModules || (_output5.cssModules = {});
|
|
141
144
|
var _auto;
|
|
142
145
|
(_auto = (_output_cssModules = output.cssModules).auto) !== null && _auto !== void 0 ? _auto : _output_cssModules.auto = isLooseCssModules;
|
|
143
146
|
}
|
|
@@ -235,8 +238,8 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
235
238
|
(0, import_emitRouteFile.pluginEmitRouteFile)(),
|
|
236
239
|
(0, import_plugin_toml.pluginToml)(),
|
|
237
240
|
(0, import_plugin_yaml.pluginYaml)(),
|
|
238
|
-
(0, import_antd.pluginAntd)(),
|
|
239
|
-
(0, import_arco.pluginArco)(),
|
|
241
|
+
(0, import_antd.pluginAntd)(transformImport),
|
|
242
|
+
(0, import_arco.pluginArco)(transformImport),
|
|
240
243
|
(0, import_plugin_sass.pluginSass)({
|
|
241
244
|
sassLoaderOptions: sass
|
|
242
245
|
}),
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
export declare const pluginAntd: () => RsbuildPlugin;
|
|
1
|
+
import type { RsbuildPlugin, SourceConfig } from '@rsbuild/core';
|
|
2
|
+
export declare const pluginAntd: (imports?: SourceConfig['transformImport'] | false) => RsbuildPlugin;
|
|
@@ -35,26 +35,29 @@ const getAntdMajorVersion = (appDirectory) => {
|
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
const pluginAntd = () => ({
|
|
38
|
+
const pluginAntd = (imports) => ({
|
|
39
39
|
name: "uni-builder:antd",
|
|
40
40
|
setup(api) {
|
|
41
|
-
api.modifyEnvironmentConfig((rsbuildConfig, { name }) => {
|
|
42
|
-
|
|
43
|
-
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"))) {
|
|
41
|
+
api.modifyEnvironmentConfig((rsbuildConfig, { name, mergeEnvironmentConfig }) => {
|
|
42
|
+
if (imports === false || Array.isArray(imports) && (imports === null || imports === void 0 ? void 0 : imports.some((item) => typeof item === "object" && item.libraryName === "antd"))) {
|
|
44
43
|
return;
|
|
45
44
|
}
|
|
46
45
|
const useServerEnvironment = (0, import_utils.isServerEnvironment)(rsbuildConfig.output.target, name);
|
|
47
46
|
const antdMajorVersion = getAntdMajorVersion(api.context.rootPath);
|
|
48
47
|
if (antdMajorVersion && antdMajorVersion < 5) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
return mergeEnvironmentConfig({
|
|
49
|
+
source: {
|
|
50
|
+
transformImport: [
|
|
51
|
+
{
|
|
52
|
+
libraryName: "antd",
|
|
53
|
+
libraryDirectory: useServerEnvironment ? "lib" : "es",
|
|
54
|
+
style: true
|
|
55
|
+
}
|
|
56
|
+
]
|
|
55
57
|
}
|
|
56
|
-
|
|
58
|
+
}, rsbuildConfig);
|
|
57
59
|
}
|
|
60
|
+
return rsbuildConfig;
|
|
58
61
|
});
|
|
59
62
|
}
|
|
60
63
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
export declare const pluginArco: () => RsbuildPlugin;
|
|
1
|
+
import type { RsbuildPlugin, SourceConfig } from '@rsbuild/core';
|
|
2
|
+
export declare const pluginArco: (imports?: SourceConfig['transformImport'] | false) => RsbuildPlugin;
|
|
@@ -23,33 +23,37 @@ __export(arco_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(arco_exports);
|
|
24
24
|
var import_utils = require("@modern-js/utils");
|
|
25
25
|
var import_utils2 = require("../utils");
|
|
26
|
-
const pluginArco = () => ({
|
|
26
|
+
const pluginArco = (imports) => ({
|
|
27
27
|
name: "uni-builder:arco",
|
|
28
28
|
setup(api) {
|
|
29
29
|
const ARCO_NAME = "@arco-design/web-react";
|
|
30
30
|
const ARCO_ICON = `${ARCO_NAME}/icon`;
|
|
31
|
-
api.modifyEnvironmentConfig((rsbuildConfig, { name }) => {
|
|
32
|
-
|
|
33
|
-
if (transformImport === false || !(0, import_utils.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
|
|
31
|
+
api.modifyEnvironmentConfig((rsbuildConfig, { name, mergeEnvironmentConfig }) => {
|
|
32
|
+
if (imports === false || !(0, import_utils.isPackageInstalled)(ARCO_NAME, api.context.rootPath)) {
|
|
34
33
|
return;
|
|
35
34
|
}
|
|
35
|
+
const defaultImports = [];
|
|
36
36
|
const useServerEnvironment = (0, import_utils2.isServerEnvironment)(rsbuildConfig.output.target, name);
|
|
37
|
-
if (!(
|
|
38
|
-
|
|
37
|
+
if (typeof imports === "function" || !(imports === null || imports === void 0 ? void 0 : imports.some((item) => typeof item === "object" && item.libraryName === ARCO_NAME))) {
|
|
38
|
+
defaultImports.push({
|
|
39
39
|
libraryName: ARCO_NAME,
|
|
40
40
|
libraryDirectory: useServerEnvironment ? "lib" : "es",
|
|
41
41
|
camelToDashComponentName: false,
|
|
42
42
|
style: true
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
-
if (!(
|
|
46
|
-
|
|
45
|
+
if (typeof imports === "function" || !(imports === null || imports === void 0 ? void 0 : imports.some((item) => typeof item === "object" && item.libraryName === ARCO_ICON))) {
|
|
46
|
+
defaultImports.push({
|
|
47
47
|
libraryName: ARCO_ICON,
|
|
48
48
|
libraryDirectory: useServerEnvironment ? "react-icon-cjs" : "react-icon",
|
|
49
49
|
camelToDashComponentName: false
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
return defaultImports.length ? mergeEnvironmentConfig({
|
|
53
|
+
source: {
|
|
54
|
+
transformImport: defaultImports
|
|
55
|
+
}
|
|
56
|
+
}, rsbuildConfig) : rsbuildConfig;
|
|
53
57
|
});
|
|
54
58
|
}
|
|
55
59
|
});
|
|
@@ -35,6 +35,7 @@ const pluginEnvironmentDefaults = (distPath = {}) => ({
|
|
|
35
35
|
(_environments = (_compatConfig = compatConfig).environments) !== null && _environments !== void 0 ? _environments : _compatConfig.environments = {};
|
|
36
36
|
compatConfig.environments[import_utils.SERVICE_WORKER_ENVIRONMENT_NAME] = {
|
|
37
37
|
output: {
|
|
38
|
+
polyfill: "off",
|
|
38
39
|
distPath: {
|
|
39
40
|
root: (0, import_node_path.join)(distPath.root || "dist", distPath.worker || "worker"),
|
|
40
41
|
js: "",
|
|
@@ -73,7 +74,7 @@ const pluginEnvironmentDefaults = (distPath = {}) => ({
|
|
|
73
74
|
const environmentNameOrder = [
|
|
74
75
|
"web",
|
|
75
76
|
"node",
|
|
76
|
-
"
|
|
77
|
+
"workerSSR"
|
|
77
78
|
];
|
|
78
79
|
config.environments = Object.fromEntries(Object.entries(config.environments).sort((a1, a2) => environmentNameOrder.includes(a1[0]) ? environmentNameOrder.indexOf(a1[0]) - environmentNameOrder.indexOf(a2[0]) : 1));
|
|
79
80
|
},
|
|
@@ -84,6 +85,12 @@ const pluginEnvironmentDefaults = (distPath = {}) => ({
|
|
|
84
85
|
var _overrideBrowserslist;
|
|
85
86
|
(_overrideBrowserslist = (_config_output = config.output).overrideBrowserslist) !== null && _overrideBrowserslist !== void 0 ? _overrideBrowserslist : _config_output.overrideBrowserslist = await (0, import_utils.getBrowserslistWithDefault)(api.context.rootPath, config, name === import_utils.SERVICE_WORKER_ENVIRONMENT_NAME ? "node" : config.output.target);
|
|
86
87
|
});
|
|
88
|
+
api.modifyBundlerChain(async (chain, { environment }) => {
|
|
89
|
+
const isServiceWorker = environment.name === import_utils.SERVICE_WORKER_ENVIRONMENT_NAME;
|
|
90
|
+
if (isServiceWorker) {
|
|
91
|
+
chain.output.libraryTarget("commonjs2");
|
|
92
|
+
}
|
|
93
|
+
});
|
|
87
94
|
}
|
|
88
95
|
});
|
|
89
96
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/shared/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NormalizedEnvironmentConfig, RsbuildContext, RsbuildTarget, RspackChain } from '@rsbuild/core';
|
|
2
2
|
export declare const RUNTIME_CHUNK_NAME = "builder-runtime";
|
|
3
|
-
export declare const SERVICE_WORKER_ENVIRONMENT_NAME = "
|
|
3
|
+
export declare const SERVICE_WORKER_ENVIRONMENT_NAME = "workerSSR";
|
|
4
4
|
export declare const JS_REGEX: RegExp;
|
|
5
5
|
export declare const TS_REGEX: RegExp;
|
|
6
6
|
export declare const SCRIPT_REGEX: RegExp;
|
package/dist/shared/utils.js
CHANGED
|
@@ -45,7 +45,7 @@ __export(utils_exports, {
|
|
|
45
45
|
module.exports = __toCommonJS(utils_exports);
|
|
46
46
|
var import_browserslist = __toESM(require("browserslist"));
|
|
47
47
|
const RUNTIME_CHUNK_NAME = "builder-runtime";
|
|
48
|
-
const SERVICE_WORKER_ENVIRONMENT_NAME = "
|
|
48
|
+
const SERVICE_WORKER_ENVIRONMENT_NAME = "workerSSR";
|
|
49
49
|
const JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/;
|
|
50
50
|
const TS_REGEX = /\.(?:ts|mts|cts|tsx)$/;
|
|
51
51
|
const SCRIPT_REGEX = /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/;
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AliasOption } from '@modern-js/utils';
|
|
2
|
-
import type { ConfigChain, ConfigChainWithContext, DevConfig, DistPathConfig, HtmlConfig, HtmlTagDescriptor, OutputConfig, Polyfill, RequestHandler, RsbuildConfig, RsbuildPlugin, RsbuildPluginAPI, RsbuildTarget, Rspack, ScriptInject, ServerConfig } from '@rsbuild/core';
|
|
2
|
+
import type { ConfigChain, ConfigChainWithContext, DevConfig, DistPathConfig, HtmlConfig, HtmlTagDescriptor, OutputConfig, Polyfill, RequestHandler, RsbuildConfig, RsbuildPlugin, RsbuildPluginAPI, RsbuildPlugins, RsbuildTarget, Rspack, ScriptInject, SecurityConfig, ServerConfig, SourceConfig, ToolsConfig } from '@rsbuild/core';
|
|
3
3
|
import type { PluginAssetsRetryOptions } from '@rsbuild/plugin-assets-retry';
|
|
4
4
|
import type { PluginBabelOptions } from '@rsbuild/plugin-babel';
|
|
5
5
|
import type { PluginCheckSyntaxOptions } from '@rsbuild/plugin-check-syntax';
|
|
@@ -19,9 +19,7 @@ import type { PluginTsLoaderOptions } from './webpack/plugins/tsLoader';
|
|
|
19
19
|
type ArrayOrNot<T> = T | T[];
|
|
20
20
|
export type Stats = Omit<Rspack.Stats, '#private' | 'hash' | 'startTime' | 'endTime'>;
|
|
21
21
|
export type RspackConfig = Rspack.Configuration;
|
|
22
|
-
export type MultiStats =
|
|
23
|
-
stats: Stats[];
|
|
24
|
-
};
|
|
22
|
+
export type MultiStats = Rspack.MultiStats;
|
|
25
23
|
/**
|
|
26
24
|
* custom properties
|
|
27
25
|
* e.g. { name: 'viewport' content: 'width=500, initial-scale=1' }
|
|
@@ -151,6 +149,7 @@ export type UniBuilderExtraConfig = {
|
|
|
151
149
|
port?: number;
|
|
152
150
|
};
|
|
153
151
|
source?: {
|
|
152
|
+
transformImport?: SourceConfig['transformImport'] | false;
|
|
154
153
|
alias?: AliasOption;
|
|
155
154
|
/**
|
|
156
155
|
* Define global variables. It can replace expressions like `process.env.FOO` in your code after compile.
|
|
@@ -367,16 +366,16 @@ export type DistPath = DistPathConfig & {
|
|
|
367
366
|
};
|
|
368
367
|
export type UniBuilderConfig = {
|
|
369
368
|
dev?: RsbuildConfig['dev'];
|
|
370
|
-
html?: Omit<
|
|
371
|
-
output?: Omit<
|
|
369
|
+
html?: Omit<HtmlConfig, 'appIcon'>;
|
|
370
|
+
output?: Omit<OutputConfig, 'polyfill' | 'distPath'> & {
|
|
372
371
|
polyfill?: Polyfill | 'ua';
|
|
373
372
|
distPath?: DistPath;
|
|
374
373
|
};
|
|
375
374
|
performance?: RsbuildConfig['performance'];
|
|
376
|
-
security?:
|
|
377
|
-
tools?: Omit<
|
|
378
|
-
source?: Omit<
|
|
379
|
-
plugins?:
|
|
375
|
+
security?: Omit<SecurityConfig, 'sri'>;
|
|
376
|
+
tools?: Omit<ToolsConfig, 'htmlPlugin'>;
|
|
377
|
+
source?: Omit<SourceConfig, 'alias' | 'transformImport'>;
|
|
378
|
+
plugins?: RsbuildPlugins;
|
|
380
379
|
environments?: RsbuildConfig['environments'];
|
|
381
380
|
} & UniBuilderExtraConfig;
|
|
382
381
|
export {};
|
|
@@ -36,6 +36,7 @@ var import_cloneDeep = __toESM(require("lodash/cloneDeep"));
|
|
|
36
36
|
var import_node = require("@modern-js/babel-preset/node");
|
|
37
37
|
var import_web = require("@modern-js/babel-preset/web");
|
|
38
38
|
var import_utils = require("@modern-js/utils");
|
|
39
|
+
var import_core = require("@rsbuild/core");
|
|
39
40
|
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
40
41
|
var import_utils2 = require("../../shared/utils");
|
|
41
42
|
const getPresetReact = (rootPath, isProd) => {
|
|
@@ -101,8 +102,8 @@ const pluginBabel = (options, extraOptions) => ({
|
|
|
101
102
|
},
|
|
102
103
|
pluginDecorators: decoratorConfig
|
|
103
104
|
});
|
|
105
|
+
applyPluginLodash(baseBabelConfig, extraOptions.transformLodash, config2.source.transformImport);
|
|
104
106
|
applyPluginImport(baseBabelConfig, config2.source.transformImport);
|
|
105
|
-
applyPluginLodash(baseBabelConfig, extraOptions.transformLodash);
|
|
106
107
|
(_baseBabelConfig_presets = baseBabelConfig.presets) === null || _baseBabelConfig_presets === void 0 ? void 0 : _baseBabelConfig_presets.push(getPresetReact(api.context.rootPath, isProd));
|
|
107
108
|
if (isProd) {
|
|
108
109
|
var _baseBabelConfig_plugins;
|
|
@@ -155,7 +156,14 @@ const pluginBabel = (options, extraOptions) => ({
|
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
});
|
|
158
|
-
function applyPluginLodash(config, transformLodash) {
|
|
159
|
+
function applyPluginLodash(config, transformLodash, transformImport = []) {
|
|
160
|
+
const finalTransformImport = reduceTransformImportConfig(transformImport);
|
|
161
|
+
const hasImportPluginForLodash = finalTransformImport.some((transformImport2) => {
|
|
162
|
+
return transformImport2.libraryName === "lodash";
|
|
163
|
+
});
|
|
164
|
+
if (hasImportPluginForLodash && transformLodash) {
|
|
165
|
+
import_core.logger.warn("Detected a potential conflict between `source.transformImport` and `performance.transformLodash` for lodash. Please ensure only one of these configurations is used to handle lodash imports. If you want to use `source.transformImport`, set `performance.transformLodash` to `false` in your configuration.");
|
|
166
|
+
}
|
|
159
167
|
if (transformLodash) {
|
|
160
168
|
var _config_plugins;
|
|
161
169
|
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push([
|
|
@@ -164,9 +172,25 @@ function applyPluginLodash(config, transformLodash) {
|
|
|
164
172
|
]);
|
|
165
173
|
}
|
|
166
174
|
}
|
|
175
|
+
const reduceTransformImportConfig = (options) => {
|
|
176
|
+
if (!options) {
|
|
177
|
+
return [];
|
|
178
|
+
}
|
|
179
|
+
let imports = [];
|
|
180
|
+
for (const item of (0, import_utils2.castArray)(options)) {
|
|
181
|
+
if (typeof item === "function") {
|
|
182
|
+
var _item;
|
|
183
|
+
imports = (_item = item(imports)) !== null && _item !== void 0 ? _item : imports;
|
|
184
|
+
} else {
|
|
185
|
+
imports.push(item);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return imports;
|
|
189
|
+
};
|
|
167
190
|
function applyPluginImport(config, pluginImport) {
|
|
168
|
-
|
|
169
|
-
|
|
191
|
+
const finalPluginImport = reduceTransformImportConfig(pluginImport);
|
|
192
|
+
if (finalPluginImport === null || finalPluginImport === void 0 ? void 0 : finalPluginImport.length) {
|
|
193
|
+
for (const item of finalPluginImport) {
|
|
170
194
|
var _config_plugins;
|
|
171
195
|
const name = item.libraryName;
|
|
172
196
|
const option = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/uni-builder",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.60.0",
|
|
4
4
|
"description": "Unified builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,25 +26,25 @@
|
|
|
26
26
|
"@babel/preset-react": "^7.22.15",
|
|
27
27
|
"@babel/types": "^7.24.7",
|
|
28
28
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
|
|
29
|
-
"@rsbuild/core": "1.0.
|
|
30
|
-
"@rsbuild/plugin-assets-retry": "1.0.1
|
|
31
|
-
"@rsbuild/plugin-babel": "1.0.1
|
|
29
|
+
"@rsbuild/core": "1.0.2",
|
|
30
|
+
"@rsbuild/plugin-assets-retry": "1.0.1",
|
|
31
|
+
"@rsbuild/plugin-babel": "1.0.1",
|
|
32
32
|
"@rsbuild/plugin-check-syntax": "1.0.1",
|
|
33
33
|
"@rsbuild/plugin-css-minimizer": "1.0.2",
|
|
34
|
-
"@rsbuild/plugin-less": "1.0.1
|
|
34
|
+
"@rsbuild/plugin-less": "1.0.1",
|
|
35
35
|
"@rsbuild/plugin-pug": "1.0.2",
|
|
36
|
-
"@rsbuild/plugin-react": "1.0.1
|
|
36
|
+
"@rsbuild/plugin-react": "1.0.1",
|
|
37
37
|
"@rsbuild/plugin-rem": "1.0.1",
|
|
38
|
-
"@rsbuild/plugin-sass": "1.0.1
|
|
38
|
+
"@rsbuild/plugin-sass": "1.0.1",
|
|
39
39
|
"@rsbuild/plugin-source-build": "1.0.1",
|
|
40
40
|
"@rsbuild/plugin-styled-components": "1.0.1",
|
|
41
|
-
"@rsbuild/plugin-svgr": "1.0.1
|
|
41
|
+
"@rsbuild/plugin-svgr": "1.0.1",
|
|
42
42
|
"@rsbuild/plugin-toml": "1.0.1",
|
|
43
|
-
"@rsbuild/plugin-type-check": "1.0.1
|
|
43
|
+
"@rsbuild/plugin-type-check": "1.0.1",
|
|
44
44
|
"@rsbuild/plugin-typed-css-modules": "1.0.2",
|
|
45
45
|
"@rsbuild/plugin-yaml": "1.0.2",
|
|
46
|
-
"@rsbuild/webpack": "1.0.
|
|
47
|
-
"@swc/helpers": "0.5.
|
|
46
|
+
"@rsbuild/webpack": "1.0.2",
|
|
47
|
+
"@swc/helpers": "0.5.13",
|
|
48
48
|
"autoprefixer": "10.4.19",
|
|
49
49
|
"babel-loader": "9.1.3",
|
|
50
50
|
"babel-plugin-import": "1.13.5",
|
|
@@ -70,21 +70,21 @@
|
|
|
70
70
|
"terser-webpack-plugin": "5.3.10",
|
|
71
71
|
"ts-deepmerge": "7.0.0",
|
|
72
72
|
"ts-loader": "9.4.4",
|
|
73
|
-
"webpack": "^5.
|
|
73
|
+
"webpack": "^5.94.0",
|
|
74
74
|
"webpack-subresource-integrity": "5.1.0",
|
|
75
|
-
"@modern-js/babel-preset": "2.
|
|
76
|
-
"@modern-js/utils": "2.
|
|
75
|
+
"@modern-js/babel-preset": "2.60.0",
|
|
76
|
+
"@modern-js/utils": "2.60.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@rsbuild/plugin-swc": "1.0.
|
|
79
|
+
"@rsbuild/plugin-webpack-swc": "1.0.2",
|
|
80
80
|
"@types/html-minifier-terser": "^7.0.2",
|
|
81
81
|
"@types/lodash": "^4.14.202",
|
|
82
82
|
"react": "^18.2.0",
|
|
83
83
|
"react-dom": "^18.2.0",
|
|
84
84
|
"terser": "^5.31.1",
|
|
85
85
|
"typescript": "^5.3.0",
|
|
86
|
-
"@scripts/
|
|
87
|
-
"@scripts/
|
|
86
|
+
"@scripts/build": "2.60.0",
|
|
87
|
+
"@scripts/vitest-config": "2.60.0"
|
|
88
88
|
},
|
|
89
89
|
"publishConfig": {
|
|
90
90
|
"access": "public",
|