@modern-js/uni-builder 2.48.1 → 2.48.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/devServer.d.ts +6 -3
- package/dist/shared/devServer.js +78 -22
- package/dist/shared/parseCommonConfig.js +6 -35
- package/dist/types.d.ts +17 -16
- package/package.json +6 -6
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { StartDevServerOptions as RsbuildStartDevServerOptions, StartServerResult, RsbuildInstance } from '@rsbuild/shared';
|
|
1
|
+
import { StartDevServerOptions as RsbuildStartDevServerOptions, StartServerResult, RsbuildInstance, DevConfig, ServerConfig } from '@rsbuild/shared';
|
|
2
2
|
import type { Server, ModernDevServerOptionsNew } from '@modern-js/server';
|
|
3
|
-
import { UniBuilderConfig } from '../types';
|
|
3
|
+
import type { UniBuilderConfig, ToolsDevServerConfig } from '../types';
|
|
4
4
|
type ServerOptions = Partial<Omit<ModernDevServerOptionsNew, 'config'>> & {
|
|
5
5
|
config?: Partial<ModernDevServerOptionsNew['config']>;
|
|
6
6
|
};
|
|
7
|
+
export declare const transformToRsbuildServerOptions: (dev: NonNullable<UniBuilderConfig['dev']>, devServer: ToolsDevServerConfig) => {
|
|
8
|
+
dev: DevConfig;
|
|
9
|
+
server: ServerConfig;
|
|
10
|
+
};
|
|
7
11
|
export type StartDevServerOptions = Omit<RsbuildStartDevServerOptions, 'printURLs'> & {
|
|
8
12
|
apiOnly?: boolean;
|
|
9
|
-
defaultPort?: number;
|
|
10
13
|
serverOptions?: ServerOptions;
|
|
11
14
|
};
|
|
12
15
|
export type UniBuilderStartServerResult = Omit<StartServerResult, 'server'> & {
|
package/dist/shared/devServer.js
CHANGED
|
@@ -28,7 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var devServer_exports = {};
|
|
30
30
|
__export(devServer_exports, {
|
|
31
|
-
startDevServer: () => startDevServer
|
|
31
|
+
startDevServer: () => startDevServer,
|
|
32
|
+
transformToRsbuildServerOptions: () => transformToRsbuildServerOptions
|
|
32
33
|
});
|
|
33
34
|
module.exports = __toCommonJS(devServer_exports);
|
|
34
35
|
var import_shared = require("@rsbuild/shared");
|
|
@@ -52,55 +53,109 @@ const getServerOptions = (builderConfig) => {
|
|
|
52
53
|
bff: {}
|
|
53
54
|
};
|
|
54
55
|
};
|
|
55
|
-
const
|
|
56
|
-
var
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
const transformToRsbuildServerOptions = (dev, devServer) => {
|
|
57
|
+
var _newDevServerConfig_devMiddleware, _newDevServerConfig_before, _newDevServerConfig_after;
|
|
58
|
+
const { port, host, https, ...devConfig } = dev;
|
|
59
|
+
var _dev_hmr;
|
|
60
|
+
const newDevServerConfig = (0, import_shared.mergeChainedOptions)({
|
|
61
|
+
defaults: {
|
|
62
|
+
devMiddleware: {
|
|
63
|
+
writeToDisk: (file) => !file.includes(".hot-update.")
|
|
64
|
+
},
|
|
65
|
+
hot: (_dev_hmr = dev === null || dev === void 0 ? void 0 : dev.hmr) !== null && _dev_hmr !== void 0 ? _dev_hmr : true,
|
|
66
|
+
liveReload: true,
|
|
67
|
+
client: {
|
|
68
|
+
path: "/webpack-hmr"
|
|
69
|
+
}
|
|
62
70
|
},
|
|
63
|
-
|
|
64
|
-
serverOptions.dev || {}
|
|
65
|
-
);
|
|
66
|
-
const devConfig = (0, import_shared.mergeChainedOptions)({
|
|
67
|
-
defaults: defaultDevConfig,
|
|
68
|
-
options: (_builderConfig_tools = builderConfig.tools) === null || _builderConfig_tools === void 0 ? void 0 : _builderConfig_tools.devServer,
|
|
71
|
+
options: devServer,
|
|
69
72
|
mergeFn: import_shared.deepmerge
|
|
70
73
|
});
|
|
74
|
+
const rsbuildDev = {
|
|
75
|
+
...devConfig,
|
|
76
|
+
writeToDisk: (_newDevServerConfig_devMiddleware = newDevServerConfig.devMiddleware) === null || _newDevServerConfig_devMiddleware === void 0 ? void 0 : _newDevServerConfig_devMiddleware.writeToDisk,
|
|
77
|
+
hmr: newDevServerConfig.hot,
|
|
78
|
+
client: newDevServerConfig.client,
|
|
79
|
+
liveReload: newDevServerConfig.liveReload
|
|
80
|
+
};
|
|
81
|
+
if (dev.progressBar === void 0) {
|
|
82
|
+
rsbuildDev.progressBar = true;
|
|
83
|
+
}
|
|
84
|
+
if (((_newDevServerConfig_before = newDevServerConfig.before) === null || _newDevServerConfig_before === void 0 ? void 0 : _newDevServerConfig_before.length) || ((_newDevServerConfig_after = newDevServerConfig.after) === null || _newDevServerConfig_after === void 0 ? void 0 : _newDevServerConfig_after.length)) {
|
|
85
|
+
rsbuildDev.setupMiddlewares = [
|
|
86
|
+
...newDevServerConfig.setupMiddlewares || [],
|
|
87
|
+
(middlewares) => {
|
|
88
|
+
middlewares.unshift(...newDevServerConfig.before || []);
|
|
89
|
+
middlewares.push(...newDevServerConfig.after || []);
|
|
90
|
+
}
|
|
91
|
+
];
|
|
92
|
+
} else if (newDevServerConfig.setupMiddlewares) {
|
|
93
|
+
rsbuildDev.setupMiddlewares = newDevServerConfig.setupMiddlewares;
|
|
94
|
+
}
|
|
95
|
+
const server = (0, import_shared.isProd)() ? {
|
|
96
|
+
publicDir: false,
|
|
97
|
+
htmlFallback: false
|
|
98
|
+
} : {
|
|
99
|
+
publicDir: false,
|
|
100
|
+
htmlFallback: false,
|
|
101
|
+
compress: newDevServerConfig.compress,
|
|
102
|
+
headers: newDevServerConfig.headers,
|
|
103
|
+
historyApiFallback: newDevServerConfig.historyApiFallback,
|
|
104
|
+
proxy: newDevServerConfig.proxy,
|
|
105
|
+
port,
|
|
106
|
+
host,
|
|
107
|
+
https: https ? https : void 0
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
dev: rsbuildDev,
|
|
111
|
+
server
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
const getDevServerOptions = async ({ builderConfig, serverOptions }) => {
|
|
71
115
|
const defaultConfig = getServerOptions(builderConfig);
|
|
72
116
|
const config = serverOptions.config ? (0, import_shared.deepmerge)(defaultConfig, serverOptions.config) : defaultConfig;
|
|
73
117
|
return {
|
|
74
|
-
config
|
|
75
|
-
devConfig
|
|
118
|
+
config
|
|
76
119
|
};
|
|
77
120
|
};
|
|
78
121
|
async function startDevServer(rsbuild, options = {}, builderConfig) {
|
|
122
|
+
var _serverOptions_dev, _serverOptions_dev1, _rsbuildConfig_server, _rsbuildConfig_dev;
|
|
79
123
|
(0, import_shared.debug)("create dev server");
|
|
80
124
|
const { ServerForRsbuild } = await Promise.resolve().then(() => __toESM(require("@modern-js/server")));
|
|
81
125
|
const rsbuildServer = await rsbuild.getServerAPIs(options);
|
|
82
126
|
const { serverOptions = {} } = options;
|
|
83
|
-
const { config
|
|
127
|
+
const { config } = await getDevServerOptions({
|
|
84
128
|
builderConfig,
|
|
85
|
-
serverOptions
|
|
86
|
-
port: rsbuildServer.config.port
|
|
129
|
+
serverOptions
|
|
87
130
|
});
|
|
88
131
|
const compileMiddlewareAPI = options.apiOnly ? void 0 : await rsbuildServer.startCompile();
|
|
132
|
+
const rsbuildConfig = rsbuild.getRsbuildConfig();
|
|
133
|
+
var _serverOptions_dev_https;
|
|
134
|
+
const https = (_serverOptions_dev_https = (_serverOptions_dev = serverOptions.dev) === null || _serverOptions_dev === void 0 ? void 0 : _serverOptions_dev.https) !== null && _serverOptions_dev_https !== void 0 ? _serverOptions_dev_https : rsbuildServer.config.https;
|
|
135
|
+
var _serverOptions_dev_watch;
|
|
89
136
|
const server = new ServerForRsbuild({
|
|
90
137
|
pwd: rsbuild.context.rootPath,
|
|
91
138
|
...serverOptions,
|
|
92
139
|
rsbuild,
|
|
93
140
|
getMiddlewares: (config2) => rsbuildServer.getMiddlewares({
|
|
94
141
|
compileMiddlewareAPI,
|
|
142
|
+
// TODO: To be removed. should update all rsbuild config in parseCommonConfig stage
|
|
95
143
|
overrides: config2
|
|
96
144
|
}),
|
|
97
|
-
dev:
|
|
145
|
+
dev: {
|
|
146
|
+
watch: (_serverOptions_dev_watch = (_serverOptions_dev1 = serverOptions.dev) === null || _serverOptions_dev1 === void 0 ? void 0 : _serverOptions_dev1.watch) !== null && _serverOptions_dev_watch !== void 0 ? _serverOptions_dev_watch : true,
|
|
147
|
+
compress: (_rsbuildConfig_server = rsbuildConfig.server) === null || _rsbuildConfig_server === void 0 ? void 0 : _rsbuildConfig_server.compress,
|
|
148
|
+
https,
|
|
149
|
+
devMiddleware: {
|
|
150
|
+
writeToDisk: (_rsbuildConfig_dev = rsbuildConfig.dev) === null || _rsbuildConfig_dev === void 0 ? void 0 : _rsbuildConfig_dev.writeToDisk
|
|
151
|
+
}
|
|
152
|
+
},
|
|
98
153
|
config
|
|
99
154
|
});
|
|
100
155
|
const { config: { port, host } } = rsbuildServer;
|
|
101
156
|
(0, import_shared.debug)("create dev server done");
|
|
102
157
|
await rsbuildServer.beforeStart();
|
|
103
|
-
const protocol =
|
|
158
|
+
const protocol = https ? "https" : "http";
|
|
104
159
|
const urls = (0, import_shared.getAddressUrls)({
|
|
105
160
|
protocol,
|
|
106
161
|
port,
|
|
@@ -136,5 +191,6 @@ async function startDevServer(rsbuild, options = {}, builderConfig) {
|
|
|
136
191
|
}
|
|
137
192
|
// Annotate the CommonJS export names for ESM import in node:
|
|
138
193
|
0 && (module.exports = {
|
|
139
|
-
startDevServer
|
|
194
|
+
startDevServer,
|
|
195
|
+
transformToRsbuildServerOptions
|
|
140
196
|
});
|
|
@@ -47,6 +47,7 @@ var import_devtools = require("./plugins/devtools");
|
|
|
47
47
|
var import_emitRouteFile = require("./plugins/emitRouteFile");
|
|
48
48
|
var import_antd = require("./plugins/antd");
|
|
49
49
|
var import_arco = require("./plugins/arco");
|
|
50
|
+
var import_devServer = require("./devServer");
|
|
50
51
|
const GLOBAL_CSS_REGEX = /\.global\.\w+$/;
|
|
51
52
|
const isLooseCssModules = (path) => {
|
|
52
53
|
if (import_shared.NODE_MODULES_REGEX.test(path)) {
|
|
@@ -104,10 +105,10 @@ const isUseCssSourceMap = (disableSourceMap = {}) => {
|
|
|
104
105
|
return !disableSourceMap.css;
|
|
105
106
|
};
|
|
106
107
|
async function parseCommonConfig(uniBuilderConfig, options) {
|
|
107
|
-
var
|
|
108
|
+
var _uniBuilderConfig_output, _uniBuilderConfig_tools;
|
|
108
109
|
var _output, _output_distPath, _output_distPath1, _output1, _extraConfig, _html, _extraConfig1;
|
|
109
110
|
const { cwd, frameworkConfigPath, entry, target } = options;
|
|
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
|
|
111
|
+
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, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, ...toolsConfig } = {} } = uniBuilderConfig;
|
|
111
112
|
const rsbuildConfig = {
|
|
112
113
|
plugins,
|
|
113
114
|
output: outputConfig,
|
|
@@ -118,10 +119,9 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
118
119
|
performance: performanceConfig,
|
|
119
120
|
html: htmlConfig,
|
|
120
121
|
tools: toolsConfig,
|
|
121
|
-
dev: devConfig,
|
|
122
122
|
security: securityConfig
|
|
123
123
|
};
|
|
124
|
-
const {
|
|
124
|
+
const { html = {}, output = {}, source = {} } = rsbuildConfig;
|
|
125
125
|
if (enableLatestDecorators) {
|
|
126
126
|
source.decorators = {
|
|
127
127
|
version: "2022-03"
|
|
@@ -213,38 +213,9 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
213
213
|
};
|
|
214
214
|
}
|
|
215
215
|
};
|
|
216
|
-
|
|
217
|
-
dev.progressBar = true;
|
|
218
|
-
}
|
|
219
|
-
var _dev_hmr;
|
|
220
|
-
const newDevServerConfig = (0, import_shared.mergeChainedOptions)({
|
|
221
|
-
defaults: {
|
|
222
|
-
devMiddleware: {
|
|
223
|
-
writeToDisk: (file) => !file.includes(".hot-update.")
|
|
224
|
-
},
|
|
225
|
-
hot: (_dev_hmr = dev === null || dev === void 0 ? void 0 : dev.hmr) !== null && _dev_hmr !== void 0 ? _dev_hmr : true,
|
|
226
|
-
liveReload: true,
|
|
227
|
-
client: {
|
|
228
|
-
path: "/webpack-hmr"
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
options: devServer,
|
|
232
|
-
mergeFn: import_shared.deepmerge
|
|
233
|
-
});
|
|
234
|
-
dev.writeToDisk = (_newDevServerConfig_devMiddleware = newDevServerConfig.devMiddleware) === null || _newDevServerConfig_devMiddleware === void 0 ? void 0 : _newDevServerConfig_devMiddleware.writeToDisk;
|
|
235
|
-
dev.hmr = newDevServerConfig.hot;
|
|
236
|
-
dev.client = newDevServerConfig.client;
|
|
237
|
-
dev.liveReload = newDevServerConfig.liveReload;
|
|
238
|
-
const server = (0, import_shared.isProd)() ? {
|
|
239
|
-
publicDir: false
|
|
240
|
-
} : {
|
|
241
|
-
publicDir: false,
|
|
242
|
-
port,
|
|
243
|
-
host,
|
|
244
|
-
https: https ? https : void 0
|
|
245
|
-
};
|
|
216
|
+
const { dev: RsbuildDev, server } = (0, import_devServer.transformToRsbuildServerOptions)(dev || {}, devServer || {});
|
|
246
217
|
rsbuildConfig.server = removeUndefinedKey(server);
|
|
247
|
-
rsbuildConfig.dev = removeUndefinedKey(
|
|
218
|
+
rsbuildConfig.dev = removeUndefinedKey(RsbuildDev);
|
|
248
219
|
rsbuildConfig.html = html;
|
|
249
220
|
rsbuildConfig.output = output;
|
|
250
221
|
if (entry) {
|
package/dist/types.d.ts
CHANGED
|
@@ -40,25 +40,26 @@ export type DisableSourceMapOption = boolean | {
|
|
|
40
40
|
js?: boolean;
|
|
41
41
|
css?: boolean;
|
|
42
42
|
};
|
|
43
|
+
export type ToolsDevServerConfig = ChainedConfig<{
|
|
44
|
+
before?: RequestHandler[];
|
|
45
|
+
after?: RequestHandler[];
|
|
46
|
+
client?: DevConfig['client'];
|
|
47
|
+
compress?: ServerConfig['compress'];
|
|
48
|
+
devMiddleware?: {
|
|
49
|
+
writeToDisk?: DevConfig['writeToDisk'];
|
|
50
|
+
};
|
|
51
|
+
liveReload?: boolean;
|
|
52
|
+
headers?: ServerConfig['headers'];
|
|
53
|
+
historyApiFallback?: ServerConfig['historyApiFallback'];
|
|
54
|
+
hot?: boolean;
|
|
55
|
+
https?: DevServerHttpsOptions;
|
|
56
|
+
setupMiddlewares?: DevConfig['setupMiddlewares'];
|
|
57
|
+
proxy?: ServerConfig['proxy'];
|
|
58
|
+
}>;
|
|
43
59
|
export type UniBuilderExtraConfig = {
|
|
44
60
|
tools?: {
|
|
45
61
|
styledComponents?: false | PluginStyledComponentsOptions;
|
|
46
|
-
devServer?:
|
|
47
|
-
before?: RequestHandler[];
|
|
48
|
-
after?: RequestHandler[];
|
|
49
|
-
client?: DevConfig['client'];
|
|
50
|
-
compress?: ServerConfig['compress'];
|
|
51
|
-
devMiddleware?: {
|
|
52
|
-
writeToDisk?: DevConfig['writeToDisk'];
|
|
53
|
-
};
|
|
54
|
-
liveReload?: boolean;
|
|
55
|
-
headers?: ServerConfig['headers'];
|
|
56
|
-
historyApiFallback?: ServerConfig['historyApiFallback'];
|
|
57
|
-
hot?: boolean;
|
|
58
|
-
https?: DevServerHttpsOptions;
|
|
59
|
-
setupMiddlewares?: DevConfig['setupMiddlewares'];
|
|
60
|
-
proxy?: ServerConfig['proxy'];
|
|
61
|
-
}>;
|
|
62
|
+
devServer?: ToolsDevServerConfig;
|
|
62
63
|
/**
|
|
63
64
|
* Configure the [Pug](https://pugjs.org/) template engine.
|
|
64
65
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/uni-builder",
|
|
3
|
-
"version": "2.48.
|
|
3
|
+
"version": "2.48.2",
|
|
4
4
|
"description": "Unified builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -66,8 +66,8 @@
|
|
|
66
66
|
"webpack": "^5.89.0",
|
|
67
67
|
"webpack-manifest-plugin": "5.0.0",
|
|
68
68
|
"webpack-subresource-integrity": "5.1.0",
|
|
69
|
-
"@modern-js/utils": "2.48.
|
|
70
|
-
"@modern-js/server": "2.48.
|
|
69
|
+
"@modern-js/utils": "2.48.2",
|
|
70
|
+
"@modern-js/server": "2.48.2"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
73
|
"@rsbuild/plugin-swc": "0.4.15",
|
|
@@ -75,9 +75,9 @@
|
|
|
75
75
|
"react": "^18.2.0",
|
|
76
76
|
"react-dom": "^18.2.0",
|
|
77
77
|
"typescript": "^5.3.0",
|
|
78
|
-
"@modern-js/prod-server": "2.48.
|
|
79
|
-
"@scripts/build": "2.48.
|
|
80
|
-
"@scripts/vitest-config": "2.48.
|
|
78
|
+
"@modern-js/prod-server": "2.48.2",
|
|
79
|
+
"@scripts/build": "2.48.2",
|
|
80
|
+
"@scripts/vitest-config": "2.48.2"
|
|
81
81
|
},
|
|
82
82
|
"publishConfig": {
|
|
83
83
|
"access": "public",
|