@modern-js/uni-builder 2.45.0 → 2.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/rspack/index.js +2 -1
- package/dist/rspack/plugins/babel-post.d.ts +5 -0
- package/dist/rspack/plugins/babel-post.js +55 -0
- package/dist/shared/devServer.js +9 -11
- package/dist/shared/parseCommonConfig.js +63 -20
- package/dist/shared/plugins/splitChunk.js +2 -0
- package/dist/types.d.ts +10 -5
- package/dist/webpack/plugins/babel.js +5 -0
- package/package.json +25 -23
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
|
5
5
|
export { HtmlWebpackPlugin };
|
|
6
6
|
export type { CreateUniBuilderOptions, UniBuilderInstance, UniBuilderWebpackInstance, };
|
|
7
7
|
export type { BundlerChain, RsbuildPlugin, ChainedConfig, CopyPluginOptions, ChainIdentifier, NormalizedConfig, RspackConfig, CacheGroup, } from '@rsbuild/shared';
|
|
8
|
-
export type { UniBuilderConfig } from './types';
|
|
8
|
+
export type { UniBuilderConfig, UniBuilderPlugin } from './types';
|
|
9
9
|
export type { StartDevServerOptions } from './shared/devServer';
|
|
10
10
|
export declare function createUniBuilder(options: CreateUniBuilderOptions): Promise<UniBuilderInstance>;
|
|
11
11
|
export { logger, type Rspack, type RsbuildContext, type RsbuildConfig, } from '@rsbuild/core';
|
package/dist/rspack/index.js
CHANGED
|
@@ -45,9 +45,10 @@ async function parseConfig(uniBuilderConfig, options) {
|
|
|
45
45
|
if ((_uniBuilderConfig_tools = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools === void 0 ? void 0 : _uniBuilderConfig_tools.babel) {
|
|
46
46
|
var _uniBuilderConfig_tools2;
|
|
47
47
|
const { pluginBabel } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-babel")));
|
|
48
|
+
const { pluginBabelPost } = await Promise.resolve().then(() => __toESM(require("./plugins/babel-post")));
|
|
48
49
|
rsbuildPlugins.push(pluginBabel({
|
|
49
50
|
babelLoaderOptions: (_uniBuilderConfig_tools2 = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools2 === void 0 ? void 0 : _uniBuilderConfig_tools2.babel
|
|
50
|
-
}));
|
|
51
|
+
}), pluginBabelPost());
|
|
51
52
|
}
|
|
52
53
|
if (((_uniBuilderConfig_tools1 = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools1 === void 0 ? void 0 : _uniBuilderConfig_tools1.styledComponents) !== false) {
|
|
53
54
|
var _uniBuilderConfig_tools3;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var babel_post_exports = {};
|
|
30
|
+
__export(babel_post_exports, {
|
|
31
|
+
pluginBabelPost: () => pluginBabelPost
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(babel_post_exports);
|
|
34
|
+
var import_isEqual = __toESM(require("lodash/isEqual"));
|
|
35
|
+
var import_plugin_babel = require("@rsbuild/plugin-babel");
|
|
36
|
+
const pluginBabelPost = () => ({
|
|
37
|
+
name: "uni-builder:babel-post",
|
|
38
|
+
pre: [
|
|
39
|
+
"rsbuild:babel"
|
|
40
|
+
],
|
|
41
|
+
setup(api) {
|
|
42
|
+
api.modifyBundlerChain(async (chain, { CHAIN_ID }) => {
|
|
43
|
+
if (chain.module.rules.get(CHAIN_ID.RULE.JS)) {
|
|
44
|
+
const babelLoaderOptions = chain.module.rule(CHAIN_ID.RULE.JS).use(CHAIN_ID.USE.BABEL).get("options");
|
|
45
|
+
if (babelLoaderOptions && (0, import_isEqual.default)((0, import_plugin_babel.getDefaultBabelOptions)(), babelLoaderOptions)) {
|
|
46
|
+
chain.module.rule(CHAIN_ID.RULE.JS).uses.delete(CHAIN_ID.USE.BABEL);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
53
|
+
0 && (module.exports = {
|
|
54
|
+
pluginBabelPost
|
|
55
|
+
});
|
package/dist/shared/devServer.js
CHANGED
|
@@ -53,18 +53,12 @@ const getServerOptions = (builderConfig) => {
|
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
55
|
const getDevServerOptions = async ({ builderConfig, serverOptions, port }) => {
|
|
56
|
-
var _builderConfig_dev,
|
|
57
|
-
var _builderConfig_dev_hmr, _builderConfig_dev_hmr1;
|
|
56
|
+
var _builderConfig_dev, _builderConfig_tools;
|
|
58
57
|
const defaultDevConfig = (0, import_shared.deepmerge)(
|
|
59
58
|
{
|
|
60
|
-
hot: (_builderConfig_dev_hmr = (_builderConfig_dev = builderConfig.dev) === null || _builderConfig_dev === void 0 ? void 0 : _builderConfig_dev.hmr) !== null && _builderConfig_dev_hmr !== void 0 ? _builderConfig_dev_hmr : true,
|
|
61
59
|
watch: true,
|
|
62
|
-
client: {
|
|
63
|
-
port: port.toString()
|
|
64
|
-
},
|
|
65
60
|
port,
|
|
66
|
-
|
|
67
|
-
https: (_builderConfig_dev2 = builderConfig.dev) === null || _builderConfig_dev2 === void 0 ? void 0 : _builderConfig_dev2.https
|
|
61
|
+
https: (_builderConfig_dev = builderConfig.dev) === null || _builderConfig_dev === void 0 ? void 0 : _builderConfig_dev.https
|
|
68
62
|
},
|
|
69
63
|
// merge devServerOptions from serverOptions
|
|
70
64
|
serverOptions.dev || {}
|
|
@@ -107,7 +101,11 @@ async function startDevServer(rsbuild, options = {}, builderConfig) {
|
|
|
107
101
|
(0, import_shared.debug)("create dev server done");
|
|
108
102
|
await rsbuildServer.beforeStart();
|
|
109
103
|
const protocol = devConfig.https ? "https" : "http";
|
|
110
|
-
const urls = (0, import_shared.getAddressUrls)(
|
|
104
|
+
const urls = (0, import_shared.getAddressUrls)({
|
|
105
|
+
protocol,
|
|
106
|
+
port,
|
|
107
|
+
host
|
|
108
|
+
});
|
|
111
109
|
(0, import_shared.debug)("listen dev server");
|
|
112
110
|
await server.init();
|
|
113
111
|
return new Promise((resolve) => {
|
|
@@ -123,8 +121,8 @@ async function startDevServer(rsbuild, options = {}, builderConfig) {
|
|
|
123
121
|
port,
|
|
124
122
|
routes: [
|
|
125
123
|
{
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
pathname: "/",
|
|
125
|
+
entryName: "index"
|
|
128
126
|
}
|
|
129
127
|
]
|
|
130
128
|
});
|
|
@@ -34,6 +34,8 @@ __export(parseCommonConfig_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(parseCommonConfig_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
36
|
var import_core = require("@rsbuild/core");
|
|
37
|
+
var import_plugin_toml = require("@rsbuild/plugin-toml");
|
|
38
|
+
var import_plugin_yaml = require("@rsbuild/plugin-yaml");
|
|
37
39
|
var import_plugin_react = require("@rsbuild/plugin-react");
|
|
38
40
|
var import_globalVars = require("./plugins/globalVars");
|
|
39
41
|
var import_runtimeChunk = require("./plugins/runtimeChunk");
|
|
@@ -91,8 +93,8 @@ async function getBrowserslistWithDefault(path, config, target) {
|
|
|
91
93
|
return DEFAULT_BROWSERSLIST[target];
|
|
92
94
|
}
|
|
93
95
|
async function parseCommonConfig(uniBuilderConfig, options) {
|
|
94
|
-
var _uniBuilderConfig_output, _uniBuilderConfig_output1, _uniBuilderConfig_output2, _uniBuilderConfig_html, _uniBuilderConfig_html1, _uniBuilderConfig_html2, _uniBuilderConfig_html3, _uniBuilderConfig_html4, _uniBuilderConfig_html5,
|
|
95
|
-
var _output, _output_distPath, _output1, _extraConfig, _html;
|
|
96
|
+
var _uniBuilderConfig_output, _uniBuilderConfig_output1, _uniBuilderConfig_output2, _uniBuilderConfig_html, _uniBuilderConfig_html1, _uniBuilderConfig_html2, _uniBuilderConfig_html3, _uniBuilderConfig_html4, _uniBuilderConfig_html5, _devServer_devMiddleware, _uniBuilderConfig_source, _uniBuilderConfig_output3, _uniBuilderConfig_security, _uniBuilderConfig_output4, _uniBuilderConfig_source1, _uniBuilderConfig_source2, _uniBuilderConfig_output5, _uniBuilderConfig_output6, _uniBuilderConfig_output7, _uniBuilderConfig_tools, _uniBuilderConfig_output8, _uniBuilderConfig_output9, _uniBuilderConfig_tools1;
|
|
97
|
+
var _output, _output_distPath, _output_distPath1, _output1, _extraConfig, _html, _extraConfig1;
|
|
96
98
|
const { cwd, frameworkConfigPath, entry, target } = options;
|
|
97
99
|
const rsbuildConfig = (0, import_shared.deepmerge)({}, uniBuilderConfig);
|
|
98
100
|
const { dev = {}, html = {}, output = {}, tools = {} } = rsbuildConfig;
|
|
@@ -106,6 +108,8 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
106
108
|
(_distPath = (_output = output).distPath) !== null && _distPath !== void 0 ? _distPath : _output.distPath = {};
|
|
107
109
|
var _html1;
|
|
108
110
|
(_html1 = (_output_distPath = output.distPath).html) !== null && _html1 !== void 0 ? _html1 : _output_distPath.html = "html";
|
|
111
|
+
var _server;
|
|
112
|
+
(_server = (_output_distPath1 = output.distPath).server) !== null && _server !== void 0 ? _server : _output_distPath1.server = "bundles";
|
|
109
113
|
var _polyfill;
|
|
110
114
|
(_polyfill = (_output1 = output).polyfill) !== null && _polyfill !== void 0 ? _polyfill : _output1.polyfill = "entry";
|
|
111
115
|
if (output.disableCssModuleExtension) {
|
|
@@ -169,14 +173,50 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
169
173
|
extraConfig.html.templateParameters = (_, { entryName }) => uniBuilderConfig.html.templateParametersByEntries[entryName];
|
|
170
174
|
delete html.templateParametersByEntries;
|
|
171
175
|
}
|
|
176
|
+
var _tools;
|
|
177
|
+
(_tools = (_extraConfig1 = extraConfig).tools) !== null && _tools !== void 0 ? _tools : _extraConfig1.tools = {};
|
|
178
|
+
extraConfig.tools.htmlPlugin = (config) => {
|
|
179
|
+
if (typeof config.templateParameters === "function") {
|
|
180
|
+
const originFn = config.templateParameters;
|
|
181
|
+
config.templateParameters = (...args) => {
|
|
182
|
+
const res = originFn(...args);
|
|
183
|
+
return {
|
|
184
|
+
title: config.title,
|
|
185
|
+
meta: void 0,
|
|
186
|
+
...res
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
};
|
|
172
191
|
if (dev.progressBar === void 0) {
|
|
173
192
|
dev.progressBar = true;
|
|
174
193
|
}
|
|
175
|
-
var
|
|
176
|
-
|
|
177
|
-
|
|
194
|
+
var _dev_hmr;
|
|
195
|
+
const devServer = (0, import_shared.mergeChainedOptions)({
|
|
196
|
+
defaults: {
|
|
197
|
+
devMiddleware: {
|
|
198
|
+
writeToDisk: (file) => !file.includes(".hot-update.")
|
|
199
|
+
},
|
|
200
|
+
hot: (_dev_hmr = dev === null || dev === void 0 ? void 0 : dev.hmr) !== null && _dev_hmr !== void 0 ? _dev_hmr : true,
|
|
201
|
+
liveReload: true,
|
|
202
|
+
client: {
|
|
203
|
+
path: "/webpack-hmr"
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
options: tools.devServer,
|
|
207
|
+
mergeFn: import_shared.deepmerge
|
|
208
|
+
});
|
|
209
|
+
dev.writeToDisk = (_devServer_devMiddleware = devServer.devMiddleware) === null || _devServer_devMiddleware === void 0 ? void 0 : _devServer_devMiddleware.writeToDisk;
|
|
210
|
+
dev.hmr = devServer.hot;
|
|
211
|
+
dev.client = devServer.client;
|
|
212
|
+
dev.liveReload = devServer.liveReload;
|
|
213
|
+
const server = (0, import_shared.isProd)() ? {
|
|
214
|
+
publicDir: false
|
|
215
|
+
} : {
|
|
216
|
+
publicDir: false,
|
|
178
217
|
port: dev.port,
|
|
179
|
-
host: dev.host
|
|
218
|
+
host: dev.host,
|
|
219
|
+
https: dev.https ? dev.https : void 0
|
|
180
220
|
};
|
|
181
221
|
delete tools.devServer;
|
|
182
222
|
delete dev.https;
|
|
@@ -198,7 +238,9 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
198
238
|
(0, import_devtools.pluginDevtool)({
|
|
199
239
|
disableSourceMap: (_uniBuilderConfig_output3 = uniBuilderConfig.output) === null || _uniBuilderConfig_output3 === void 0 ? void 0 : _uniBuilderConfig_output3.disableSourceMap
|
|
200
240
|
}),
|
|
201
|
-
(0, import_emitRouteFile.pluginEmitRouteFile)()
|
|
241
|
+
(0, import_emitRouteFile.pluginEmitRouteFile)(),
|
|
242
|
+
(0, import_plugin_toml.pluginToml)(),
|
|
243
|
+
(0, import_plugin_yaml.pluginYaml)()
|
|
202
244
|
];
|
|
203
245
|
const checkSyntaxOptions = (_uniBuilderConfig_security = uniBuilderConfig.security) === null || _uniBuilderConfig_security === void 0 ? void 0 : _uniBuilderConfig_security.checkSyntax;
|
|
204
246
|
if (checkSyntaxOptions) {
|
|
@@ -214,15 +256,6 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
214
256
|
delete output.disableTsChecker;
|
|
215
257
|
delete tools.tsChecker;
|
|
216
258
|
}
|
|
217
|
-
if (!((_uniBuilderConfig_output5 = uniBuilderConfig.output) === null || _uniBuilderConfig_output5 === void 0 ? void 0 : _uniBuilderConfig_output5.disableSvgr)) {
|
|
218
|
-
var _uniBuilderConfig_output13;
|
|
219
|
-
const { pluginSvgr } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-svgr")));
|
|
220
|
-
rsbuildPlugins.push(pluginSvgr({
|
|
221
|
-
svgDefaultExport: ((_uniBuilderConfig_output13 = uniBuilderConfig.output) === null || _uniBuilderConfig_output13 === void 0 ? void 0 : _uniBuilderConfig_output13.svgDefaultExport) || "url"
|
|
222
|
-
}));
|
|
223
|
-
delete output.disableSvgr;
|
|
224
|
-
delete output.svgDefaultExport;
|
|
225
|
-
}
|
|
226
259
|
if ((_uniBuilderConfig_source1 = uniBuilderConfig.source) === null || _uniBuilderConfig_source1 === void 0 ? void 0 : _uniBuilderConfig_source1.resolveMainFields) {
|
|
227
260
|
var _uniBuilderConfig_source3;
|
|
228
261
|
const { pluginMainFields } = await Promise.resolve().then(() => __toESM(require("./plugins/mainFields")));
|
|
@@ -233,17 +266,27 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
233
266
|
const { pluginExtensionPrefix } = await Promise.resolve().then(() => __toESM(require("./plugins/extensionPrefix")));
|
|
234
267
|
rsbuildPlugins.push(pluginExtensionPrefix((_uniBuilderConfig_source4 = uniBuilderConfig.source) === null || _uniBuilderConfig_source4 === void 0 ? void 0 : _uniBuilderConfig_source4.resolveExtensionPrefix));
|
|
235
268
|
}
|
|
236
|
-
const remOptions = (
|
|
269
|
+
const remOptions = (_uniBuilderConfig_output5 = uniBuilderConfig.output) === null || _uniBuilderConfig_output5 === void 0 ? void 0 : _uniBuilderConfig_output5.convertToRem;
|
|
237
270
|
if (remOptions) {
|
|
238
271
|
const { pluginRem } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-rem")));
|
|
239
272
|
rsbuildPlugins.push(pluginRem(typeof remOptions === "boolean" ? {} : remOptions));
|
|
240
273
|
}
|
|
241
|
-
rsbuildPlugins.push((0, import_runtimeChunk.pluginRuntimeChunk)((
|
|
242
|
-
|
|
274
|
+
rsbuildPlugins.push((0, import_runtimeChunk.pluginRuntimeChunk)((_uniBuilderConfig_output6 = uniBuilderConfig.output) === null || _uniBuilderConfig_output6 === void 0 ? void 0 : _uniBuilderConfig_output6.disableInlineRuntimeChunk));
|
|
275
|
+
const { sourceBuild } = uniBuilderConfig.experiments || {};
|
|
276
|
+
if (sourceBuild) {
|
|
243
277
|
const { pluginSourceBuild } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-source-build")));
|
|
244
|
-
rsbuildPlugins.push(pluginSourceBuild());
|
|
278
|
+
rsbuildPlugins.push(pluginSourceBuild(sourceBuild === true ? {} : sourceBuild));
|
|
245
279
|
}
|
|
246
280
|
rsbuildPlugins.push((0, import_plugin_react.pluginReact)());
|
|
281
|
+
if (!((_uniBuilderConfig_output7 = uniBuilderConfig.output) === null || _uniBuilderConfig_output7 === void 0 ? void 0 : _uniBuilderConfig_output7.disableSvgr)) {
|
|
282
|
+
var _uniBuilderConfig_output13;
|
|
283
|
+
const { pluginSvgr } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-svgr")));
|
|
284
|
+
rsbuildPlugins.push(pluginSvgr({
|
|
285
|
+
svgDefaultExport: ((_uniBuilderConfig_output13 = uniBuilderConfig.output) === null || _uniBuilderConfig_output13 === void 0 ? void 0 : _uniBuilderConfig_output13.svgDefaultExport) || "url"
|
|
286
|
+
}));
|
|
287
|
+
delete output.disableSvgr;
|
|
288
|
+
delete output.svgDefaultExport;
|
|
289
|
+
}
|
|
247
290
|
const pugOptions = (_uniBuilderConfig_tools = uniBuilderConfig.tools) === null || _uniBuilderConfig_tools === void 0 ? void 0 : _uniBuilderConfig_tools.pug;
|
|
248
291
|
if (pugOptions) {
|
|
249
292
|
const { pluginPug } = await Promise.resolve().then(() => __toESM(require("@rsbuild/plugin-pug")));
|
|
@@ -57,6 +57,8 @@ const pluginSplitChunks = () => ({
|
|
|
57
57
|
}
|
|
58
58
|
chain.optimization.splitChunks({
|
|
59
59
|
...currentConfig,
|
|
60
|
+
// rspack chunks type mismatch with webpack
|
|
61
|
+
// @ts-expect-error
|
|
60
62
|
cacheGroups: {
|
|
61
63
|
...currentConfig.cacheGroups,
|
|
62
64
|
...(0, import_shared.createCacheGroups)(groups)
|
package/dist/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { PluginPugOptions } from '@rsbuild/plugin-pug';
|
|
|
13
13
|
import type { PluginBabelOptions } from '@rsbuild/plugin-babel';
|
|
14
14
|
import type { AliasOption } from '@modern-js/utils';
|
|
15
15
|
import type { StartDevServerOptions, UniBuilderStartServerResult } from './shared/devServer';
|
|
16
|
+
import type { PluginSourceBuildOptions } from '@rsbuild/plugin-source-build';
|
|
16
17
|
export type CreateBuilderCommonOptions = {
|
|
17
18
|
entry?: RsbuildEntry;
|
|
18
19
|
frameworkConfigPath?: string;
|
|
@@ -42,21 +43,22 @@ export type DisableSourceMapOption = boolean | {
|
|
|
42
43
|
export type UniBuilderExtraConfig = {
|
|
43
44
|
tools?: {
|
|
44
45
|
styledComponents?: false | PluginStyledComponentsOptions;
|
|
45
|
-
devServer?: {
|
|
46
|
+
devServer?: ChainedConfig<{
|
|
46
47
|
before?: RequestHandler[];
|
|
47
48
|
after?: RequestHandler[];
|
|
48
49
|
client?: DevConfig['client'];
|
|
49
50
|
compress?: ServerConfig['compress'];
|
|
50
51
|
devMiddleware?: {
|
|
51
|
-
writeToDisk
|
|
52
|
+
writeToDisk?: DevConfig['writeToDisk'];
|
|
52
53
|
};
|
|
54
|
+
liveReload?: boolean;
|
|
53
55
|
headers?: ServerConfig['headers'];
|
|
54
56
|
historyApiFallback?: ServerConfig['historyApiFallback'];
|
|
55
57
|
hot?: boolean;
|
|
56
58
|
https?: DevServerHttpsOptions;
|
|
57
59
|
setupMiddlewares?: DevConfig['setupMiddlewares'];
|
|
58
60
|
proxy?: ServerConfig['proxy'];
|
|
59
|
-
}
|
|
61
|
+
}>;
|
|
60
62
|
/**
|
|
61
63
|
* Configure the [Pug](https://pugjs.org/) template engine.
|
|
62
64
|
*/
|
|
@@ -231,7 +233,7 @@ export type UniBuilderExtraConfig = {
|
|
|
231
233
|
/**
|
|
232
234
|
* Enable the ability for source code building
|
|
233
235
|
*/
|
|
234
|
-
sourceBuild?: boolean
|
|
236
|
+
sourceBuild?: boolean | Pick<PluginSourceBuildOptions, 'sourceField' | 'resolvePriority'>;
|
|
235
237
|
};
|
|
236
238
|
};
|
|
237
239
|
export type SriOptions = {
|
|
@@ -256,8 +258,11 @@ export type UniBuilderContext = RsbuildPluginAPI['context'] & {
|
|
|
256
258
|
srcPath: string;
|
|
257
259
|
entry: Record<string, string | string[]>;
|
|
258
260
|
};
|
|
261
|
+
/**
|
|
262
|
+
* make the plugins type looser to avoid type mismatch
|
|
263
|
+
*/
|
|
259
264
|
export type UniBuilderPluginAPI = {
|
|
260
|
-
[key in keyof RsbuildPluginAPI]:
|
|
265
|
+
[key in keyof RsbuildPluginAPI]: any;
|
|
261
266
|
} & {
|
|
262
267
|
/** The following APIs only type incompatibility */
|
|
263
268
|
onBeforeCreateCompiler: (fn: any) => void;
|
|
@@ -68,6 +68,11 @@ const pluginBabel = (options) => ({
|
|
|
68
68
|
version: config2.output.enableLatestDecorators ? "2018-09" : "legacy"
|
|
69
69
|
};
|
|
70
70
|
const baseBabelConfig = isServer || isServiceWorker ? (0, import_node.getBabelConfigForNode)({
|
|
71
|
+
presetEnv: {
|
|
72
|
+
targets: [
|
|
73
|
+
"node >= 14"
|
|
74
|
+
]
|
|
75
|
+
},
|
|
71
76
|
pluginDecorators: decoratorConfig
|
|
72
77
|
}) : (0, import_web.getBabelConfigForWeb)({
|
|
73
78
|
presetEnv: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/uni-builder",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.46.1",
|
|
4
4
|
"description": "Unified builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,21 +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/
|
|
43
|
-
"@rsbuild/
|
|
29
|
+
"@rsbuild/babel-preset": "0.3.4",
|
|
30
|
+
"@rsbuild/core": "0.3.4",
|
|
31
|
+
"@rsbuild/plugin-assets-retry": "0.3.4",
|
|
32
|
+
"@rsbuild/plugin-babel": "0.3.4",
|
|
33
|
+
"@rsbuild/plugin-check-syntax": "0.3.4",
|
|
34
|
+
"@rsbuild/plugin-css-minimizer": "0.3.4",
|
|
35
|
+
"@rsbuild/plugin-pug": "0.3.4",
|
|
36
|
+
"@rsbuild/plugin-react": "0.3.4",
|
|
37
|
+
"@rsbuild/plugin-rem": "0.3.4",
|
|
38
|
+
"@rsbuild/plugin-source-build": "0.3.4",
|
|
39
|
+
"@rsbuild/plugin-styled-components": "0.3.4",
|
|
40
|
+
"@rsbuild/plugin-svgr": "0.3.4",
|
|
41
|
+
"@rsbuild/plugin-type-check": "0.3.4",
|
|
42
|
+
"@rsbuild/plugin-toml": "0.3.4",
|
|
43
|
+
"@rsbuild/plugin-yaml": "0.3.4",
|
|
44
|
+
"@rsbuild/shared": "0.3.4",
|
|
45
|
+
"@rsbuild/webpack": "0.3.4",
|
|
44
46
|
"@swc/helpers": "0.5.3",
|
|
45
47
|
"babel-loader": "9.1.3",
|
|
46
48
|
"babel-plugin-import": "1.13.5",
|
|
@@ -62,19 +64,19 @@
|
|
|
62
64
|
"webpack": "^5.89.0",
|
|
63
65
|
"webpack-manifest-plugin": "5.0.0",
|
|
64
66
|
"webpack-subresource-integrity": "5.1.0",
|
|
65
|
-
"@modern-js/utils": "2.
|
|
66
|
-
"@modern-js/server": "2.
|
|
67
|
-
"@modern-js/prod-server": "2.
|
|
67
|
+
"@modern-js/utils": "2.46.1",
|
|
68
|
+
"@modern-js/server": "2.46.1",
|
|
69
|
+
"@modern-js/prod-server": "2.46.1"
|
|
68
70
|
},
|
|
69
71
|
"devDependencies": {
|
|
70
|
-
"@rsbuild/plugin-swc": "0.
|
|
72
|
+
"@rsbuild/plugin-swc": "0.3.4",
|
|
71
73
|
"@types/lodash": "^4.14.202",
|
|
72
74
|
"react": "^18.2.0",
|
|
73
75
|
"react-dom": "^18.2.0",
|
|
74
76
|
"typescript": "^5.3.0",
|
|
75
|
-
"@modern-js/builder-plugin-node-polyfill": "2.
|
|
76
|
-
"@scripts/build": "2.
|
|
77
|
-
"@scripts/vitest-config": "2.
|
|
77
|
+
"@modern-js/builder-plugin-node-polyfill": "2.46.1",
|
|
78
|
+
"@scripts/build": "2.46.1",
|
|
79
|
+
"@scripts/vitest-config": "2.46.1"
|
|
78
80
|
},
|
|
79
81
|
"publishConfig": {
|
|
80
82
|
"access": "public",
|