@modern-js/uni-builder 2.56.1 → 2.57.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/index.d.ts +1 -2
- package/dist/rspack/index.js +0 -4
- package/dist/shared/devServer.d.ts +1 -21
- package/dist/shared/devServer.js +15 -111
- package/dist/types.d.ts +5 -9
- package/dist/webpack/index.js +0 -4
- package/package.json +5 -7
package/dist/index.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ import type { CreateUniBuilderOptions } from './types';
|
|
|
4
4
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
5
5
|
export { HtmlWebpackPlugin };
|
|
6
6
|
export type { CreateUniBuilderOptions, UniBuilderInstance, UniBuilderWebpackInstance, };
|
|
7
|
-
export type { UniBuilderConfig, UniBuilderPlugin, BundlerType, MetaOptions, Stats, MultiStats, RspackConfig, } from './types';
|
|
8
|
-
export type { StartDevServerOptions } from './shared/devServer';
|
|
7
|
+
export type { UniBuilderConfig, UniBuilderPlugin, LooseRsbuildPlugin, BundlerType, MetaOptions, Stats, MultiStats, RspackConfig, } from './types';
|
|
9
8
|
export declare function createUniBuilder(options: CreateUniBuilderOptions): Promise<UniBuilderInstance>;
|
|
10
9
|
export { logger, type ConfigChain, type RsbuildPlugin, type ChainIdentifier, type RspackChain, type Rspack, type RsbuildContext, type RsbuildConfig, type RsbuildTarget, type NormalizedConfig, type CacheGroup, } from '@rsbuild/core';
|
|
11
10
|
export type { webpack, WebpackConfig } from '@rsbuild/webpack';
|
package/dist/rspack/index.js
CHANGED
|
@@ -84,10 +84,6 @@ async function createRspackBuilder(options) {
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
rsbuild.addPlugins(warpedPlugins, options2);
|
|
87
|
-
},
|
|
88
|
-
startDevServer: async (options2 = {}) => {
|
|
89
|
-
const { startDevServer } = await Promise.resolve().then(() => __toESM(require("../shared/devServer")));
|
|
90
|
-
return startDevServer(rsbuild, options2, config);
|
|
91
87
|
}
|
|
92
88
|
};
|
|
93
89
|
}
|
|
@@ -1,26 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import { type RsbuildInstance, type DevConfig, type ServerConfig, type Rspack } from '@rsbuild/core';
|
|
3
|
-
import type { ModernDevServerOptions } from '@modern-js/server';
|
|
4
|
-
import type { Server } from 'node:http';
|
|
5
|
-
import { type ApplyPlugins } from '@modern-js/prod-server';
|
|
1
|
+
import { type DevConfig, type ServerConfig } from '@rsbuild/core';
|
|
6
2
|
import type { UniBuilderConfig, ToolsDevServerConfig } from '../types';
|
|
7
|
-
type ServerOptions = Partial<Omit<ModernDevServerOptions, 'config'>> & {
|
|
8
|
-
config?: Partial<ModernDevServerOptions['config']>;
|
|
9
|
-
};
|
|
10
3
|
export declare const transformToRsbuildServerOptions: (dev: NonNullable<UniBuilderConfig['dev']>, devServer: ToolsDevServerConfig) => {
|
|
11
4
|
dev: DevConfig;
|
|
12
5
|
server: ServerConfig;
|
|
13
6
|
};
|
|
14
|
-
export type StartDevServerOptions = {
|
|
15
|
-
compiler?: Rspack.Compiler | Rspack.MultiCompiler;
|
|
16
|
-
getPortSilently?: boolean;
|
|
17
|
-
apiOnly?: boolean;
|
|
18
|
-
serverOptions?: ServerOptions;
|
|
19
|
-
applyPlugins?: ApplyPlugins;
|
|
20
|
-
};
|
|
21
|
-
export type UniBuilderStartServerResult = {
|
|
22
|
-
server: Server;
|
|
23
|
-
port: number;
|
|
24
|
-
};
|
|
25
|
-
export declare function startDevServer(rsbuild: RsbuildInstance, options: StartDevServerOptions | undefined, builderConfig: UniBuilderConfig): Promise<UniBuilderStartServerResult>;
|
|
26
|
-
export {};
|
package/dist/shared/devServer.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,49 +15,30 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
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
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
var devServer_exports = {};
|
|
30
20
|
__export(devServer_exports, {
|
|
31
|
-
startDevServer: () => startDevServer,
|
|
32
21
|
transformToRsbuildServerOptions: () => transformToRsbuildServerOptions
|
|
33
22
|
});
|
|
34
23
|
module.exports = __toCommonJS(devServer_exports);
|
|
35
24
|
var import_ts_deepmerge = require("ts-deepmerge");
|
|
36
25
|
var import_utils = require("@modern-js/utils");
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
html: {},
|
|
51
|
-
tools: {
|
|
52
|
-
babel: {}
|
|
53
|
-
},
|
|
54
|
-
server: {},
|
|
55
|
-
runtime: {},
|
|
56
|
-
bff: {},
|
|
57
|
-
dev: {},
|
|
58
|
-
security: {}
|
|
59
|
-
};
|
|
26
|
+
const transformDevSetupMiddlewares = (seuptMiddlewares) => {
|
|
27
|
+
if (seuptMiddlewares) {
|
|
28
|
+
const newSetupMiddlewares = seuptMiddlewares.map((handler) => (_, server) => {
|
|
29
|
+
handler({
|
|
30
|
+
unshift() {
|
|
31
|
+
},
|
|
32
|
+
push() {
|
|
33
|
+
}
|
|
34
|
+
}, server);
|
|
35
|
+
});
|
|
36
|
+
return newSetupMiddlewares;
|
|
37
|
+
}
|
|
38
|
+
return void 0;
|
|
60
39
|
};
|
|
61
40
|
const transformToRsbuildServerOptions = (dev, devServer) => {
|
|
62
|
-
var _newDevServerConfig_devMiddleware
|
|
41
|
+
var _newDevServerConfig_devMiddleware;
|
|
63
42
|
const { port = 8080, host, https, startUrl, beforeStartUrl, ...devConfig } = dev;
|
|
64
43
|
var _dev_hmr;
|
|
65
44
|
const newDevServerConfig = (0, import_utils.applyOptionsChain)({
|
|
@@ -88,17 +67,7 @@ const transformToRsbuildServerOptions = (dev, devServer) => {
|
|
|
88
67
|
if (dev.progressBar === void 0) {
|
|
89
68
|
rsbuildDev.progressBar = true;
|
|
90
69
|
}
|
|
91
|
-
|
|
92
|
-
rsbuildDev.setupMiddlewares = [
|
|
93
|
-
...newDevServerConfig.setupMiddlewares || [],
|
|
94
|
-
(middlewares) => {
|
|
95
|
-
middlewares.unshift(...newDevServerConfig.before || []);
|
|
96
|
-
middlewares.push(...newDevServerConfig.after || []);
|
|
97
|
-
}
|
|
98
|
-
];
|
|
99
|
-
} else if (newDevServerConfig.setupMiddlewares) {
|
|
100
|
-
rsbuildDev.setupMiddlewares = newDevServerConfig.setupMiddlewares;
|
|
101
|
-
}
|
|
70
|
+
rsbuildDev.setupMiddlewares = transformDevSetupMiddlewares(newDevServerConfig.setupMiddlewares);
|
|
102
71
|
const server = (0, import_utils.isProd)() ? {
|
|
103
72
|
publicDir: false,
|
|
104
73
|
htmlFallback: false,
|
|
@@ -126,72 +95,7 @@ const transformToRsbuildServerOptions = (dev, devServer) => {
|
|
|
126
95
|
server
|
|
127
96
|
};
|
|
128
97
|
};
|
|
129
|
-
const getDevServerOptions = async ({ builderConfig, serverOptions }) => {
|
|
130
|
-
const defaultConfig = getServerOptions(builderConfig);
|
|
131
|
-
const config = serverOptions.config ? (0, import_ts_deepmerge.merge)(defaultConfig, serverOptions.config) : defaultConfig;
|
|
132
|
-
return {
|
|
133
|
-
config
|
|
134
|
-
};
|
|
135
|
-
};
|
|
136
|
-
async function startDevServer(rsbuild, options = {}, builderConfig) {
|
|
137
|
-
var _serverOptions_dev, _serverOptions_dev1;
|
|
138
|
-
import_core.logger.debug("create dev server");
|
|
139
|
-
if (!options.applyPlugins) {
|
|
140
|
-
options.applyPlugins = import_prod_server.applyPlugins;
|
|
141
|
-
}
|
|
142
|
-
const { createDevServer } = await Promise.resolve().then(() => __toESM(require("@modern-js/server")));
|
|
143
|
-
const rsbuildServer = await rsbuild.createDevServer({
|
|
144
|
-
...options,
|
|
145
|
-
runCompile: !options.apiOnly
|
|
146
|
-
});
|
|
147
|
-
const { serverOptions = {} } = options;
|
|
148
|
-
const { config } = await getDevServerOptions({
|
|
149
|
-
builderConfig,
|
|
150
|
-
serverOptions
|
|
151
|
-
});
|
|
152
|
-
const rsbuildConfig = rsbuild.getNormalizedConfig();
|
|
153
|
-
var _serverOptions_dev_https;
|
|
154
|
-
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 : rsbuildConfig.server.https;
|
|
155
|
-
const { port } = rsbuildServer;
|
|
156
|
-
const { server: { host }, dev: { writeToDisk } } = rsbuildConfig;
|
|
157
|
-
var _serverOptions_dev_watch;
|
|
158
|
-
const server = await createDevServer({
|
|
159
|
-
pwd: rsbuild.context.rootPath,
|
|
160
|
-
...serverOptions,
|
|
161
|
-
appContext: serverOptions.appContext || {},
|
|
162
|
-
rsbuild,
|
|
163
|
-
getMiddlewares: () => ({
|
|
164
|
-
middlewares: rsbuildServer.middlewares,
|
|
165
|
-
close: rsbuildServer.close,
|
|
166
|
-
onHTTPUpgrade: rsbuildServer.onHTTPUpgrade
|
|
167
|
-
}),
|
|
168
|
-
dev: {
|
|
169
|
-
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,
|
|
170
|
-
https,
|
|
171
|
-
writeToDisk
|
|
172
|
-
},
|
|
173
|
-
config
|
|
174
|
-
}, options.applyPlugins);
|
|
175
|
-
import_core.logger.debug("listen dev server");
|
|
176
|
-
return new Promise((resolve) => {
|
|
177
|
-
server.listen({
|
|
178
|
-
host,
|
|
179
|
-
port
|
|
180
|
-
}, async (err) => {
|
|
181
|
-
if (err) {
|
|
182
|
-
throw err;
|
|
183
|
-
}
|
|
184
|
-
import_core.logger.debug("listen dev server done");
|
|
185
|
-
await rsbuildServer.afterListen();
|
|
186
|
-
resolve({
|
|
187
|
-
port,
|
|
188
|
-
server
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
98
|
// Annotate the CommonJS export names for ESM import in node:
|
|
194
99
|
0 && (module.exports = {
|
|
195
|
-
startDevServer,
|
|
196
100
|
transformToRsbuildServerOptions
|
|
197
101
|
});
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConfigChainWithContext, ConfigChain, DevConfig, RsbuildConfig, RsbuildTarget, Polyfill, ScriptInject, ServerConfig, RsbuildPluginAPI, OutputConfig, DistPathConfig, Rspack, RequestHandler, NodeEnv, HtmlTagDescriptor } from '@rsbuild/core';
|
|
1
|
+
import type { ConfigChainWithContext, ConfigChain, DevConfig, RsbuildConfig, RsbuildTarget, Polyfill, ScriptInject, ServerConfig, RsbuildPluginAPI, OutputConfig, DistPathConfig, Rspack, RequestHandler, NodeEnv, HtmlTagDescriptor, RsbuildPlugin } from '@rsbuild/core';
|
|
2
2
|
import type { PluginAssetsRetryOptions } from '@rsbuild/plugin-assets-retry';
|
|
3
3
|
import type { PluginStyledComponentsOptions } from '@rsbuild/plugin-styled-components';
|
|
4
4
|
import type { PluginRemOptions } from '@rsbuild/plugin-rem';
|
|
@@ -12,7 +12,6 @@ import type { PluginBabelOptions } from '@rsbuild/plugin-babel';
|
|
|
12
12
|
import type { PluginSassOptions } from '@rsbuild/plugin-sass';
|
|
13
13
|
import type { PluginLessOptions } from '@rsbuild/plugin-less';
|
|
14
14
|
import type { AliasOption } from '@modern-js/utils';
|
|
15
|
-
import type { StartDevServerOptions, UniBuilderStartServerResult } from './shared/devServer';
|
|
16
15
|
import type { PluginSourceBuildOptions } from '@rsbuild/plugin-source-build';
|
|
17
16
|
import type TerserPlugin from 'terser-webpack-plugin';
|
|
18
17
|
import type { Options as HTMLPluginOptions } from 'html-webpack-plugin';
|
|
@@ -313,15 +312,9 @@ export type SriOptions = {
|
|
|
313
312
|
hashLoading?: 'eager' | 'lazy';
|
|
314
313
|
};
|
|
315
314
|
export type OverridesUniBuilderInstance = {
|
|
316
|
-
addPlugins: (plugins: UniBuilderPlugin
|
|
315
|
+
addPlugins: (plugins: Array<UniBuilderPlugin | LooseRsbuildPlugin>, options?: {
|
|
317
316
|
before?: string;
|
|
318
317
|
}) => void;
|
|
319
|
-
/**
|
|
320
|
-
* should be used in conjunction with the upper-layer framework:
|
|
321
|
-
*
|
|
322
|
-
* missing route.json (required in modern server)
|
|
323
|
-
*/
|
|
324
|
-
startDevServer: (options: StartDevServerOptions) => Promise<UniBuilderStartServerResult>;
|
|
325
318
|
};
|
|
326
319
|
export type UniBuilderContext = RsbuildPluginAPI['context'] & {
|
|
327
320
|
target: RsbuildTarget[];
|
|
@@ -358,6 +351,9 @@ export type UniBuilderPlugin = {
|
|
|
358
351
|
post?: string[];
|
|
359
352
|
remove?: string[];
|
|
360
353
|
};
|
|
354
|
+
export type LooseRsbuildPlugin = Omit<RsbuildPlugin, 'setup'> & {
|
|
355
|
+
setup: (api: any) => Promise<void> | void;
|
|
356
|
+
};
|
|
361
357
|
export type DistPath = DistPathConfig & {
|
|
362
358
|
server?: string;
|
|
363
359
|
worker?: string;
|
package/dist/webpack/index.js
CHANGED
|
@@ -111,10 +111,6 @@ async function createWebpackBuilder(options) {
|
|
|
111
111
|
});
|
|
112
112
|
});
|
|
113
113
|
rsbuild.addPlugins(warpedPlugins, options2);
|
|
114
|
-
},
|
|
115
|
-
startDevServer: async (options2 = {}) => {
|
|
116
|
-
const { startDevServer } = await Promise.resolve().then(() => __toESM(require("../shared/devServer")));
|
|
117
|
-
return startDevServer(rsbuild, options2, config);
|
|
118
114
|
}
|
|
119
115
|
};
|
|
120
116
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/uni-builder",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.57.0",
|
|
4
4
|
"description": "Unified builder for Modern.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -71,10 +71,8 @@
|
|
|
71
71
|
"ts-loader": "9.4.4",
|
|
72
72
|
"webpack": "^5.93.0",
|
|
73
73
|
"webpack-subresource-integrity": "5.1.0",
|
|
74
|
-
"@modern-js/
|
|
75
|
-
"@modern-js/
|
|
76
|
-
"@modern-js/utils": "2.56.1",
|
|
77
|
-
"@modern-js/babel-preset": "2.56.1"
|
|
74
|
+
"@modern-js/utils": "2.57.0",
|
|
75
|
+
"@modern-js/babel-preset": "2.57.0"
|
|
78
76
|
},
|
|
79
77
|
"devDependencies": {
|
|
80
78
|
"@rsbuild/plugin-swc": "1.0.1-beta.3",
|
|
@@ -84,8 +82,8 @@
|
|
|
84
82
|
"react-dom": "^18.2.0",
|
|
85
83
|
"terser": "^5.31.1",
|
|
86
84
|
"typescript": "^5.3.0",
|
|
87
|
-
"@scripts/
|
|
88
|
-
"@scripts/
|
|
85
|
+
"@scripts/vitest-config": "2.57.0",
|
|
86
|
+
"@scripts/build": "2.57.0"
|
|
89
87
|
},
|
|
90
88
|
"publishConfig": {
|
|
91
89
|
"access": "public",
|