@modern-js/server 2.35.1 → 2.36.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/constants.js +26 -9
- package/dist/cjs/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +27 -17
- package/dist/cjs/dev-tools/dev-middleware/hmr-client/index.js +30 -12
- package/dist/cjs/dev-tools/dev-middleware/index.js +39 -18
- package/dist/cjs/dev-tools/dev-middleware/socketServer.js +41 -19
- package/dist/cjs/dev-tools/https/index.js +29 -12
- package/dist/cjs/dev-tools/mock/getMockData.js +27 -18
- package/dist/cjs/dev-tools/mock/index.js +43 -18
- package/dist/cjs/dev-tools/register/index.js +47 -21
- package/dist/cjs/dev-tools/watcher/dependencyTree.js +43 -24
- package/dist/cjs/dev-tools/watcher/index.js +50 -34
- package/dist/cjs/dev-tools/watcher/statsCache.js +45 -19
- package/dist/cjs/index.js +27 -18
- package/dist/cjs/server/devServer.js +80 -55
- package/dist/cjs/server/index.js +28 -11
- package/dist/cjs/server/workerSSRRender.js +38 -12
- package/dist/cjs/types.js +15 -3
- package/dist/esm/constants.js +4 -1
- package/dist/esm/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +6 -2
- package/dist/esm/dev-tools/dev-middleware/hmr-client/index.js +148 -139
- package/dist/esm/dev-tools/dev-middleware/index.js +5 -4
- package/dist/esm/dev-tools/dev-middleware/socketServer.js +7 -5
- package/dist/esm/dev-tools/https/index.js +4 -1
- package/dist/esm/dev-tools/mock/getMockData.js +6 -2
- package/dist/esm/dev-tools/mock/index.js +4 -1
- package/dist/esm/dev-tools/register/index.js +7 -4
- package/dist/esm/dev-tools/watcher/dependencyTree.js +7 -3
- package/dist/esm/dev-tools/watcher/index.js +9 -4
- package/dist/esm/dev-tools/watcher/statsCache.js +4 -1
- package/dist/esm/index.js +5 -2
- package/dist/esm/server/devServer.js +17 -14
- package/dist/esm/server/index.js +4 -1
- package/dist/esm/server/workerSSRRender.js +6 -3
- package/dist/esm/types.js +0 -1
- package/dist/esm-node/constants.js +4 -1
- package/dist/esm-node/dev-tools/dev-middleware/hmr-client/createSocketUrl.js +6 -2
- package/dist/esm-node/dev-tools/dev-middleware/hmr-client/index.js +134 -125
- package/dist/esm-node/dev-tools/dev-middleware/index.js +4 -3
- package/dist/esm-node/dev-tools/dev-middleware/socketServer.js +3 -1
- package/dist/esm-node/dev-tools/https/index.js +4 -1
- package/dist/esm-node/dev-tools/mock/getMockData.js +6 -2
- package/dist/esm-node/dev-tools/mock/index.js +4 -1
- package/dist/esm-node/dev-tools/register/index.js +4 -1
- package/dist/esm-node/dev-tools/watcher/dependencyTree.js +6 -2
- package/dist/esm-node/dev-tools/watcher/index.js +9 -4
- package/dist/esm-node/dev-tools/watcher/statsCache.js +4 -1
- package/dist/esm-node/index.js +5 -2
- package/dist/esm-node/server/devServer.js +4 -1
- package/dist/esm-node/server/index.js +4 -1
- package/dist/esm-node/server/workerSSRRender.js +4 -1
- package/dist/esm-node/types.js +0 -1
- package/package.json +10 -11
|
@@ -3,7 +3,7 @@ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
|
|
3
3
|
import axios from "axios";
|
|
4
4
|
import { mime } from "@modern-js/utils";
|
|
5
5
|
var PORT = 9230;
|
|
6
|
-
|
|
6
|
+
function workerSSRRender(ctx, renderOptions, _runner) {
|
|
7
7
|
return _workerSSRRender.apply(this, arguments);
|
|
8
8
|
}
|
|
9
9
|
function _workerSSRRender() {
|
|
@@ -20,8 +20,8 @@ function _workerSSRRender() {
|
|
|
20
20
|
axios.get(url, {
|
|
21
21
|
timeout: 5e3,
|
|
22
22
|
responseType: "text",
|
|
23
|
-
headers
|
|
24
|
-
params
|
|
23
|
+
headers,
|
|
24
|
+
params
|
|
25
25
|
})
|
|
26
26
|
];
|
|
27
27
|
case 1:
|
|
@@ -38,3 +38,6 @@ function _workerSSRRender() {
|
|
|
38
38
|
});
|
|
39
39
|
return _workerSSRRender.apply(this, arguments);
|
|
40
40
|
}
|
|
41
|
+
export {
|
|
42
|
+
workerSSRRender
|
|
43
|
+
};
|
package/dist/esm/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HMR_SOCK_PATH } from "@modern-js/utils/universal/constants";
|
|
2
|
-
|
|
2
|
+
const getDefaultDevOptions = () => {
|
|
3
3
|
return {
|
|
4
4
|
client: {
|
|
5
5
|
path: HMR_SOCK_PATH,
|
|
@@ -20,3 +20,6 @@ export const getDefaultDevOptions = () => {
|
|
|
20
20
|
liveReload: true
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
+
export {
|
|
24
|
+
getDefaultDevOptions
|
|
25
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HMR_SOCK_PATH } from "@modern-js/utils/universal/constants";
|
|
2
|
-
|
|
2
|
+
function createSocketUrl(resourceQuery) {
|
|
3
3
|
const searchParams = resourceQuery.substr(1).split("&");
|
|
4
4
|
const options = {};
|
|
5
5
|
for (const pair of searchParams) {
|
|
@@ -9,7 +9,7 @@ export function createSocketUrl(resourceQuery) {
|
|
|
9
9
|
const currentLocation = self.location;
|
|
10
10
|
return getSocketUrl(options, currentLocation);
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
function formatURL({ port, protocol, hostname, pathname }) {
|
|
13
13
|
if (window.URL) {
|
|
14
14
|
const url = new URL("http://localhost");
|
|
15
15
|
url.port = port;
|
|
@@ -30,3 +30,7 @@ function getSocketUrl(urlParts, location) {
|
|
|
30
30
|
pathname: path || HMR_SOCK_PATH
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
+
export {
|
|
34
|
+
createSocketUrl,
|
|
35
|
+
formatURL
|
|
36
|
+
};
|
|
@@ -1,136 +1,145 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
+
};
|
|
1
5
|
import stripAnsi from "@modern-js/utils/strip-ansi";
|
|
2
6
|
import { formatWebpackMessages } from "@modern-js/utils/universal/format-webpack";
|
|
3
7
|
import { createSocketUrl } from "./createSocketUrl";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
console.clear
|
|
8
|
+
var require_hmr_client = __commonJS({
|
|
9
|
+
"src/dev-tools/dev-middleware/hmr-client/index.ts"(exports, module) {
|
|
10
|
+
const hadRuntimeError = false;
|
|
11
|
+
const socketUrl = createSocketUrl(__resourceQuery);
|
|
12
|
+
const connection = new WebSocket(socketUrl);
|
|
13
|
+
connection.onopen = function() {
|
|
14
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
15
|
+
console.info("[HMR] connected.");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
connection.onclose = function() {
|
|
19
|
+
if (typeof console !== "undefined" && typeof console.info === "function") {
|
|
20
|
+
console.info("[HMR] disconnected. Refresh the page if necessary.");
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
let isFirstCompilation = true;
|
|
24
|
+
let mostRecentCompilationHash = null;
|
|
25
|
+
let hasCompileErrors = false;
|
|
26
|
+
function clearOutdatedErrors() {
|
|
27
|
+
if (typeof console !== "undefined" && typeof console.clear === "function") {
|
|
28
|
+
if (hasCompileErrors) {
|
|
29
|
+
console.clear();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
33
|
+
function handleSuccess() {
|
|
34
|
+
clearOutdatedErrors();
|
|
35
|
+
const isHotUpdate = !isFirstCompilation;
|
|
36
|
+
isFirstCompilation = false;
|
|
37
|
+
hasCompileErrors = false;
|
|
38
|
+
if (isHotUpdate) {
|
|
39
|
+
tryApplyUpdates();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function handleWarnings(warnings) {
|
|
43
|
+
clearOutdatedErrors();
|
|
44
|
+
const isHotUpdate = !isFirstCompilation;
|
|
45
|
+
isFirstCompilation = false;
|
|
46
|
+
hasCompileErrors = false;
|
|
47
|
+
function printWarnings() {
|
|
48
|
+
const formatted = formatWebpackMessages({
|
|
49
|
+
warnings,
|
|
50
|
+
errors: []
|
|
51
|
+
});
|
|
52
|
+
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
53
|
+
for (let i = 0; i < formatted.warnings.length; i++) {
|
|
54
|
+
if (i === 5) {
|
|
55
|
+
console.warn("There were more warnings in other files.\nYou can find a complete log in the terminal.");
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
console.warn(stripAnsi(formatted.warnings[i]));
|
|
59
|
+
}
|
|
51
60
|
}
|
|
52
|
-
|
|
61
|
+
}
|
|
62
|
+
printWarnings();
|
|
63
|
+
if (isHotUpdate) {
|
|
64
|
+
tryApplyUpdates();
|
|
53
65
|
}
|
|
54
66
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
70
|
-
for (const error of formatted.errors) {
|
|
71
|
-
console.error(stripAnsi(error));
|
|
67
|
+
function handleErrors(errors) {
|
|
68
|
+
clearOutdatedErrors();
|
|
69
|
+
isFirstCompilation = false;
|
|
70
|
+
hasCompileErrors = true;
|
|
71
|
+
const formatted = formatWebpackMessages({
|
|
72
|
+
errors,
|
|
73
|
+
warnings: []
|
|
74
|
+
});
|
|
75
|
+
if (typeof console !== "undefined" && typeof console.error === "function") {
|
|
76
|
+
for (const error of formatted.errors) {
|
|
77
|
+
console.error(stripAnsi(error));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
72
80
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
function handleAvailableHash(hash) {
|
|
76
|
-
mostRecentCompilationHash = hash;
|
|
77
|
-
}
|
|
78
|
-
connection.onmessage = function(e) {
|
|
79
|
-
const message = JSON.parse(e.data);
|
|
80
|
-
switch (message.type) {
|
|
81
|
-
case "hash":
|
|
82
|
-
handleAvailableHash(message.data);
|
|
83
|
-
break;
|
|
84
|
-
case "still-ok":
|
|
85
|
-
case "ok":
|
|
86
|
-
handleSuccess();
|
|
87
|
-
break;
|
|
88
|
-
case "content-changed":
|
|
89
|
-
window.location.reload();
|
|
90
|
-
break;
|
|
91
|
-
case "warnings":
|
|
92
|
-
handleWarnings(message.data);
|
|
93
|
-
break;
|
|
94
|
-
case "errors":
|
|
95
|
-
handleErrors(message.data);
|
|
96
|
-
break;
|
|
97
|
-
default:
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
function isUpdateAvailable() {
|
|
101
|
-
return mostRecentCompilationHash !== __webpack_hash__;
|
|
102
|
-
}
|
|
103
|
-
function canApplyUpdates() {
|
|
104
|
-
return module.hot.status() === "idle";
|
|
105
|
-
}
|
|
106
|
-
function tryApplyUpdates() {
|
|
107
|
-
if (!module.hot) {
|
|
108
|
-
window.location.reload();
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
if (!isUpdateAvailable() || !canApplyUpdates()) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
function handleApplyUpdates(err, updatedModules) {
|
|
115
|
-
const wantsForcedReload = err || !updatedModules || hadRuntimeError;
|
|
116
|
-
if (wantsForcedReload) {
|
|
117
|
-
window.location.reload();
|
|
118
|
-
return;
|
|
81
|
+
function handleAvailableHash(hash) {
|
|
82
|
+
mostRecentCompilationHash = hash;
|
|
119
83
|
}
|
|
120
|
-
|
|
121
|
-
|
|
84
|
+
connection.onmessage = function(e) {
|
|
85
|
+
const message = JSON.parse(e.data);
|
|
86
|
+
switch (message.type) {
|
|
87
|
+
case "hash":
|
|
88
|
+
handleAvailableHash(message.data);
|
|
89
|
+
break;
|
|
90
|
+
case "still-ok":
|
|
91
|
+
case "ok":
|
|
92
|
+
handleSuccess();
|
|
93
|
+
break;
|
|
94
|
+
case "content-changed":
|
|
95
|
+
window.location.reload();
|
|
96
|
+
break;
|
|
97
|
+
case "warnings":
|
|
98
|
+
handleWarnings(message.data);
|
|
99
|
+
break;
|
|
100
|
+
case "errors":
|
|
101
|
+
handleErrors(message.data);
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
function isUpdateAvailable() {
|
|
107
|
+
return mostRecentCompilationHash !== __webpack_hash__;
|
|
108
|
+
}
|
|
109
|
+
function canApplyUpdates() {
|
|
110
|
+
return module.hot.status() === "idle";
|
|
111
|
+
}
|
|
112
|
+
function tryApplyUpdates() {
|
|
113
|
+
if (!module.hot) {
|
|
114
|
+
window.location.reload();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (!isUpdateAvailable() || !canApplyUpdates()) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
function handleApplyUpdates(err, updatedModules) {
|
|
121
|
+
const wantsForcedReload = err || !updatedModules || hadRuntimeError;
|
|
122
|
+
if (wantsForcedReload) {
|
|
123
|
+
window.location.reload();
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
if (isUpdateAvailable()) {
|
|
127
|
+
tryApplyUpdates();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const result = module.hot.check(
|
|
131
|
+
/* autoApply */
|
|
132
|
+
true,
|
|
133
|
+
handleApplyUpdates
|
|
134
|
+
);
|
|
135
|
+
if (result === null || result === void 0 ? void 0 : result.then) {
|
|
136
|
+
result.then((updatedModules) => {
|
|
137
|
+
handleApplyUpdates(null, updatedModules);
|
|
138
|
+
}, (err) => {
|
|
139
|
+
handleApplyUpdates(err, null);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
122
142
|
}
|
|
123
143
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
true,
|
|
127
|
-
handleApplyUpdates
|
|
128
|
-
);
|
|
129
|
-
if (result === null || result === void 0 ? void 0 : result.then) {
|
|
130
|
-
result.then((updatedModules) => {
|
|
131
|
-
handleApplyUpdates(null, updatedModules);
|
|
132
|
-
}, (err) => {
|
|
133
|
-
handleApplyUpdates(err, null);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
}
|
|
144
|
+
});
|
|
145
|
+
export default require_hmr_client();
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
|
-
import { sep } from "path";
|
|
3
2
|
import { EventEmitter } from "events";
|
|
4
3
|
import SocketServer from "./socketServer";
|
|
5
4
|
const noop = () => {
|
|
@@ -10,7 +9,7 @@ function getHMRClientPath(client) {
|
|
|
10
9
|
const path = (client === null || client === void 0 ? void 0 : client.path) ? `&path=${client.path}` : "";
|
|
11
10
|
const port = (client === null || client === void 0 ? void 0 : client.port) ? `&port=${client.port}` : "";
|
|
12
11
|
const clientEntry = `${require.resolve("@modern-js/server/hmr-client")}?${host}${path}${port}${protocol}`;
|
|
13
|
-
return clientEntry
|
|
12
|
+
return clientEntry;
|
|
14
13
|
}
|
|
15
14
|
class DevMiddleware extends EventEmitter {
|
|
16
15
|
init(app) {
|
|
@@ -60,4 +59,6 @@ class DevMiddleware extends EventEmitter {
|
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
|
-
export {
|
|
62
|
+
export {
|
|
63
|
+
DevMiddleware as default
|
|
64
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { chalk, getPackageManager, logger } from "@modern-js/utils";
|
|
2
|
-
|
|
2
|
+
const genHttpsOptions = async (userOptions, pwd) => {
|
|
3
3
|
const httpsOptions = typeof userOptions === "boolean" ? {} : userOptions;
|
|
4
4
|
if (!httpsOptions.key || !httpsOptions.cert) {
|
|
5
5
|
let devcertPath;
|
|
@@ -25,3 +25,6 @@ export const genHttpsOptions = async (userOptions, pwd) => {
|
|
|
25
25
|
}
|
|
26
26
|
return httpsOptions;
|
|
27
27
|
};
|
|
28
|
+
export {
|
|
29
|
+
genHttpsOptions
|
|
30
|
+
};
|
|
@@ -25,7 +25,7 @@ const allowTypes = [
|
|
|
25
25
|
"object",
|
|
26
26
|
"function"
|
|
27
27
|
];
|
|
28
|
-
|
|
28
|
+
var getMockData_default = (mockConfig) => Object.keys(mockConfig).reduce((acc, key) => {
|
|
29
29
|
const handler = mockConfig[key];
|
|
30
30
|
const type = typeof handler;
|
|
31
31
|
if (!allowTypes.includes(type)) {
|
|
@@ -60,7 +60,7 @@ const parseKey = (key) => {
|
|
|
60
60
|
path: key
|
|
61
61
|
};
|
|
62
62
|
};
|
|
63
|
-
|
|
63
|
+
const getMatched = (context, mockApiList) => {
|
|
64
64
|
const { path: targetPathname, method: targetMethod } = context;
|
|
65
65
|
const matched = mockApiList.find((mockApi) => {
|
|
66
66
|
const { method, path: pathname } = mockApi;
|
|
@@ -74,3 +74,7 @@ export const getMatched = (context, mockApiList) => {
|
|
|
74
74
|
});
|
|
75
75
|
return matched;
|
|
76
76
|
};
|
|
77
|
+
export {
|
|
78
|
+
getMockData_default as default,
|
|
79
|
+
getMatched
|
|
80
|
+
};
|
|
@@ -2,7 +2,7 @@ import path from "path";
|
|
|
2
2
|
import { compatRequire, fs } from "@modern-js/utils";
|
|
3
3
|
import { AGGRED_DIR } from "@modern-js/prod-server";
|
|
4
4
|
import getMockData, { getMatched } from "./getMockData";
|
|
5
|
-
|
|
5
|
+
const createMockHandler = ({ pwd }) => {
|
|
6
6
|
const exts = [
|
|
7
7
|
".ts",
|
|
8
8
|
".js"
|
|
@@ -46,3 +46,6 @@ export const createMockHandler = ({ pwd }) => {
|
|
|
46
46
|
return matched.handler(context, next);
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
+
export {
|
|
50
|
+
createMockHandler
|
|
51
|
+
};
|
|
@@ -12,7 +12,7 @@ const checkDep = (depName, paths) => {
|
|
|
12
12
|
}
|
|
13
13
|
return Boolean(packagePath);
|
|
14
14
|
};
|
|
15
|
-
|
|
15
|
+
const enableRegister = (projectRoot, config) => {
|
|
16
16
|
const registerDirs = [
|
|
17
17
|
"./api",
|
|
18
18
|
"./server",
|
|
@@ -107,3 +107,6 @@ export const enableRegister = (projectRoot, config) => {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
};
|
|
110
|
+
export {
|
|
111
|
+
enableRegister
|
|
112
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
2
|
import minimatch from "minimatch";
|
|
3
|
-
|
|
3
|
+
const defaultIgnores = [
|
|
4
4
|
"**/coverage/**",
|
|
5
5
|
"**/node_modules/**",
|
|
6
6
|
"**/.*/**",
|
|
7
7
|
"**/*.d.ts",
|
|
8
8
|
"**/*.log"
|
|
9
9
|
];
|
|
10
|
-
|
|
10
|
+
class DependencyTree {
|
|
11
11
|
getNode(path) {
|
|
12
12
|
return this.tree.get(path);
|
|
13
13
|
}
|
|
@@ -64,3 +64,7 @@ export class DependencyTree {
|
|
|
64
64
|
];
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
export {
|
|
68
|
+
DependencyTree,
|
|
69
|
+
defaultIgnores
|
|
70
|
+
};
|
|
@@ -3,12 +3,12 @@ import path from "path";
|
|
|
3
3
|
import { fs, chokidar } from "@modern-js/utils";
|
|
4
4
|
import { DependencyTree } from "./dependencyTree";
|
|
5
5
|
import { StatsCache } from "./statsCache";
|
|
6
|
-
|
|
6
|
+
const defaultWatchOptions = {
|
|
7
7
|
// 初始化的时候不触发 add、addDir 事件
|
|
8
8
|
ignoreInitial: true,
|
|
9
9
|
ignored: /api\/typings\/.*/
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
const getWatchedFiles = (watcher) => {
|
|
12
12
|
const watched = watcher.getWatched();
|
|
13
13
|
const files = [];
|
|
14
14
|
Object.keys(watched).forEach((dir) => {
|
|
@@ -18,7 +18,7 @@ export const getWatchedFiles = (watcher) => {
|
|
|
18
18
|
});
|
|
19
19
|
return files;
|
|
20
20
|
};
|
|
21
|
-
|
|
21
|
+
const mergeWatchOptions = (options) => {
|
|
22
22
|
const watchOptions = {
|
|
23
23
|
...options
|
|
24
24
|
};
|
|
@@ -94,4 +94,9 @@ class Watcher {
|
|
|
94
94
|
_define_property(this, "watcher", void 0);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
export {
|
|
97
|
+
export {
|
|
98
|
+
Watcher as default,
|
|
99
|
+
defaultWatchOptions,
|
|
100
|
+
getWatchedFiles,
|
|
101
|
+
mergeWatchOptions
|
|
102
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
|
2
2
|
import fs from "fs";
|
|
3
3
|
import crypto from "crypto";
|
|
4
|
-
|
|
4
|
+
class StatsCache {
|
|
5
5
|
add(files) {
|
|
6
6
|
const { cachedHash, cachedSize } = this;
|
|
7
7
|
for (const filename of files) {
|
|
@@ -54,3 +54,6 @@ export class StatsCache {
|
|
|
54
54
|
_define_property(this, "cachedSize", {});
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
export {
|
|
58
|
+
StatsCache
|
|
59
|
+
};
|
package/dist/esm-node/index.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { DevServer as Server } from "./server";
|
|
2
|
-
|
|
3
|
-
export default (options) => {
|
|
2
|
+
var src_default = (options) => {
|
|
4
3
|
if (options == null) {
|
|
5
4
|
throw new Error("can not start server without options");
|
|
6
5
|
}
|
|
7
6
|
const server = new Server(options);
|
|
8
7
|
return server.init();
|
|
9
8
|
};
|
|
9
|
+
export {
|
|
10
|
+
Server,
|
|
11
|
+
src_default as default
|
|
12
|
+
};
|
|
@@ -11,7 +11,7 @@ import { enableRegister } from "../dev-tools/register";
|
|
|
11
11
|
import Watcher, { mergeWatchOptions } from "../dev-tools/watcher";
|
|
12
12
|
import DevMiddleware from "../dev-tools/dev-middleware";
|
|
13
13
|
import { workerSSRRender } from "./workerSSRRender";
|
|
14
|
-
|
|
14
|
+
class ModernDevServer extends ModernServer {
|
|
15
15
|
getDevOptions(options) {
|
|
16
16
|
const devOptions = typeof options.dev === "boolean" ? {} : options.dev;
|
|
17
17
|
const defaultOptions = getDefaultDevOptions();
|
|
@@ -330,3 +330,6 @@ export class ModernDevServer extends ModernServer {
|
|
|
330
330
|
enableRegister(this.pwd, this.conf);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
+
export {
|
|
334
|
+
ModernDevServer
|
|
335
|
+
};
|
|
@@ -3,7 +3,7 @@ import { ModernDevServer } from "./devServer";
|
|
|
3
3
|
const createDevServer = (options) => {
|
|
4
4
|
return new ModernDevServer(options);
|
|
5
5
|
};
|
|
6
|
-
|
|
6
|
+
class DevServer extends Server {
|
|
7
7
|
constructor(options) {
|
|
8
8
|
super(options);
|
|
9
9
|
if (options.dev) {
|
|
@@ -11,3 +11,6 @@ export class DevServer extends Server {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
export {
|
|
15
|
+
DevServer
|
|
16
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
2
|
import { mime } from "@modern-js/utils";
|
|
3
3
|
const PORT = 9230;
|
|
4
|
-
|
|
4
|
+
async function workerSSRRender(ctx, renderOptions, _runner) {
|
|
5
5
|
const { headers, params } = ctx;
|
|
6
6
|
const { urlPath } = renderOptions;
|
|
7
7
|
const url = `http://0.0.0.0:${PORT}/${urlPath}`;
|
|
@@ -16,3 +16,6 @@ export async function workerSSRRender(ctx, renderOptions, _runner) {
|
|
|
16
16
|
contentType: mime.contentType("html")
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
export {
|
|
20
|
+
workerSSRRender
|
|
21
|
+
};
|
package/dist/esm-node/types.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.36.0",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -32,10 +32,9 @@
|
|
|
32
32
|
"./hmr-client": {
|
|
33
33
|
"node": {
|
|
34
34
|
"jsnext:source": "./src/dev-tools/dev-middleware/hmr-client/index.ts",
|
|
35
|
-
"import": "./dist/esm/dev-tools/dev-middleware/hmr-client/index.js",
|
|
36
35
|
"require": "./dist/cjs/dev-tools/dev-middleware/hmr-client/index.js"
|
|
37
36
|
},
|
|
38
|
-
"default": "./dist/
|
|
37
|
+
"default": "./dist/cjs/dev-tools/dev-middleware/hmr-client/index.js"
|
|
39
38
|
}
|
|
40
39
|
},
|
|
41
40
|
"dependencies": {
|
|
@@ -48,11 +47,11 @@
|
|
|
48
47
|
"path-to-regexp": "^6.2.0",
|
|
49
48
|
"ws": "^8.2.0",
|
|
50
49
|
"axios": "^1.2.1",
|
|
51
|
-
"@modern-js/
|
|
52
|
-
"@modern-js/server
|
|
53
|
-
"@modern-js/
|
|
54
|
-
"@modern-js/
|
|
55
|
-
"@modern-js/
|
|
50
|
+
"@modern-js/runtime-utils": "2.36.0",
|
|
51
|
+
"@modern-js/prod-server": "2.36.0",
|
|
52
|
+
"@modern-js/server-utils": "2.36.0",
|
|
53
|
+
"@modern-js/types": "2.36.0",
|
|
54
|
+
"@modern-js/utils": "2.36.0"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
57
|
"@types/connect-history-api-fallback": "^1.3.5",
|
|
@@ -67,9 +66,9 @@
|
|
|
67
66
|
"typescript": "^5",
|
|
68
67
|
"webpack": "^5.88.1",
|
|
69
68
|
"websocket": "^1",
|
|
70
|
-
"@modern-js/server-core": "2.
|
|
71
|
-
"@scripts/
|
|
72
|
-
"@scripts/
|
|
69
|
+
"@modern-js/server-core": "2.36.0",
|
|
70
|
+
"@scripts/build": "2.36.0",
|
|
71
|
+
"@scripts/jest-config": "2.36.0"
|
|
73
72
|
},
|
|
74
73
|
"peerDependencies": {
|
|
75
74
|
"devcert": "^1.0.0",
|