@modern-js/uni-builder 2.48.6 → 2.49.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.
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { StartDevServerOptions as RsbuildStartDevServerOptions, StartServerResult, RsbuildInstance, DevConfig, ServerConfig } from '@rsbuild/shared';
|
|
2
|
-
import type {
|
|
3
|
+
import type { ModernDevServerOptions } from '@modern-js/server';
|
|
4
|
+
import type { Server } from 'node:http';
|
|
5
|
+
import { type InitProdMiddlewares } from '@modern-js/prod-server';
|
|
3
6
|
import type { UniBuilderConfig, ToolsDevServerConfig } from '../types';
|
|
4
|
-
type ServerOptions = Partial<Omit<
|
|
5
|
-
config?: Partial<
|
|
7
|
+
type ServerOptions = Partial<Omit<ModernDevServerOptions, 'config'>> & {
|
|
8
|
+
config?: Partial<ModernDevServerOptions['config']>;
|
|
6
9
|
};
|
|
7
10
|
export declare const transformToRsbuildServerOptions: (dev: NonNullable<UniBuilderConfig['dev']>, devServer: ToolsDevServerConfig) => {
|
|
8
11
|
dev: DevConfig;
|
|
@@ -11,6 +14,7 @@ export declare const transformToRsbuildServerOptions: (dev: NonNullable<UniBuild
|
|
|
11
14
|
export type StartDevServerOptions = RsbuildStartDevServerOptions & {
|
|
12
15
|
apiOnly?: boolean;
|
|
13
16
|
serverOptions?: ServerOptions;
|
|
17
|
+
initProdMiddlewares?: InitProdMiddlewares;
|
|
14
18
|
};
|
|
15
19
|
export type UniBuilderStartServerResult = Omit<StartServerResult, 'server'> & {
|
|
16
20
|
server: Server;
|
package/dist/shared/devServer.js
CHANGED
|
@@ -33,6 +33,7 @@ __export(devServer_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(devServer_exports);
|
|
35
35
|
var import_shared = require("@rsbuild/shared");
|
|
36
|
+
var import_prod_server = require("@modern-js/prod-server");
|
|
36
37
|
const getServerOptions = (builderConfig) => {
|
|
37
38
|
var _builderConfig_output_distPath, _builderConfig_output, _builderConfig_output1, _builderConfig_output2;
|
|
38
39
|
return {
|
|
@@ -123,7 +124,11 @@ const getDevServerOptions = async ({ builderConfig, serverOptions }) => {
|
|
|
123
124
|
};
|
|
124
125
|
async function startDevServer(rsbuild, options = {}, builderConfig) {
|
|
125
126
|
var _serverOptions_dev, _serverOptions_dev1;
|
|
126
|
-
|
|
127
|
+
(0, import_shared.debug)("create dev server");
|
|
128
|
+
if (!options.initProdMiddlewares) {
|
|
129
|
+
options.initProdMiddlewares = import_prod_server.initProdMiddlewares;
|
|
130
|
+
}
|
|
131
|
+
const { createDevServer } = await Promise.resolve().then(() => __toESM(require("@modern-js/server")));
|
|
127
132
|
const rsbuildServer = await rsbuild.createDevServer({
|
|
128
133
|
...options,
|
|
129
134
|
runCompile: !options.apiOnly
|
|
@@ -139,9 +144,10 @@ async function startDevServer(rsbuild, options = {}, builderConfig) {
|
|
|
139
144
|
const { port } = rsbuildServer;
|
|
140
145
|
const { server: { host }, dev: { writeToDisk } } = rsbuildConfig;
|
|
141
146
|
var _serverOptions_dev_watch;
|
|
142
|
-
const server =
|
|
147
|
+
const server = await createDevServer({
|
|
143
148
|
pwd: rsbuild.context.rootPath,
|
|
144
149
|
...serverOptions,
|
|
150
|
+
appContext: serverOptions.appContext || {},
|
|
145
151
|
rsbuild,
|
|
146
152
|
getMiddlewares: () => ({
|
|
147
153
|
middlewares: rsbuildServer.middlewares,
|
|
@@ -154,7 +160,7 @@ async function startDevServer(rsbuild, options = {}, builderConfig) {
|
|
|
154
160
|
writeToDisk
|
|
155
161
|
},
|
|
156
162
|
config
|
|
157
|
-
});
|
|
163
|
+
}, options.initProdMiddlewares);
|
|
158
164
|
const protocol = https ? "https" : "http";
|
|
159
165
|
const urls = (0, import_shared.getAddressUrls)({
|
|
160
166
|
protocol,
|
|
@@ -162,7 +168,6 @@ async function startDevServer(rsbuild, options = {}, builderConfig) {
|
|
|
162
168
|
host
|
|
163
169
|
});
|
|
164
170
|
(0, import_shared.debug)("listen dev server");
|
|
165
|
-
await server.init();
|
|
166
171
|
return new Promise((resolve) => {
|
|
167
172
|
server.listen({
|
|
168
173
|
host,
|
|
@@ -108,10 +108,13 @@ async function parseCommonConfig(uniBuilderConfig, options) {
|
|
|
108
108
|
var _uniBuilderConfig_output, _uniBuilderConfig_tools;
|
|
109
109
|
var _output, _output_distPath, _output_distPath1, _output1, _extraConfig, _html, _extraConfig1;
|
|
110
110
|
const { cwd, frameworkConfigPath, entry, target } = options;
|
|
111
|
-
const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { disableFilenameHash, enableLatestDecorators, cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, disableSourceMap, convertToRem, disableMinimize, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, tagsByEntries, tags, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, ...sourceConfig } = {}, dev, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, ...toolsConfig } = {} } = uniBuilderConfig;
|
|
111
|
+
const { plugins: [...plugins] = [], performance: { ...performanceConfig } = {}, output: { disableFilenameHash, enableLatestDecorators, cssModuleLocalIdentName, enableInlineScripts, disableCssExtract, enableInlineStyles, disableCssModuleExtension, disableTsChecker, disableSvgr, svgDefaultExport, assetsRetry, enableAssetFallback, disableSourceMap, convertToRem, disableMinimize, polyfill, ...outputConfig } = {}, html: { disableHtmlFolder, metaByEntries, titleByEntries, faviconByEntries, injectByEntries, templateByEntries, templateParametersByEntries, tagsByEntries, tags, ...htmlConfig } = {}, source: { alias, globalVars, resolveMainFields, resolveExtensionPrefix, ...sourceConfig } = {}, dev, security: { checkSyntax, sri, ...securityConfig } = {}, tools: { devServer, tsChecker, minifyCss, ...toolsConfig } = {} } = uniBuilderConfig;
|
|
112
112
|
const rsbuildConfig = {
|
|
113
113
|
plugins,
|
|
114
|
-
output:
|
|
114
|
+
output: {
|
|
115
|
+
polyfill: polyfill === "ua" ? "off" : polyfill,
|
|
116
|
+
...outputConfig
|
|
117
|
+
},
|
|
115
118
|
source: {
|
|
116
119
|
alias,
|
|
117
120
|
...sourceConfig
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NodeEnv, MetaOptions, ServerConfig, ScriptInject, RsbuildTarget, ChainedConfig, ChainedConfigWithUtils, InlineChunkTest, DevConfig, RequestHandler, RsbuildEntry, MaybePromise, RsbuildPluginAPI, ArrayOrNot, HtmlTagDescriptor } from '@rsbuild/shared';
|
|
1
|
+
import type { NodeEnv, MetaOptions, ServerConfig, ScriptInject, RsbuildTarget, ChainedConfig, ChainedConfigWithUtils, InlineChunkTest, DevConfig, RequestHandler, RsbuildEntry, MaybePromise, RsbuildPluginAPI, ArrayOrNot, HtmlTagDescriptor, Polyfill } from '@rsbuild/shared';
|
|
2
2
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
3
3
|
import type { PluginAssetsRetryOptions } from '@rsbuild/plugin-assets-retry';
|
|
4
4
|
import type { PluginStyledComponentsOptions } from '@rsbuild/plugin-styled-components';
|
|
@@ -324,7 +324,9 @@ export type UniBuilderPlugin = {
|
|
|
324
324
|
export type UniBuilderConfig = {
|
|
325
325
|
dev?: RsbuildConfig['dev'];
|
|
326
326
|
html?: RsbuildConfig['html'];
|
|
327
|
-
output?: RsbuildConfig['output']
|
|
327
|
+
output?: Omit<NonNullable<RsbuildConfig['output']>, 'polyfill'> & {
|
|
328
|
+
polyfill?: Polyfill | 'ua';
|
|
329
|
+
};
|
|
328
330
|
performance?: RsbuildConfig['performance'];
|
|
329
331
|
security?: RsbuildConfig['security'];
|
|
330
332
|
tools?: RsbuildConfig['tools'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/uni-builder",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.49.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.6.
|
|
30
|
-
"@rsbuild/core": "0.6.
|
|
31
|
-
"@rsbuild/plugin-assets-retry": "0.6.
|
|
32
|
-
"@rsbuild/plugin-babel": "0.6.
|
|
33
|
-
"@rsbuild/plugin-check-syntax": "0.6.
|
|
34
|
-
"@rsbuild/plugin-css-minimizer": "0.6.
|
|
35
|
-
"@rsbuild/plugin-pug": "0.6.
|
|
36
|
-
"@rsbuild/plugin-react": "0.6.
|
|
37
|
-
"@rsbuild/plugin-rem": "0.6.
|
|
38
|
-
"@rsbuild/plugin-source-build": "0.6.
|
|
39
|
-
"@rsbuild/plugin-styled-components": "0.6.
|
|
40
|
-
"@rsbuild/plugin-svgr": "0.6.
|
|
41
|
-
"@rsbuild/plugin-type-check": "0.6.
|
|
42
|
-
"@rsbuild/plugin-toml": "0.6.
|
|
43
|
-
"@rsbuild/plugin-yaml": "0.6.
|
|
44
|
-
"@rsbuild/shared": "0.6.
|
|
45
|
-
"@rsbuild/webpack": "0.6.
|
|
29
|
+
"@rsbuild/babel-preset": "0.6.3",
|
|
30
|
+
"@rsbuild/core": "0.6.3",
|
|
31
|
+
"@rsbuild/plugin-assets-retry": "0.6.3",
|
|
32
|
+
"@rsbuild/plugin-babel": "0.6.3",
|
|
33
|
+
"@rsbuild/plugin-check-syntax": "0.6.3",
|
|
34
|
+
"@rsbuild/plugin-css-minimizer": "0.6.3",
|
|
35
|
+
"@rsbuild/plugin-pug": "0.6.3",
|
|
36
|
+
"@rsbuild/plugin-react": "0.6.3",
|
|
37
|
+
"@rsbuild/plugin-rem": "0.6.3",
|
|
38
|
+
"@rsbuild/plugin-source-build": "0.6.3",
|
|
39
|
+
"@rsbuild/plugin-styled-components": "0.6.3",
|
|
40
|
+
"@rsbuild/plugin-svgr": "0.6.3",
|
|
41
|
+
"@rsbuild/plugin-type-check": "0.6.3",
|
|
42
|
+
"@rsbuild/plugin-toml": "0.6.3",
|
|
43
|
+
"@rsbuild/plugin-yaml": "0.6.3",
|
|
44
|
+
"@rsbuild/shared": "0.6.3",
|
|
45
|
+
"@rsbuild/webpack": "0.6.3",
|
|
46
46
|
"@swc/helpers": "0.5.3",
|
|
47
47
|
"babel-loader": "9.1.3",
|
|
48
48
|
"babel-plugin-import": "1.13.5",
|
|
@@ -67,18 +67,18 @@
|
|
|
67
67
|
"webpack": "^5.91.0",
|
|
68
68
|
"webpack-manifest-plugin": "5.0.0",
|
|
69
69
|
"webpack-subresource-integrity": "5.1.0",
|
|
70
|
-
"@modern-js/utils": "2.
|
|
71
|
-
"@modern-js/server": "2.
|
|
70
|
+
"@modern-js/utils": "2.49.0",
|
|
71
|
+
"@modern-js/server": "2.49.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@rsbuild/plugin-swc": "0.6.
|
|
74
|
+
"@rsbuild/plugin-swc": "0.6.3",
|
|
75
75
|
"@types/lodash": "^4.14.202",
|
|
76
76
|
"react": "^18.2.0",
|
|
77
77
|
"react-dom": "^18.2.0",
|
|
78
78
|
"typescript": "^5.3.0",
|
|
79
|
-
"@scripts/
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
79
|
+
"@scripts/vitest-config": "2.49.0",
|
|
80
|
+
"@modern-js/prod-server": "2.49.0",
|
|
81
|
+
"@scripts/build": "2.49.0"
|
|
82
82
|
},
|
|
83
83
|
"publishConfig": {
|
|
84
84
|
"access": "public",
|