@modern-js/server 2.67.0 → 2.67.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/cjs/createDevServer.js +2 -1
- package/dist/cjs/helpers/devOptions.js +2 -1
- package/dist/esm/createDevServer.js +3 -2
- package/dist/esm/helpers/devOptions.js +2 -1
- package/dist/esm-node/createDevServer.js +2 -1
- package/dist/esm-node/helpers/devOptions.js +2 -1
- package/dist/types/createDevServer.d.ts +2 -2
- package/dist/types/helpers/mock.d.ts +2 -2
- package/dist/types/types.d.ts +2 -1
- package/package.json +7 -7
|
@@ -51,11 +51,12 @@ async function createDevServer(options, applyPlugins) {
|
|
|
51
51
|
}
|
|
52
52
|
const server = (0, import_server_core.createServerBase)(prodServerOptions);
|
|
53
53
|
const devHttpsOption = typeof dev === "object" && dev.https;
|
|
54
|
+
const isHttp2 = devHttpsOption && typeof dev.proxy === "undefined";
|
|
54
55
|
let nodeServer;
|
|
55
56
|
if (devHttpsOption) {
|
|
56
57
|
const { genHttpsOptions } = await Promise.resolve().then(() => __toESM(require("./dev-tools/https")));
|
|
57
58
|
const httpsOptions = await genHttpsOptions(devHttpsOption, pwd);
|
|
58
|
-
nodeServer = await (0, import_node.createNodeServer)(server.handle.bind(server), httpsOptions);
|
|
59
|
+
nodeServer = await (0, import_node.createNodeServer)(server.handle.bind(server), httpsOptions, isHttp2);
|
|
59
60
|
} else {
|
|
60
61
|
nodeServer = await (0, import_node.createNodeServer)(server.handle.bind(server));
|
|
61
62
|
}
|
|
@@ -35,6 +35,7 @@ const getDevAssetPrefix = (builder) => {
|
|
|
35
35
|
return resolve("");
|
|
36
36
|
}
|
|
37
37
|
builder === null || builder === void 0 ? void 0 : builder.onAfterCreateCompiler((params) => {
|
|
38
|
+
var _webCompiler_options_output, _webCompiler_options;
|
|
38
39
|
let webCompiler;
|
|
39
40
|
if ("compilers" in params.compiler) {
|
|
40
41
|
webCompiler = params.compiler.compilers.find((c) => {
|
|
@@ -43,7 +44,7 @@ const getDevAssetPrefix = (builder) => {
|
|
|
43
44
|
} else {
|
|
44
45
|
webCompiler = params.compiler;
|
|
45
46
|
}
|
|
46
|
-
const publicPath = webCompiler.options.output.publicPath;
|
|
47
|
+
const publicPath = webCompiler === null || webCompiler === void 0 ? void 0 : (_webCompiler_options = webCompiler.options) === null || _webCompiler_options === void 0 ? void 0 : (_webCompiler_options_output = _webCompiler_options.output) === null || _webCompiler_options_output === void 0 ? void 0 : _webCompiler_options_output.publicPath;
|
|
47
48
|
if (publicPath && typeof publicPath === "string") {
|
|
48
49
|
const formatPublicPath = publicPath.replace(/^https?:\/\/[^/]+/, "");
|
|
49
50
|
return resolve(formatPublicPath);
|
|
@@ -13,7 +13,7 @@ function createDevServer(options, applyPlugins) {
|
|
|
13
13
|
}
|
|
14
14
|
function _createDevServer() {
|
|
15
15
|
_createDevServer = _async_to_generator(function(options, applyPlugins) {
|
|
16
|
-
var _config_output_distPath, config, pwd, serverConfigFile, serverConfigPath, builder, dev, distDir, serverConfig, prodServerOptions, server, devHttpsOption, nodeServer, genHttpsOptions, httpsOptions, promise, builderDevServer, assetPrefix, afterListen;
|
|
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
17
|
return _ts_generator(this, function(_state) {
|
|
18
18
|
switch (_state.label) {
|
|
19
19
|
case 0:
|
|
@@ -34,6 +34,7 @@ function _createDevServer() {
|
|
|
34
34
|
}
|
|
35
35
|
server = createServerBase(prodServerOptions);
|
|
36
36
|
devHttpsOption = (typeof dev === "undefined" ? "undefined" : _type_of(dev)) === "object" && dev.https;
|
|
37
|
+
isHttp2 = devHttpsOption && typeof dev.proxy === "undefined";
|
|
37
38
|
if (!devHttpsOption)
|
|
38
39
|
return [
|
|
39
40
|
3,
|
|
@@ -53,7 +54,7 @@ function _createDevServer() {
|
|
|
53
54
|
httpsOptions = _state.sent();
|
|
54
55
|
return [
|
|
55
56
|
4,
|
|
56
|
-
createNodeServer(server.handle.bind(server), httpsOptions)
|
|
57
|
+
createNodeServer(server.handle.bind(server), httpsOptions, isHttp2)
|
|
57
58
|
];
|
|
58
59
|
case 4:
|
|
59
60
|
nodeServer = _state.sent();
|
|
@@ -11,6 +11,7 @@ var getDevAssetPrefix = function(builder) {
|
|
|
11
11
|
return resolve("");
|
|
12
12
|
}
|
|
13
13
|
builder === null || builder === void 0 ? void 0 : builder.onAfterCreateCompiler(function(params) {
|
|
14
|
+
var _webCompiler_options_output, _webCompiler_options;
|
|
14
15
|
var webCompiler;
|
|
15
16
|
if ("compilers" in params.compiler) {
|
|
16
17
|
webCompiler = params.compiler.compilers.find(function(c) {
|
|
@@ -19,7 +20,7 @@ var getDevAssetPrefix = function(builder) {
|
|
|
19
20
|
} else {
|
|
20
21
|
webCompiler = params.compiler;
|
|
21
22
|
}
|
|
22
|
-
var publicPath = webCompiler.options.output.publicPath;
|
|
23
|
+
var publicPath = webCompiler === null || webCompiler === void 0 ? void 0 : (_webCompiler_options = webCompiler.options) === null || _webCompiler_options === void 0 ? void 0 : (_webCompiler_options_output = _webCompiler_options.output) === null || _webCompiler_options_output === void 0 ? void 0 : _webCompiler_options_output.publicPath;
|
|
23
24
|
if (publicPath && typeof publicPath === "string") {
|
|
24
25
|
var formatPublicPath = publicPath.replace(/^https?:\/\/[^/]+/, "");
|
|
25
26
|
return resolve(formatPublicPath);
|
|
@@ -18,11 +18,12 @@ async function createDevServer(options, applyPlugins) {
|
|
|
18
18
|
}
|
|
19
19
|
const server = createServerBase(prodServerOptions);
|
|
20
20
|
const devHttpsOption = typeof dev === "object" && dev.https;
|
|
21
|
+
const isHttp2 = devHttpsOption && typeof dev.proxy === "undefined";
|
|
21
22
|
let nodeServer;
|
|
22
23
|
if (devHttpsOption) {
|
|
23
24
|
const { genHttpsOptions } = await import("./dev-tools/https");
|
|
24
25
|
const httpsOptions = await genHttpsOptions(devHttpsOption, pwd);
|
|
25
|
-
nodeServer = await createNodeServer(server.handle.bind(server), httpsOptions);
|
|
26
|
+
nodeServer = await createNodeServer(server.handle.bind(server), httpsOptions, isHttp2);
|
|
26
27
|
} else {
|
|
27
28
|
nodeServer = await createNodeServer(server.handle.bind(server));
|
|
28
29
|
}
|
|
@@ -11,6 +11,7 @@ const getDevAssetPrefix = (builder) => {
|
|
|
11
11
|
return resolve("");
|
|
12
12
|
}
|
|
13
13
|
builder === null || builder === void 0 ? void 0 : builder.onAfterCreateCompiler((params) => {
|
|
14
|
+
var _webCompiler_options_output, _webCompiler_options;
|
|
14
15
|
let webCompiler;
|
|
15
16
|
if ("compilers" in params.compiler) {
|
|
16
17
|
webCompiler = params.compiler.compilers.find((c) => {
|
|
@@ -19,7 +20,7 @@ const getDevAssetPrefix = (builder) => {
|
|
|
19
20
|
} else {
|
|
20
21
|
webCompiler = params.compiler;
|
|
21
22
|
}
|
|
22
|
-
const publicPath = webCompiler.options.output.publicPath;
|
|
23
|
+
const publicPath = webCompiler === null || webCompiler === void 0 ? void 0 : (_webCompiler_options = webCompiler.options) === null || _webCompiler_options === void 0 ? void 0 : (_webCompiler_options_output = _webCompiler_options.output) === null || _webCompiler_options_output === void 0 ? void 0 : _webCompiler_options_output.publicPath;
|
|
23
24
|
if (publicPath && typeof publicPath === "string") {
|
|
24
25
|
const formatPublicPath = publicPath.replace(/^https?:\/\/[^/]+/, "");
|
|
25
26
|
return resolve(formatPublicPath);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ApplyPlugins, ModernDevServerOptions } from './types';
|
|
2
2
|
export declare function createDevServer(options: ModernDevServerOptions, applyPlugins: ApplyPlugins): Promise<{
|
|
3
|
-
server: (import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | import("https").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>) & {
|
|
4
|
-
getRequestListener: () => ReturnType<(handler: import("@modern-js/server-core/dist/types/types").RequestHandler) => (req: import("@modern-js/
|
|
3
|
+
server: (import("http2").Http2SecureServer | import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | import("https").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>) & {
|
|
4
|
+
getRequestListener: () => ReturnType<(handler: import("@modern-js/server-core/dist/types/types").RequestHandler) => (req: import("@modern-js/types").NodeRequest, res: import("@modern-js/types").NodeResponse) => Promise<void>>;
|
|
5
5
|
getRequestHandler: () => import("@modern-js/server-core/dist/types/types").RequestHandler;
|
|
6
6
|
};
|
|
7
7
|
afterListen: () => Promise<void>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
1
|
import { type InternalRequest, type Middleware } from '@modern-js/server-core';
|
|
3
2
|
import type { NextFunction } from '@modern-js/types';
|
|
3
|
+
import type { NodeRequest, NodeResponse } from '@modern-js/types/server';
|
|
4
4
|
/** Types: Mock */
|
|
5
5
|
type MockHandler = {
|
|
6
6
|
data: any;
|
|
7
|
-
} | ((req:
|
|
7
|
+
} | ((req: NodeRequest, res: NodeResponse, next: NextFunction) => Promise<void> | void);
|
|
8
8
|
type MockAPI = {
|
|
9
9
|
method: string;
|
|
10
10
|
path: string;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Server as NodeServer } from 'node:http';
|
|
2
|
+
import type { Http2SecureServer } from 'node:http2';
|
|
2
3
|
import type { DevServerHttpsOptions, DevServerOptions } from '@modern-js/types';
|
|
3
4
|
import type { Rspack, UniBuilderInstance } from '@modern-js/uni-builder';
|
|
4
5
|
import type { ServerBase, ServerBaseOptions } from '@modern-js/server-core';
|
|
@@ -19,4 +20,4 @@ export type ExtraOptions = {
|
|
|
19
20
|
builder?: UniBuilderInstance;
|
|
20
21
|
};
|
|
21
22
|
export type ModernDevServerOptions<O extends ServerBaseOptions = ServerBaseOptions> = O & ExtraOptions;
|
|
22
|
-
export type ApplyPlugins<O extends ServerBaseOptions = ServerBaseOptions> = (server: ServerBase, options: O, nodeServer?: NodeServer) => Promise<void>;
|
|
23
|
+
export type ApplyPlugins<O extends ServerBaseOptions = ServerBaseOptions> = (server: ServerBase, options: 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.1",
|
|
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/
|
|
52
|
-
"@modern-js/
|
|
53
|
-
"@modern-js/server-utils": "2.67.
|
|
54
|
-
"@modern-js/types": "2.67.
|
|
55
|
-
"@modern-js/utils": "2.67.
|
|
51
|
+
"@modern-js/runtime-utils": "2.67.1",
|
|
52
|
+
"@modern-js/server-core": "2.67.1",
|
|
53
|
+
"@modern-js/server-utils": "2.67.1",
|
|
54
|
+
"@modern-js/types": "2.67.1",
|
|
55
|
+
"@modern-js/utils": "2.67.1"
|
|
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.1",
|
|
71
71
|
"@scripts/build": "2.66.0",
|
|
72
72
|
"@scripts/jest-config": "2.66.0"
|
|
73
73
|
},
|