@modern-js/prod-server 2.67.3 → 2.67.5
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/apply.js +2 -0
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/netlify.js +9 -1
- package/dist/esm/apply.js +6 -3
- package/dist/esm/index.js +3 -1
- package/dist/esm/netlify.js +17 -6
- package/dist/esm-node/apply.js +3 -1
- package/dist/esm-node/index.js +5 -1
- package/dist/esm-node/netlify.js +10 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +2 -2
- package/package.json +6 -6
package/dist/cjs/apply.js
CHANGED
|
@@ -48,6 +48,7 @@ async function applyPlugins(serverBase, options, nodeServer) {
|
|
|
48
48
|
return c.html((0, import_server_core.createErrorHtml)(500), 500);
|
|
49
49
|
});
|
|
50
50
|
const loggerOptions = config.server.logger;
|
|
51
|
+
const { middlewares, renderMiddlewares } = options.serverConfig || {};
|
|
51
52
|
const plugins = [
|
|
52
53
|
...nodeServer ? [
|
|
53
54
|
(0, import_node.injectNodeSeverPlugin)({
|
|
@@ -59,6 +60,7 @@ async function applyPlugins(serverBase, options, nodeServer) {
|
|
|
59
60
|
staticGenerate: options.staticGenerate,
|
|
60
61
|
logger: loggerOptions === false ? false : getLogger(loggerOptions)
|
|
61
62
|
}),
|
|
63
|
+
(0, import_server_core.injectConfigMiddlewarePlugin)(middlewares, renderMiddlewares),
|
|
62
64
|
...options.plugins || [],
|
|
63
65
|
(0, import_node.injectResourcePlugin)(),
|
|
64
66
|
(0, import_node.injectRscManifestPlugin)(),
|
package/dist/cjs/index.js
CHANGED
|
@@ -48,9 +48,13 @@ const createProdServer = async (options) => {
|
|
|
48
48
|
if (serverCliConfig) {
|
|
49
49
|
serverBaseOptions.config = serverCliConfig;
|
|
50
50
|
}
|
|
51
|
-
const serverRuntimeConfig = await (0, import_node.loadServerRuntimeConfig)(options.pwd, options.serverConfigFile, options.serverConfigPath);
|
|
51
|
+
const serverRuntimeConfig = await (0, import_node.loadServerRuntimeConfig)(options.pwd, options.serverConfigFile, options.serverConfigPath, options.metaName);
|
|
52
52
|
if (serverRuntimeConfig) {
|
|
53
53
|
serverBaseOptions.serverConfig = serverRuntimeConfig;
|
|
54
|
+
serverBaseOptions.plugins = [
|
|
55
|
+
...serverRuntimeConfig.plugins || [],
|
|
56
|
+
...options.plugins || []
|
|
57
|
+
];
|
|
54
58
|
}
|
|
55
59
|
const server = (0, import_server_core.createServerBase)(serverBaseOptions);
|
|
56
60
|
const nodeServer = await (0, import_node.createNodeServer)(server.handle.bind(server));
|
package/dist/cjs/netlify.js
CHANGED
|
@@ -25,11 +25,19 @@ var import_server_core = require("@modern-js/server-core");
|
|
|
25
25
|
var import_node = require("@modern-js/server-core/node");
|
|
26
26
|
var import_apply = require("./apply");
|
|
27
27
|
const createNetlifyFunction = async (options) => {
|
|
28
|
+
const serverBaseOptions = options;
|
|
28
29
|
const serverCliConfig = (0, import_node.loadServerCliConfig)(options.pwd, options.config);
|
|
29
30
|
if (serverCliConfig) {
|
|
30
31
|
options.config = serverCliConfig;
|
|
31
32
|
}
|
|
32
|
-
const
|
|
33
|
+
const serverRuntimeConfig = await (0, import_node.loadServerRuntimeConfig)(options.pwd, options.serverConfigFile, options.serverConfigPath, options.metaName);
|
|
34
|
+
if (serverRuntimeConfig) {
|
|
35
|
+
serverBaseOptions.plugins = [
|
|
36
|
+
...serverRuntimeConfig.plugins || [],
|
|
37
|
+
...options.plugins || []
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
const server = (0, import_server_core.createServerBase)(serverBaseOptions);
|
|
33
41
|
await (0, import_node.loadServerEnv)(options);
|
|
34
42
|
await (0, import_apply.applyPlugins)(server, options);
|
|
35
43
|
await server.init();
|
package/dist/esm/apply.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
2
|
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
3
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
|
-
import { ErrorDigest, createDefaultPlugins, createErrorHtml, faviconPlugin, onError, renderPlugin } from "@modern-js/server-core";
|
|
4
|
+
import { ErrorDigest, createDefaultPlugins, createErrorHtml, faviconPlugin, injectConfigMiddlewarePlugin, onError, renderPlugin } from "@modern-js/server-core";
|
|
5
5
|
import { injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, loadCacheConfig, serverStaticPlugin } from "@modern-js/server-core/node";
|
|
6
6
|
import { createLogger, isProd } from "@modern-js/utils";
|
|
7
7
|
function getLogger(_) {
|
|
@@ -18,7 +18,7 @@ function applyPlugins(serverBase, options, nodeServer) {
|
|
|
18
18
|
}
|
|
19
19
|
function _applyPlugins() {
|
|
20
20
|
_applyPlugins = _async_to_generator(function(serverBase, options, nodeServer) {
|
|
21
|
-
var pwd, appContext, config, loadCachePwd, cacheConfig, loggerOptions, plugins;
|
|
21
|
+
var pwd, appContext, config, loadCachePwd, cacheConfig, loggerOptions, _ref, middlewares, renderMiddlewares, plugins;
|
|
22
22
|
return _ts_generator(this, function(_state) {
|
|
23
23
|
switch (_state.label) {
|
|
24
24
|
case 0:
|
|
@@ -41,6 +41,7 @@ function _applyPlugins() {
|
|
|
41
41
|
return c.html(createErrorHtml(500), 500);
|
|
42
42
|
});
|
|
43
43
|
loggerOptions = config.server.logger;
|
|
44
|
+
_ref = options.serverConfig || {}, middlewares = _ref.middlewares, renderMiddlewares = _ref.renderMiddlewares;
|
|
44
45
|
plugins = _to_consumable_array(nodeServer ? [
|
|
45
46
|
injectNodeSeverPlugin({
|
|
46
47
|
nodeServer
|
|
@@ -49,7 +50,9 @@ function _applyPlugins() {
|
|
|
49
50
|
cacheConfig,
|
|
50
51
|
staticGenerate: options.staticGenerate,
|
|
51
52
|
logger: loggerOptions === false ? false : getLogger(loggerOptions)
|
|
52
|
-
})),
|
|
53
|
+
})), [
|
|
54
|
+
injectConfigMiddlewarePlugin(middlewares, renderMiddlewares)
|
|
55
|
+
], _to_consumable_array(options.plugins || []), [
|
|
53
56
|
injectResourcePlugin(),
|
|
54
57
|
injectRscManifestPlugin(),
|
|
55
58
|
serverStaticPlugin(),
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
2
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
4
|
import { createServerBase } from "@modern-js/server-core";
|
|
4
5
|
import { createNodeServer, loadServerCliConfig, loadServerEnv, loadServerRuntimeConfig } from "@modern-js/server-core/node";
|
|
@@ -26,12 +27,13 @@ var createProdServer = function() {
|
|
|
26
27
|
}
|
|
27
28
|
return [
|
|
28
29
|
4,
|
|
29
|
-
loadServerRuntimeConfig(options.pwd, options.serverConfigFile, options.serverConfigPath)
|
|
30
|
+
loadServerRuntimeConfig(options.pwd, options.serverConfigFile, options.serverConfigPath, options.metaName)
|
|
30
31
|
];
|
|
31
32
|
case 2:
|
|
32
33
|
serverRuntimeConfig = _state.sent();
|
|
33
34
|
if (serverRuntimeConfig) {
|
|
34
35
|
serverBaseOptions.serverConfig = serverRuntimeConfig;
|
|
36
|
+
serverBaseOptions.plugins = _to_consumable_array(serverRuntimeConfig.plugins || []).concat(_to_consumable_array(options.plugins || []));
|
|
35
37
|
}
|
|
36
38
|
server = createServerBase(serverBaseOptions);
|
|
37
39
|
return [
|
package/dist/esm/netlify.js
CHANGED
|
@@ -1,36 +1,47 @@
|
|
|
1
1
|
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
|
2
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
|
2
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
3
4
|
import { createServerBase } from "@modern-js/server-core";
|
|
4
|
-
import { loadServerCliConfig, loadServerEnv } from "@modern-js/server-core/node";
|
|
5
|
+
import { loadServerCliConfig, loadServerEnv, loadServerRuntimeConfig } from "@modern-js/server-core/node";
|
|
5
6
|
import { applyPlugins } from "./apply";
|
|
6
7
|
var createNetlifyFunction = function() {
|
|
7
8
|
var _ref = _async_to_generator(function(options) {
|
|
8
|
-
var serverCliConfig, server;
|
|
9
|
+
var serverBaseOptions, serverCliConfig, serverRuntimeConfig, server;
|
|
9
10
|
return _ts_generator(this, function(_state) {
|
|
10
11
|
switch (_state.label) {
|
|
11
12
|
case 0:
|
|
13
|
+
serverBaseOptions = options;
|
|
12
14
|
serverCliConfig = loadServerCliConfig(options.pwd, options.config);
|
|
13
15
|
if (serverCliConfig) {
|
|
14
16
|
options.config = serverCliConfig;
|
|
15
17
|
}
|
|
16
|
-
server = createServerBase(options);
|
|
17
18
|
return [
|
|
18
19
|
4,
|
|
19
|
-
|
|
20
|
+
loadServerRuntimeConfig(options.pwd, options.serverConfigFile, options.serverConfigPath, options.metaName)
|
|
20
21
|
];
|
|
21
22
|
case 1:
|
|
23
|
+
serverRuntimeConfig = _state.sent();
|
|
24
|
+
if (serverRuntimeConfig) {
|
|
25
|
+
serverBaseOptions.plugins = _to_consumable_array(serverRuntimeConfig.plugins || []).concat(_to_consumable_array(options.plugins || []));
|
|
26
|
+
}
|
|
27
|
+
server = createServerBase(serverBaseOptions);
|
|
28
|
+
return [
|
|
29
|
+
4,
|
|
30
|
+
loadServerEnv(options)
|
|
31
|
+
];
|
|
32
|
+
case 2:
|
|
22
33
|
_state.sent();
|
|
23
34
|
return [
|
|
24
35
|
4,
|
|
25
36
|
applyPlugins(server, options)
|
|
26
37
|
];
|
|
27
|
-
case
|
|
38
|
+
case 3:
|
|
28
39
|
_state.sent();
|
|
29
40
|
return [
|
|
30
41
|
4,
|
|
31
42
|
server.init()
|
|
32
43
|
];
|
|
33
|
-
case
|
|
44
|
+
case 4:
|
|
34
45
|
_state.sent();
|
|
35
46
|
return [
|
|
36
47
|
2,
|
package/dist/esm-node/apply.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorDigest, createDefaultPlugins, createErrorHtml, faviconPlugin, onError, renderPlugin } from "@modern-js/server-core";
|
|
1
|
+
import { ErrorDigest, createDefaultPlugins, createErrorHtml, faviconPlugin, injectConfigMiddlewarePlugin, onError, renderPlugin } from "@modern-js/server-core";
|
|
2
2
|
import { injectNodeSeverPlugin, injectResourcePlugin, injectRscManifestPlugin, loadCacheConfig, serverStaticPlugin } from "@modern-js/server-core/node";
|
|
3
3
|
import { createLogger, isProd } from "@modern-js/utils";
|
|
4
4
|
function getLogger(_) {
|
|
@@ -25,6 +25,7 @@ async function applyPlugins(serverBase, options, nodeServer) {
|
|
|
25
25
|
return c.html(createErrorHtml(500), 500);
|
|
26
26
|
});
|
|
27
27
|
const loggerOptions = config.server.logger;
|
|
28
|
+
const { middlewares, renderMiddlewares } = options.serverConfig || {};
|
|
28
29
|
const plugins = [
|
|
29
30
|
...nodeServer ? [
|
|
30
31
|
injectNodeSeverPlugin({
|
|
@@ -36,6 +37,7 @@ async function applyPlugins(serverBase, options, nodeServer) {
|
|
|
36
37
|
staticGenerate: options.staticGenerate,
|
|
37
38
|
logger: loggerOptions === false ? false : getLogger(loggerOptions)
|
|
38
39
|
}),
|
|
40
|
+
injectConfigMiddlewarePlugin(middlewares, renderMiddlewares),
|
|
39
41
|
...options.plugins || [],
|
|
40
42
|
injectResourcePlugin(),
|
|
41
43
|
injectRscManifestPlugin(),
|
package/dist/esm-node/index.js
CHANGED
|
@@ -12,9 +12,13 @@ const createProdServer = async (options) => {
|
|
|
12
12
|
if (serverCliConfig) {
|
|
13
13
|
serverBaseOptions.config = serverCliConfig;
|
|
14
14
|
}
|
|
15
|
-
const serverRuntimeConfig = await loadServerRuntimeConfig(options.pwd, options.serverConfigFile, options.serverConfigPath);
|
|
15
|
+
const serverRuntimeConfig = await loadServerRuntimeConfig(options.pwd, options.serverConfigFile, options.serverConfigPath, options.metaName);
|
|
16
16
|
if (serverRuntimeConfig) {
|
|
17
17
|
serverBaseOptions.serverConfig = serverRuntimeConfig;
|
|
18
|
+
serverBaseOptions.plugins = [
|
|
19
|
+
...serverRuntimeConfig.plugins || [],
|
|
20
|
+
...options.plugins || []
|
|
21
|
+
];
|
|
18
22
|
}
|
|
19
23
|
const server = createServerBase(serverBaseOptions);
|
|
20
24
|
const nodeServer = await createNodeServer(server.handle.bind(server));
|
package/dist/esm-node/netlify.js
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { createServerBase } from "@modern-js/server-core";
|
|
2
|
-
import { loadServerCliConfig, loadServerEnv } from "@modern-js/server-core/node";
|
|
2
|
+
import { loadServerCliConfig, loadServerEnv, loadServerRuntimeConfig } from "@modern-js/server-core/node";
|
|
3
3
|
import { applyPlugins } from "./apply";
|
|
4
4
|
const createNetlifyFunction = async (options) => {
|
|
5
|
+
const serverBaseOptions = options;
|
|
5
6
|
const serverCliConfig = loadServerCliConfig(options.pwd, options.config);
|
|
6
7
|
if (serverCliConfig) {
|
|
7
8
|
options.config = serverCliConfig;
|
|
8
9
|
}
|
|
9
|
-
const
|
|
10
|
+
const serverRuntimeConfig = await loadServerRuntimeConfig(options.pwd, options.serverConfigFile, options.serverConfigPath, options.metaName);
|
|
11
|
+
if (serverRuntimeConfig) {
|
|
12
|
+
serverBaseOptions.plugins = [
|
|
13
|
+
...serverRuntimeConfig.plugins || [],
|
|
14
|
+
...options.plugins || []
|
|
15
|
+
];
|
|
16
|
+
}
|
|
17
|
+
const server = createServerBase(serverBaseOptions);
|
|
10
18
|
await loadServerEnv(options);
|
|
11
19
|
await applyPlugins(server, options);
|
|
12
20
|
await server.init();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ export { loadServerPlugins, loadServerRuntimeConfig, } from '@modern-js/server-c
|
|
|
7
7
|
export type { ServerPluginLegacy, ServerPlugin } from '@modern-js/server-core';
|
|
8
8
|
export type { ProdServerOptions, BaseEnv } from './types';
|
|
9
9
|
export declare const createProdServer: (options: ProdServerOptions) => Promise<(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>) & {
|
|
10
|
-
getRequestListener: () => (req:
|
|
10
|
+
getRequestListener: () => (req: import("@modern-js/types").NodeRequest, res: import("@modern-js/types").NodeResponse) => Promise<void>;
|
|
11
11
|
getRequestHandler: () => import("@modern-js/server-core/dist/types/types").RequestHandler;
|
|
12
12
|
}>;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -4,10 +4,10 @@ import type { Logger } from '@modern-js/utils';
|
|
|
4
4
|
interface ProdServerExtraOptions {
|
|
5
5
|
/** compat modern.server-runtime.config.ts */
|
|
6
6
|
serverConfigFile?: string;
|
|
7
|
-
serverConfigPath
|
|
7
|
+
serverConfigPath: string;
|
|
8
8
|
plugins?: (ServerPlugin | ServerPluginLegacy)[];
|
|
9
9
|
}
|
|
10
|
-
export type ProdServerOptions =
|
|
10
|
+
export type ProdServerOptions = ServerBaseOptions & ProdServerExtraOptions & CreateDefaultPluginsOptions;
|
|
11
11
|
export type BaseEnv = {
|
|
12
12
|
Variables: {
|
|
13
13
|
logger: Logger;
|
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.5",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@swc/helpers": "0.5.
|
|
43
|
+
"@swc/helpers": "^0.5.17",
|
|
44
44
|
"source-map-support": "0.5.21",
|
|
45
|
-
"@modern-js/runtime-utils": "2.67.
|
|
46
|
-
"@modern-js/
|
|
47
|
-
"@modern-js/
|
|
45
|
+
"@modern-js/runtime-utils": "2.67.5",
|
|
46
|
+
"@modern-js/server-core": "2.67.5",
|
|
47
|
+
"@modern-js/utils": "2.67.5"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/jest": "^29",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"lint-staged": "~13.3.0",
|
|
56
56
|
"tsx": "^3.12.7",
|
|
57
57
|
"typescript": "~5.0.4",
|
|
58
|
-
"@modern-js/types": "2.67.
|
|
58
|
+
"@modern-js/types": "2.67.5",
|
|
59
59
|
"@scripts/build": "2.66.0",
|
|
60
60
|
"@scripts/jest-config": "2.66.0"
|
|
61
61
|
},
|