@modern-js/server 2.65.4 → 2.66.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/cjs/createDevServer.js +5 -0
- package/dist/cjs/dev.js +2 -2
- package/dist/cjs/helpers/devOptions.js +25 -0
- package/dist/cjs/helpers/index.js +2 -2
- package/dist/cjs/helpers/mock.js +1 -1
- package/dist/cjs/helpers/repack.js +2 -2
- package/dist/esm/createDevServer.js +14 -4
- package/dist/esm/dev.js +3 -3
- package/dist/esm/helpers/devOptions.js +24 -0
- package/dist/esm/helpers/index.js +3 -3
- package/dist/esm/helpers/mock.js +2 -2
- package/dist/esm/helpers/repack.js +2 -2
- package/dist/esm-node/createDevServer.js +6 -1
- package/dist/esm-node/dev.js +2 -2
- package/dist/esm-node/helpers/devOptions.js +24 -0
- package/dist/esm-node/helpers/index.js +2 -2
- package/dist/esm-node/helpers/mock.js +2 -2
- package/dist/esm-node/helpers/repack.js +2 -2
- package/dist/types/createDevServer.d.ts +1 -3
- package/dist/types/dev-tools/https/index.d.ts +0 -2
- package/dist/types/dev-tools/watcher/dependencyTree.d.ts +0 -1
- package/dist/types/dev.d.ts +2 -2
- package/dist/types/helpers/devOptions.d.ts +4 -2
- package/dist/types/helpers/mock.d.ts +0 -1
- package/dist/types/helpers/repack.d.ts +2 -2
- package/dist/types/types.d.ts +2 -2
- package/package.json +10 -11
|
@@ -59,6 +59,7 @@ async function createDevServer(options, applyPlugins) {
|
|
|
59
59
|
} else {
|
|
60
60
|
nodeServer = await (0, import_node.createNodeServer)(server.handle.bind(server));
|
|
61
61
|
}
|
|
62
|
+
const promise = (0, import_helpers.getDevAssetPrefix)(builder);
|
|
62
63
|
const builderDevServer = await (builder === null || builder === void 0 ? void 0 : builder.createDevServer({
|
|
63
64
|
runCompile: options.runCompile,
|
|
64
65
|
compiler: options.compilier
|
|
@@ -69,6 +70,10 @@ async function createDevServer(options, applyPlugins) {
|
|
|
69
70
|
builderDevServer
|
|
70
71
|
})
|
|
71
72
|
]);
|
|
73
|
+
const assetPrefix = await promise;
|
|
74
|
+
if (assetPrefix) {
|
|
75
|
+
prodServerOptions.config.output.assetPrefix = assetPrefix;
|
|
76
|
+
}
|
|
72
77
|
await applyPlugins(server, prodServerOptions, nodeServer);
|
|
73
78
|
await server.init();
|
|
74
79
|
const afterListen = async () => {
|
package/dist/cjs/dev.js
CHANGED
|
@@ -39,12 +39,12 @@ const devPlugin = (options) => ({
|
|
|
39
39
|
connectWebSocket && nodeServer && connectWebSocket({
|
|
40
40
|
server: nodeServer
|
|
41
41
|
});
|
|
42
|
-
const
|
|
42
|
+
const hooks = api.getHooks();
|
|
43
43
|
builder === null || builder === void 0 ? void 0 : builder.onDevCompileDone(({ stats }) => {
|
|
44
44
|
if (stats.toJson({
|
|
45
45
|
all: false
|
|
46
46
|
}).name !== "server") {
|
|
47
|
-
(0, import_helpers.onRepack)(distDirectory,
|
|
47
|
+
(0, import_helpers.onRepack)(distDirectory, hooks);
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
50
|
if (dev.watch) {
|
|
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var devOptions_exports = {};
|
|
20
20
|
__export(devOptions_exports, {
|
|
21
|
+
getDevAssetPrefix: () => getDevAssetPrefix,
|
|
21
22
|
getDevOptions: () => getDevOptions
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(devOptions_exports);
|
|
@@ -28,7 +29,31 @@ const getDevOptions = (options) => {
|
|
|
28
29
|
const defaultOptions = (0, import_constants.getDefaultDevOptions)();
|
|
29
30
|
return (0, import_lodash.merge)(defaultOptions, devOptions);
|
|
30
31
|
};
|
|
32
|
+
const getDevAssetPrefix = (builder) => {
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
if (!builder) {
|
|
35
|
+
return resolve("");
|
|
36
|
+
}
|
|
37
|
+
builder === null || builder === void 0 ? void 0 : builder.onAfterCreateCompiler((params) => {
|
|
38
|
+
let webCompiler;
|
|
39
|
+
if ("compilers" in params.compiler) {
|
|
40
|
+
webCompiler = params.compiler.compilers.find((c) => {
|
|
41
|
+
return c.name === "web" || c.name === "client";
|
|
42
|
+
});
|
|
43
|
+
} else {
|
|
44
|
+
webCompiler = params.compiler;
|
|
45
|
+
}
|
|
46
|
+
const publicPath = webCompiler.options.output.publicPath;
|
|
47
|
+
if (publicPath && typeof publicPath === "string") {
|
|
48
|
+
const formatPublicPath = publicPath.replace(/^https?:\/\/[^/]+/, "");
|
|
49
|
+
return resolve(formatPublicPath);
|
|
50
|
+
}
|
|
51
|
+
return resolve("");
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
31
55
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
56
|
0 && (module.exports = {
|
|
57
|
+
getDevAssetPrefix,
|
|
33
58
|
getDevOptions
|
|
34
59
|
});
|
|
@@ -45,7 +45,7 @@ __reExport(helpers_exports, require("./mock"), module.exports);
|
|
|
45
45
|
async function onServerChange({ pwd, filepath, event, server }) {
|
|
46
46
|
const { mock } = import_server_core.AGGRED_DIR;
|
|
47
47
|
const mockPath = import_path.default.normalize(import_path.default.join(pwd, mock));
|
|
48
|
-
const {
|
|
48
|
+
const { hooks } = server;
|
|
49
49
|
if (filepath.startsWith(mockPath)) {
|
|
50
50
|
await (0, import_mock.initOrUpdateMockMiddlewares)(pwd);
|
|
51
51
|
import_utils.logger.info("Finish update the mock handlers");
|
|
@@ -60,7 +60,7 @@ async function onServerChange({ pwd, filepath, event, server }) {
|
|
|
60
60
|
}
|
|
61
61
|
]
|
|
62
62
|
};
|
|
63
|
-
await
|
|
63
|
+
await hooks.onReset.call({
|
|
64
64
|
event: fileChangeEvent
|
|
65
65
|
});
|
|
66
66
|
(0, import_utils2.debug)(`Finish reload server, trigger by ${filepath} ${event}`);
|
package/dist/cjs/helpers/mock.js
CHANGED
|
@@ -123,7 +123,7 @@ async function getMockMiddleware(pwd) {
|
|
|
123
123
|
if (matchedMockAPI) {
|
|
124
124
|
const { handler } = matchedMockAPI;
|
|
125
125
|
if (typeof handler === "function") {
|
|
126
|
-
return await (0, import_node.
|
|
126
|
+
return await (0, import_node.connectMockMid2HonoMid)(handler)(c, next);
|
|
127
127
|
} else {
|
|
128
128
|
return c.json(handler);
|
|
129
129
|
}
|
|
@@ -29,10 +29,10 @@ const cleanSSRCache = (distDir) => {
|
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
|
-
const onRepack = (distDir,
|
|
32
|
+
const onRepack = (distDir, hooks) => {
|
|
33
33
|
cleanSSRCache(distDir);
|
|
34
34
|
import_fileReader.fileReader.reset();
|
|
35
|
-
|
|
35
|
+
hooks.onReset.call({
|
|
36
36
|
event: {
|
|
37
37
|
type: "repack"
|
|
38
38
|
}
|
|
@@ -7,13 +7,13 @@ import path from "node:path";
|
|
|
7
7
|
import { createServerBase } from "@modern-js/server-core";
|
|
8
8
|
import { createNodeServer, loadServerRuntimeConfig } from "@modern-js/server-core/node";
|
|
9
9
|
import { devPlugin } from "./dev";
|
|
10
|
-
import { getDevOptions } from "./helpers";
|
|
10
|
+
import { getDevAssetPrefix, getDevOptions } from "./helpers";
|
|
11
11
|
function createDevServer(options, applyPlugins) {
|
|
12
12
|
return _createDevServer.apply(this, arguments);
|
|
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, builderDevServer, afterListen;
|
|
16
|
+
var _config_output_distPath, config, pwd, serverConfigFile, serverConfigPath, builder, dev, distDir, serverConfig, prodServerOptions, server, devHttpsOption, nodeServer, genHttpsOptions, httpsOptions, promise, builderDevServer, assetPrefix, afterListen;
|
|
17
17
|
return _ts_generator(this, function(_state) {
|
|
18
18
|
switch (_state.label) {
|
|
19
19
|
case 0:
|
|
@@ -70,6 +70,7 @@ function _createDevServer() {
|
|
|
70
70
|
nodeServer = _state.sent();
|
|
71
71
|
_state.label = 7;
|
|
72
72
|
case 7:
|
|
73
|
+
promise = getDevAssetPrefix(builder);
|
|
73
74
|
return [
|
|
74
75
|
4,
|
|
75
76
|
builder === null || builder === void 0 ? void 0 : builder.createDevServer({
|
|
@@ -86,15 +87,24 @@ function _createDevServer() {
|
|
|
86
87
|
]);
|
|
87
88
|
return [
|
|
88
89
|
4,
|
|
89
|
-
|
|
90
|
+
promise
|
|
90
91
|
];
|
|
91
92
|
case 9:
|
|
93
|
+
assetPrefix = _state.sent();
|
|
94
|
+
if (assetPrefix) {
|
|
95
|
+
prodServerOptions.config.output.assetPrefix = assetPrefix;
|
|
96
|
+
}
|
|
97
|
+
return [
|
|
98
|
+
4,
|
|
99
|
+
applyPlugins(server, prodServerOptions, nodeServer)
|
|
100
|
+
];
|
|
101
|
+
case 10:
|
|
92
102
|
_state.sent();
|
|
93
103
|
return [
|
|
94
104
|
4,
|
|
95
105
|
server.init()
|
|
96
106
|
];
|
|
97
|
-
case
|
|
107
|
+
case 11:
|
|
98
108
|
_state.sent();
|
|
99
109
|
afterListen = function() {
|
|
100
110
|
var _ref = _async_to_generator(function() {
|
package/dist/esm/dev.js
CHANGED
|
@@ -14,7 +14,7 @@ var devPlugin = function(options) {
|
|
|
14
14
|
return {
|
|
15
15
|
prepare: function prepare() {
|
|
16
16
|
return _async_to_generator(function() {
|
|
17
|
-
var _dev_after, _dev_before, _ref, builderMiddlewares, close, connectWebSocket, _api_useAppContext, middlewares, distDirectory, nodeServer, apiDirectory, sharedDirectory, serverBase,
|
|
17
|
+
var _dev_after, _dev_before, _ref, builderMiddlewares, close, connectWebSocket, _api_useAppContext, middlewares, distDirectory, nodeServer, apiDirectory, sharedDirectory, serverBase, hooks, watchOptions, watcher, before, after, _dev_setupMiddlewares, setupMiddlewares, mockMiddleware;
|
|
18
18
|
return _ts_generator(this, function(_state) {
|
|
19
19
|
switch (_state.label) {
|
|
20
20
|
case 0:
|
|
@@ -24,13 +24,13 @@ var devPlugin = function(options) {
|
|
|
24
24
|
connectWebSocket && nodeServer && connectWebSocket({
|
|
25
25
|
server: nodeServer
|
|
26
26
|
});
|
|
27
|
-
|
|
27
|
+
hooks = api.getHooks();
|
|
28
28
|
builder === null || builder === void 0 ? void 0 : builder.onDevCompileDone(function(param) {
|
|
29
29
|
var stats = param.stats;
|
|
30
30
|
if (stats.toJson({
|
|
31
31
|
all: false
|
|
32
32
|
}).name !== "server") {
|
|
33
|
-
onRepack(distDirectory,
|
|
33
|
+
onRepack(distDirectory, hooks);
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
if (dev.watch) {
|
|
@@ -5,6 +5,30 @@ var getDevOptions = function(options) {
|
|
|
5
5
|
var defaultOptions = getDefaultDevOptions();
|
|
6
6
|
return merge(defaultOptions, devOptions);
|
|
7
7
|
};
|
|
8
|
+
var getDevAssetPrefix = function(builder) {
|
|
9
|
+
return new Promise(function(resolve) {
|
|
10
|
+
if (!builder) {
|
|
11
|
+
return resolve("");
|
|
12
|
+
}
|
|
13
|
+
builder === null || builder === void 0 ? void 0 : builder.onAfterCreateCompiler(function(params) {
|
|
14
|
+
var webCompiler;
|
|
15
|
+
if ("compilers" in params.compiler) {
|
|
16
|
+
webCompiler = params.compiler.compilers.find(function(c) {
|
|
17
|
+
return c.name === "web" || c.name === "client";
|
|
18
|
+
});
|
|
19
|
+
} else {
|
|
20
|
+
webCompiler = params.compiler;
|
|
21
|
+
}
|
|
22
|
+
var publicPath = webCompiler.options.output.publicPath;
|
|
23
|
+
if (publicPath && typeof publicPath === "string") {
|
|
24
|
+
var formatPublicPath = publicPath.replace(/^https?:\/\/[^/]+/, "");
|
|
25
|
+
return resolve(formatPublicPath);
|
|
26
|
+
}
|
|
27
|
+
return resolve("");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
};
|
|
8
31
|
export {
|
|
32
|
+
getDevAssetPrefix,
|
|
9
33
|
getDevOptions
|
|
10
34
|
};
|
|
@@ -15,14 +15,14 @@ function onServerChange(_) {
|
|
|
15
15
|
}
|
|
16
16
|
function _onServerChange() {
|
|
17
17
|
_onServerChange = _async_to_generator(function(param) {
|
|
18
|
-
var pwd, filepath, event, server, mock, mockPath,
|
|
18
|
+
var pwd, filepath, event, server, mock, mockPath, hooks, fileChangeEvent, e;
|
|
19
19
|
return _ts_generator(this, function(_state) {
|
|
20
20
|
switch (_state.label) {
|
|
21
21
|
case 0:
|
|
22
22
|
pwd = param.pwd, filepath = param.filepath, event = param.event, server = param.server;
|
|
23
23
|
mock = AGGRED_DIR.mock;
|
|
24
24
|
mockPath = path.normalize(path.join(pwd, mock));
|
|
25
|
-
|
|
25
|
+
hooks = server.hooks;
|
|
26
26
|
if (!filepath.startsWith(mockPath))
|
|
27
27
|
return [
|
|
28
28
|
3,
|
|
@@ -57,7 +57,7 @@ function _onServerChange() {
|
|
|
57
57
|
};
|
|
58
58
|
return [
|
|
59
59
|
4,
|
|
60
|
-
|
|
60
|
+
hooks.onReset.call({
|
|
61
61
|
event: fileChangeEvent
|
|
62
62
|
})
|
|
63
63
|
];
|
package/dist/esm/helpers/mock.js
CHANGED
|
@@ -3,7 +3,7 @@ import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array";
|
|
|
3
3
|
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { AGGRED_DIR } from "@modern-js/server-core";
|
|
6
|
-
import {
|
|
6
|
+
import { connectMockMid2HonoMid } from "@modern-js/server-core/node";
|
|
7
7
|
import { fs } from "@modern-js/utils";
|
|
8
8
|
import { match } from "path-to-regexp";
|
|
9
9
|
var mockAPIs = [];
|
|
@@ -226,7 +226,7 @@ function _getMockMiddleware() {
|
|
|
226
226
|
];
|
|
227
227
|
return [
|
|
228
228
|
4,
|
|
229
|
-
|
|
229
|
+
connectMockMid2HonoMid(handler)(c, next)
|
|
230
230
|
];
|
|
231
231
|
case 1:
|
|
232
232
|
return [
|
|
@@ -6,10 +6,10 @@ var cleanSSRCache = function(distDir) {
|
|
|
6
6
|
}
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
|
-
var onRepack = function(distDir,
|
|
9
|
+
var onRepack = function(distDir, hooks) {
|
|
10
10
|
cleanSSRCache(distDir);
|
|
11
11
|
fileReader.reset();
|
|
12
|
-
|
|
12
|
+
hooks.onReset.call({
|
|
13
13
|
event: {
|
|
14
14
|
type: "repack"
|
|
15
15
|
}
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { createServerBase } from "@modern-js/server-core";
|
|
3
3
|
import { createNodeServer, loadServerRuntimeConfig } from "@modern-js/server-core/node";
|
|
4
4
|
import { devPlugin } from "./dev";
|
|
5
|
-
import { getDevOptions } from "./helpers";
|
|
5
|
+
import { getDevAssetPrefix, getDevOptions } from "./helpers";
|
|
6
6
|
async function createDevServer(options, applyPlugins) {
|
|
7
7
|
var _config_output_distPath;
|
|
8
8
|
const { config, pwd, serverConfigFile, serverConfigPath, builder } = options;
|
|
@@ -26,6 +26,7 @@ async function createDevServer(options, applyPlugins) {
|
|
|
26
26
|
} else {
|
|
27
27
|
nodeServer = await createNodeServer(server.handle.bind(server));
|
|
28
28
|
}
|
|
29
|
+
const promise = getDevAssetPrefix(builder);
|
|
29
30
|
const builderDevServer = await (builder === null || builder === void 0 ? void 0 : builder.createDevServer({
|
|
30
31
|
runCompile: options.runCompile,
|
|
31
32
|
compiler: options.compilier
|
|
@@ -36,6 +37,10 @@ async function createDevServer(options, applyPlugins) {
|
|
|
36
37
|
builderDevServer
|
|
37
38
|
})
|
|
38
39
|
]);
|
|
40
|
+
const assetPrefix = await promise;
|
|
41
|
+
if (assetPrefix) {
|
|
42
|
+
prodServerOptions.config.output.assetPrefix = assetPrefix;
|
|
43
|
+
}
|
|
39
44
|
await applyPlugins(server, prodServerOptions, nodeServer);
|
|
40
45
|
await server.init();
|
|
41
46
|
const afterListen = async () => {
|
package/dist/esm-node/dev.js
CHANGED
|
@@ -16,12 +16,12 @@ const devPlugin = (options) => ({
|
|
|
16
16
|
connectWebSocket && nodeServer && connectWebSocket({
|
|
17
17
|
server: nodeServer
|
|
18
18
|
});
|
|
19
|
-
const
|
|
19
|
+
const hooks = api.getHooks();
|
|
20
20
|
builder === null || builder === void 0 ? void 0 : builder.onDevCompileDone(({ stats }) => {
|
|
21
21
|
if (stats.toJson({
|
|
22
22
|
all: false
|
|
23
23
|
}).name !== "server") {
|
|
24
|
-
onRepack(distDirectory,
|
|
24
|
+
onRepack(distDirectory, hooks);
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
if (dev.watch) {
|
|
@@ -5,6 +5,30 @@ const getDevOptions = (options) => {
|
|
|
5
5
|
const defaultOptions = getDefaultDevOptions();
|
|
6
6
|
return merge(defaultOptions, devOptions);
|
|
7
7
|
};
|
|
8
|
+
const getDevAssetPrefix = (builder) => {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
if (!builder) {
|
|
11
|
+
return resolve("");
|
|
12
|
+
}
|
|
13
|
+
builder === null || builder === void 0 ? void 0 : builder.onAfterCreateCompiler((params) => {
|
|
14
|
+
let webCompiler;
|
|
15
|
+
if ("compilers" in params.compiler) {
|
|
16
|
+
webCompiler = params.compiler.compilers.find((c) => {
|
|
17
|
+
return c.name === "web" || c.name === "client";
|
|
18
|
+
});
|
|
19
|
+
} else {
|
|
20
|
+
webCompiler = params.compiler;
|
|
21
|
+
}
|
|
22
|
+
const publicPath = webCompiler.options.output.publicPath;
|
|
23
|
+
if (publicPath && typeof publicPath === "string") {
|
|
24
|
+
const formatPublicPath = publicPath.replace(/^https?:\/\/[^/]+/, "");
|
|
25
|
+
return resolve(formatPublicPath);
|
|
26
|
+
}
|
|
27
|
+
return resolve("");
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
};
|
|
8
31
|
export {
|
|
32
|
+
getDevAssetPrefix,
|
|
9
33
|
getDevOptions
|
|
10
34
|
};
|
|
@@ -11,7 +11,7 @@ export * from "./mock";
|
|
|
11
11
|
async function onServerChange({ pwd, filepath, event, server }) {
|
|
12
12
|
const { mock } = AGGRED_DIR;
|
|
13
13
|
const mockPath = path.normalize(path.join(pwd, mock));
|
|
14
|
-
const {
|
|
14
|
+
const { hooks } = server;
|
|
15
15
|
if (filepath.startsWith(mockPath)) {
|
|
16
16
|
await initOrUpdateMockMiddlewares(pwd);
|
|
17
17
|
logger.info("Finish update the mock handlers");
|
|
@@ -26,7 +26,7 @@ async function onServerChange({ pwd, filepath, event, server }) {
|
|
|
26
26
|
}
|
|
27
27
|
]
|
|
28
28
|
};
|
|
29
|
-
await
|
|
29
|
+
await hooks.onReset.call({
|
|
30
30
|
event: fileChangeEvent
|
|
31
31
|
});
|
|
32
32
|
debug(`Finish reload server, trigger by ${filepath} ${event}`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import { AGGRED_DIR } from "@modern-js/server-core";
|
|
3
|
-
import {
|
|
3
|
+
import { connectMockMid2HonoMid } from "@modern-js/server-core/node";
|
|
4
4
|
import { fs } from "@modern-js/utils";
|
|
5
5
|
import { match } from "path-to-regexp";
|
|
6
6
|
let mockAPIs = [];
|
|
@@ -88,7 +88,7 @@ async function getMockMiddleware(pwd) {
|
|
|
88
88
|
if (matchedMockAPI) {
|
|
89
89
|
const { handler } = matchedMockAPI;
|
|
90
90
|
if (typeof handler === "function") {
|
|
91
|
-
return await
|
|
91
|
+
return await connectMockMid2HonoMid(handler)(c, next);
|
|
92
92
|
} else {
|
|
93
93
|
return c.json(handler);
|
|
94
94
|
}
|
|
@@ -6,10 +6,10 @@ const cleanSSRCache = (distDir) => {
|
|
|
6
6
|
}
|
|
7
7
|
});
|
|
8
8
|
};
|
|
9
|
-
const onRepack = (distDir,
|
|
9
|
+
const onRepack = (distDir, hooks) => {
|
|
10
10
|
cleanSSRCache(distDir);
|
|
11
11
|
fileReader.reset();
|
|
12
|
-
|
|
12
|
+
hooks.onReset.call({
|
|
13
13
|
event: {
|
|
14
14
|
type: "repack"
|
|
15
15
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
import type { ApplyPlugins, ModernDevServerOptions } from './types';
|
|
4
2
|
export declare function createDevServer(options: ModernDevServerOptions, applyPlugins: ApplyPlugins): Promise<{
|
|
5
3
|
server: (import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse> | import("https").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>) & {
|
|
6
|
-
getRequestListener: () => (req: import("
|
|
4
|
+
getRequestListener: () => ReturnType<(handler: import("@modern-js/server-core/dist/types/types").RequestHandler) => (req: import("@modern-js/server-core/dist/types/types").NodeRequest, res: import("@modern-js/server-core/dist/types/types").NodeResponse) => Promise<void>>;
|
|
7
5
|
getRequestHandler: () => import("@modern-js/server-core/dist/types/types").RequestHandler;
|
|
8
6
|
};
|
|
9
7
|
afterListen: () => Promise<void>;
|
package/dist/types/dev.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ServerBaseOptions,
|
|
1
|
+
import type { ServerBaseOptions, ServerPluginLegacy } from '@modern-js/server-core';
|
|
2
2
|
import type { UniBuilderInstance } from '@modern-js/uni-builder';
|
|
3
3
|
import type { ModernDevServerOptions } from './types';
|
|
4
4
|
type BuilderDevServer = Awaited<ReturnType<UniBuilderInstance['createDevServer']>>;
|
|
5
5
|
export type DevPluginOptions = ModernDevServerOptions<ServerBaseOptions> & {
|
|
6
6
|
builderDevServer?: BuilderDevServer;
|
|
7
7
|
};
|
|
8
|
-
export declare const devPlugin: (options: DevPluginOptions) =>
|
|
8
|
+
export declare const devPlugin: (options: DevPluginOptions) => ServerPluginLegacy;
|
|
9
9
|
export {};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import type { UniBuilderInstance } from '@modern-js/uni-builder';
|
|
1
2
|
import type { ModernDevServerOptions } from '../types';
|
|
2
3
|
export declare const getDevOptions: (options: ModernDevServerOptions) => import("@modern-js/types/server/devServer").DevServerOptions & Pick<import("@modern-js/types/server/devServer").DevServerOptions, "watch" | "https"> & {
|
|
3
|
-
port?: number
|
|
4
|
-
host?: string
|
|
4
|
+
port?: number;
|
|
5
|
+
host?: string;
|
|
5
6
|
};
|
|
7
|
+
export declare const getDevAssetPrefix: (builder?: UniBuilderInstance) => Promise<string>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const onRepack: (distDir: string,
|
|
1
|
+
import type { ServerPluginHooks } from '@modern-js/server-core';
|
|
2
|
+
export declare const onRepack: (distDir: string, hooks: ServerPluginHooks) => void;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Server as NodeServer } from 'node:http';
|
|
2
2
|
import type { DevServerHttpsOptions, DevServerOptions } from '@modern-js/types';
|
|
3
3
|
import type { Rspack, UniBuilderInstance } from '@modern-js/uni-builder';
|
|
4
|
-
import type {
|
|
4
|
+
import type { ServerBase, ServerBaseOptions } from '@modern-js/server-core';
|
|
5
5
|
export type { DevServerOptions, DevServerHttpsOptions };
|
|
6
6
|
export type ExtraOptions = {
|
|
7
7
|
dev: Pick<DevServerOptions, 'watch' | 'https'> & {
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.66.0",
|
|
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.
|
|
52
|
-
"@modern-js/server-core": "2.
|
|
53
|
-
"@modern-js/server-utils": "2.
|
|
54
|
-
"@modern-js/
|
|
55
|
-
"@modern-js/
|
|
51
|
+
"@modern-js/runtime-utils": "2.66.0",
|
|
52
|
+
"@modern-js/server-core": "2.66.0",
|
|
53
|
+
"@modern-js/server-utils": "2.66.0",
|
|
54
|
+
"@modern-js/types": "2.66.0",
|
|
55
|
+
"@modern-js/utils": "2.66.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/connect-history-api-fallback": "^1.3.5",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"typescript": "^5",
|
|
68
68
|
"webpack": "^5.98.0",
|
|
69
69
|
"websocket": "^1",
|
|
70
|
-
"@modern-js/uni-builder": "2.
|
|
71
|
-
"@scripts/jest-config": "2.
|
|
72
|
-
"@scripts/build": "2.
|
|
70
|
+
"@modern-js/uni-builder": "2.66.0",
|
|
71
|
+
"@scripts/jest-config": "2.66.0",
|
|
72
|
+
"@scripts/build": "2.66.0"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"devcert": "^1.2.2",
|
|
@@ -90,8 +90,7 @@
|
|
|
90
90
|
"sideEffects": false,
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"registry": "https://registry.npmjs.org/",
|
|
93
|
-
"access": "public"
|
|
94
|
-
"provenance": true
|
|
93
|
+
"access": "public"
|
|
95
94
|
},
|
|
96
95
|
"scripts": {
|
|
97
96
|
"new": "modern-lib new",
|