@modern-js/server 2.67.3 → 2.67.4
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.
|
@@ -38,17 +38,24 @@ var import_dev = require("./dev");
|
|
|
38
38
|
var import_helpers = require("./helpers");
|
|
39
39
|
async function createDevServer(options, applyPlugins) {
|
|
40
40
|
var _config_output_distPath;
|
|
41
|
-
const { config, pwd, serverConfigFile, serverConfigPath, builder } = options;
|
|
41
|
+
const { config, pwd, serverConfigFile, serverConfigPath, builder, metaName } = options;
|
|
42
42
|
const dev = (0, import_helpers.getDevOptions)(options);
|
|
43
43
|
const distDir = import_node_path.default.resolve(pwd, ((_config_output_distPath = config.output.distPath) === null || _config_output_distPath === void 0 ? void 0 : _config_output_distPath.root) || "dist");
|
|
44
|
-
const serverConfig = await (0, import_node.loadServerRuntimeConfig)(distDir, serverConfigFile, serverConfigPath);
|
|
44
|
+
const serverConfig = await (0, import_node.loadServerRuntimeConfig)(distDir, serverConfigFile, serverConfigPath, metaName) || {};
|
|
45
45
|
const prodServerOptions = {
|
|
46
46
|
...options,
|
|
47
|
-
pwd: distDir
|
|
47
|
+
pwd: distDir,
|
|
48
|
+
serverConfig,
|
|
49
|
+
/**
|
|
50
|
+
* 1. server plugins from modern.server.ts
|
|
51
|
+
* 2. server plugins register by cli use _internalServerPlugins
|
|
52
|
+
* Merge plugins, the plugins from modern.server.ts will run first
|
|
53
|
+
*/
|
|
54
|
+
plugins: [
|
|
55
|
+
...serverConfig.plugins || [],
|
|
56
|
+
...options.plugins || []
|
|
57
|
+
]
|
|
48
58
|
};
|
|
49
|
-
if (serverConfig) {
|
|
50
|
-
prodServerOptions.serverConfig = serverConfig;
|
|
51
|
-
}
|
|
52
59
|
const server = (0, import_server_core.createServerBase)(prodServerOptions);
|
|
53
60
|
const devHttpsOption = typeof dev === "object" && dev.https;
|
|
54
61
|
const isHttp2 = devHttpsOption && typeof dev.proxy === "undefined";
|
|
@@ -63,7 +70,7 @@ async function createDevServer(options, applyPlugins) {
|
|
|
63
70
|
const promise = (0, import_helpers.getDevAssetPrefix)(builder);
|
|
64
71
|
const builderDevServer = await (builder === null || builder === void 0 ? void 0 : builder.createDevServer({
|
|
65
72
|
runCompile: options.runCompile,
|
|
66
|
-
compiler: options.
|
|
73
|
+
compiler: options.compiler
|
|
67
74
|
}));
|
|
68
75
|
server.addPlugins([
|
|
69
76
|
(0, import_dev.devPlugin)({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
|
3
3
|
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
4
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
4
5
|
import { _ as _type_of } from "@swc/helpers/_/_type_of";
|
|
5
6
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
6
7
|
import path from "node:path";
|
|
@@ -13,25 +14,29 @@ function createDevServer(options, applyPlugins) {
|
|
|
13
14
|
}
|
|
14
15
|
function _createDevServer() {
|
|
15
16
|
_createDevServer = _async_to_generator(function(options, applyPlugins) {
|
|
16
|
-
var _config_output_distPath, config, pwd, serverConfigFile, serverConfigPath, builder, dev, distDir, serverConfig, prodServerOptions, server, devHttpsOption, isHttp2, nodeServer, genHttpsOptions, httpsOptions, promise, builderDevServer, assetPrefix, afterListen;
|
|
17
|
+
var _config_output_distPath, config, pwd, serverConfigFile, serverConfigPath, builder, metaName, dev, distDir, serverConfig, prodServerOptions, server, devHttpsOption, isHttp2, nodeServer, genHttpsOptions, httpsOptions, promise, builderDevServer, assetPrefix, afterListen;
|
|
17
18
|
return _ts_generator(this, function(_state) {
|
|
18
19
|
switch (_state.label) {
|
|
19
20
|
case 0:
|
|
20
|
-
config = options.config, pwd = options.pwd, serverConfigFile = options.serverConfigFile, serverConfigPath = options.serverConfigPath, builder = options.builder;
|
|
21
|
+
config = options.config, pwd = options.pwd, serverConfigFile = options.serverConfigFile, serverConfigPath = options.serverConfigPath, builder = options.builder, metaName = options.metaName;
|
|
21
22
|
dev = getDevOptions(options);
|
|
22
23
|
distDir = path.resolve(pwd, ((_config_output_distPath = config.output.distPath) === null || _config_output_distPath === void 0 ? void 0 : _config_output_distPath.root) || "dist");
|
|
23
24
|
return [
|
|
24
25
|
4,
|
|
25
|
-
loadServerRuntimeConfig(distDir, serverConfigFile, serverConfigPath)
|
|
26
|
+
loadServerRuntimeConfig(distDir, serverConfigFile, serverConfigPath, metaName)
|
|
26
27
|
];
|
|
27
28
|
case 1:
|
|
28
|
-
serverConfig = _state.sent();
|
|
29
|
+
serverConfig = _state.sent() || {};
|
|
29
30
|
prodServerOptions = _object_spread_props(_object_spread({}, options), {
|
|
30
|
-
pwd: distDir
|
|
31
|
+
pwd: distDir,
|
|
32
|
+
serverConfig,
|
|
33
|
+
/**
|
|
34
|
+
* 1. server plugins from modern.server.ts
|
|
35
|
+
* 2. server plugins register by cli use _internalServerPlugins
|
|
36
|
+
* Merge plugins, the plugins from modern.server.ts will run first
|
|
37
|
+
*/
|
|
38
|
+
plugins: _to_consumable_array(serverConfig.plugins || []).concat(_to_consumable_array(options.plugins || []))
|
|
31
39
|
});
|
|
32
|
-
if (serverConfig) {
|
|
33
|
-
prodServerOptions.serverConfig = serverConfig;
|
|
34
|
-
}
|
|
35
40
|
server = createServerBase(prodServerOptions);
|
|
36
41
|
devHttpsOption = (typeof dev === "undefined" ? "undefined" : _type_of(dev)) === "object" && dev.https;
|
|
37
42
|
isHttp2 = devHttpsOption && typeof dev.proxy === "undefined";
|
|
@@ -76,7 +81,7 @@ function _createDevServer() {
|
|
|
76
81
|
4,
|
|
77
82
|
builder === null || builder === void 0 ? void 0 : builder.createDevServer({
|
|
78
83
|
runCompile: options.runCompile,
|
|
79
|
-
compiler: options.
|
|
84
|
+
compiler: options.compiler
|
|
80
85
|
})
|
|
81
86
|
];
|
|
82
87
|
case 8:
|
|
@@ -5,17 +5,24 @@ import { devPlugin } from "./dev";
|
|
|
5
5
|
import { getDevAssetPrefix, getDevOptions } from "./helpers";
|
|
6
6
|
async function createDevServer(options, applyPlugins) {
|
|
7
7
|
var _config_output_distPath;
|
|
8
|
-
const { config, pwd, serverConfigFile, serverConfigPath, builder } = options;
|
|
8
|
+
const { config, pwd, serverConfigFile, serverConfigPath, builder, metaName } = options;
|
|
9
9
|
const dev = getDevOptions(options);
|
|
10
10
|
const distDir = path.resolve(pwd, ((_config_output_distPath = config.output.distPath) === null || _config_output_distPath === void 0 ? void 0 : _config_output_distPath.root) || "dist");
|
|
11
|
-
const serverConfig = await loadServerRuntimeConfig(distDir, serverConfigFile, serverConfigPath);
|
|
11
|
+
const serverConfig = await loadServerRuntimeConfig(distDir, serverConfigFile, serverConfigPath, metaName) || {};
|
|
12
12
|
const prodServerOptions = {
|
|
13
13
|
...options,
|
|
14
|
-
pwd: distDir
|
|
14
|
+
pwd: distDir,
|
|
15
|
+
serverConfig,
|
|
16
|
+
/**
|
|
17
|
+
* 1. server plugins from modern.server.ts
|
|
18
|
+
* 2. server plugins register by cli use _internalServerPlugins
|
|
19
|
+
* Merge plugins, the plugins from modern.server.ts will run first
|
|
20
|
+
*/
|
|
21
|
+
plugins: [
|
|
22
|
+
...serverConfig.plugins || [],
|
|
23
|
+
...options.plugins || []
|
|
24
|
+
]
|
|
15
25
|
};
|
|
16
|
-
if (serverConfig) {
|
|
17
|
-
prodServerOptions.serverConfig = serverConfig;
|
|
18
|
-
}
|
|
19
26
|
const server = createServerBase(prodServerOptions);
|
|
20
27
|
const devHttpsOption = typeof dev === "object" && dev.https;
|
|
21
28
|
const isHttp2 = devHttpsOption && typeof dev.proxy === "undefined";
|
|
@@ -30,7 +37,7 @@ async function createDevServer(options, applyPlugins) {
|
|
|
30
37
|
const promise = getDevAssetPrefix(builder);
|
|
31
38
|
const builderDevServer = await (builder === null || builder === void 0 ? void 0 : builder.createDevServer({
|
|
32
39
|
runCompile: options.runCompile,
|
|
33
|
-
compiler: options.
|
|
40
|
+
compiler: options.compiler
|
|
34
41
|
}));
|
|
35
42
|
server.addPlugins([
|
|
36
43
|
devPlugin({
|
package/dist/types/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Server as NodeServer } from 'node:http';
|
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
3
|
import type { DevServerHttpsOptions, DevServerOptions } from '@modern-js/types';
|
|
4
4
|
import type { Rspack, UniBuilderInstance } from '@modern-js/uni-builder';
|
|
5
|
-
import type { ServerBase, ServerBaseOptions } from '@modern-js/server-core';
|
|
5
|
+
import type { ServerBase, ServerBaseOptions, ServerPlugin, ServerPluginLegacy } from '@modern-js/server-core';
|
|
6
6
|
export type { DevServerOptions, DevServerHttpsOptions };
|
|
7
7
|
export type ExtraOptions = {
|
|
8
8
|
dev: Pick<DevServerOptions, 'watch' | 'https'> & {
|
|
@@ -13,11 +13,12 @@ export type ExtraOptions = {
|
|
|
13
13
|
/**
|
|
14
14
|
* The existing compiler can be used here.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
compiler?: Rspack.Compiler | Rspack.MultiCompiler;
|
|
17
17
|
/** compat, the default value is modern.server-runtime.config.ts */
|
|
18
18
|
serverConfigFile?: string;
|
|
19
|
-
serverConfigPath
|
|
19
|
+
serverConfigPath: string;
|
|
20
20
|
builder?: UniBuilderInstance;
|
|
21
|
+
plugins?: (ServerPlugin | ServerPluginLegacy)[];
|
|
21
22
|
};
|
|
22
23
|
export type ModernDevServerOptions<O extends ServerBaseOptions = ServerBaseOptions> = O & ExtraOptions;
|
|
23
|
-
export type ApplyPlugins<O extends ServerBaseOptions = ServerBaseOptions> = (server: ServerBase, options: O
|
|
24
|
+
export type ApplyPlugins<O extends ServerBaseOptions = ServerBaseOptions> = (server: ServerBase, options: ModernDevServerOptions<O>, nodeServer?: NodeServer | Http2SecureServer) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.67.
|
|
18
|
+
"version": "2.67.4",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
"minimatch": "^3.0.4",
|
|
49
49
|
"path-to-regexp": "^6.2.0",
|
|
50
50
|
"ws": "^8.13.0",
|
|
51
|
-
"@modern-js/runtime-utils": "2.67.
|
|
52
|
-
"@modern-js/server-core": "2.67.
|
|
53
|
-
"@modern-js/
|
|
54
|
-
"@modern-js/
|
|
55
|
-
"@modern-js/utils": "2.67.
|
|
51
|
+
"@modern-js/runtime-utils": "2.67.4",
|
|
52
|
+
"@modern-js/server-core": "2.67.4",
|
|
53
|
+
"@modern-js/types": "2.67.4",
|
|
54
|
+
"@modern-js/server-utils": "2.67.4",
|
|
55
|
+
"@modern-js/utils": "2.67.4"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/connect-history-api-fallback": "^1.3.5",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"typescript": "^5",
|
|
68
68
|
"webpack": "^5.98.0",
|
|
69
69
|
"websocket": "^1",
|
|
70
|
-
"@modern-js/uni-builder": "2.67.
|
|
70
|
+
"@modern-js/uni-builder": "2.67.4",
|
|
71
71
|
"@scripts/build": "2.66.0",
|
|
72
72
|
"@scripts/jest-config": "2.66.0"
|
|
73
73
|
},
|