@modern-js/server 2.35.0 → 2.35.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/dev-tools/dev-middleware/hmr-client/index.js +1 -2
- package/dist/cjs/dev-tools/dev-middleware/index.js +4 -5
- package/dist/cjs/dev-tools/mock/index.js +2 -4
- package/dist/cjs/server/devServer.js +4 -7
- package/dist/esm/dev-tools/dev-middleware/hmr-client/index.js +1 -2
- package/dist/esm/dev-tools/dev-middleware/index.js +4 -5
- package/dist/esm/dev-tools/mock/index.js +3 -4
- package/dist/esm/server/devServer.js +4 -5
- package/dist/esm-node/dev-tools/dev-middleware/hmr-client/index.js +1 -2
- package/dist/esm-node/dev-tools/dev-middleware/index.js +4 -5
- package/dist/esm-node/dev-tools/mock/index.js +2 -4
- package/dist/esm-node/server/devServer.js +4 -7
- package/package.json +9 -8
|
@@ -109,7 +109,6 @@ function canApplyUpdates() {
|
|
|
109
109
|
return module.hot.status() === "idle";
|
|
110
110
|
}
|
|
111
111
|
function tryApplyUpdates() {
|
|
112
|
-
var _result;
|
|
113
112
|
if (!module.hot) {
|
|
114
113
|
window.location.reload();
|
|
115
114
|
return;
|
|
@@ -132,7 +131,7 @@ function tryApplyUpdates() {
|
|
|
132
131
|
true,
|
|
133
132
|
handleApplyUpdates
|
|
134
133
|
);
|
|
135
|
-
if (
|
|
134
|
+
if (result === null || result === void 0 ? void 0 : result.then) {
|
|
136
135
|
result.then((updatedModules) => {
|
|
137
136
|
handleApplyUpdates(null, updatedModules);
|
|
138
137
|
}, (err) => {
|
|
@@ -16,11 +16,10 @@ const _socketServer = /* @__PURE__ */ _interop_require_default._(require("./sock
|
|
|
16
16
|
const noop = () => {
|
|
17
17
|
};
|
|
18
18
|
function getHMRClientPath(client) {
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const port = ((_client3 = client) === null || _client3 === void 0 ? void 0 : _client3.port) ? `&port=${client.port}` : "";
|
|
19
|
+
const protocol = (client === null || client === void 0 ? void 0 : client.protocol) ? `&protocol=${client.protocol}` : "";
|
|
20
|
+
const host = (client === null || client === void 0 ? void 0 : client.host) ? `&host=${client.host}` : "";
|
|
21
|
+
const path = (client === null || client === void 0 ? void 0 : client.path) ? `&path=${client.path}` : "";
|
|
22
|
+
const port = (client === null || client === void 0 ? void 0 : client.port) ? `&port=${client.port}` : "";
|
|
24
23
|
const clientEntry = `${require.resolve("@modern-js/server/hmr-client")}?${host}${path}${port}${protocol}`;
|
|
25
24
|
return clientEntry.replace(`${_path.sep}cjs${_path.sep}dev-tools`, `${_path.sep}esm${_path.sep}dev-tools`);
|
|
26
25
|
}
|
|
@@ -15,7 +15,6 @@ const _utils = require("@modern-js/utils");
|
|
|
15
15
|
const _prodserver = require("@modern-js/prod-server");
|
|
16
16
|
const _getMockData = /* @__PURE__ */ _interop_require_wildcard._(require("./getMockData"));
|
|
17
17
|
const createMockHandler = ({ pwd }) => {
|
|
18
|
-
var _config;
|
|
19
18
|
const exts = [
|
|
20
19
|
".ts",
|
|
21
20
|
".js"
|
|
@@ -33,7 +32,7 @@ const createMockHandler = ({ pwd }) => {
|
|
|
33
32
|
}
|
|
34
33
|
const mod = (0, _utils.compatRequire)(filepath, false);
|
|
35
34
|
const { default: mockModule = mod, config } = mod;
|
|
36
|
-
if ((
|
|
35
|
+
if ((config === null || config === void 0 ? void 0 : config.enable) === false) {
|
|
37
36
|
return null;
|
|
38
37
|
}
|
|
39
38
|
if (!mockModule) {
|
|
@@ -44,8 +43,7 @@ const createMockHandler = ({ pwd }) => {
|
|
|
44
43
|
return null;
|
|
45
44
|
}
|
|
46
45
|
return async (context, next) => {
|
|
47
|
-
|
|
48
|
-
if (typeof ((_config2 = config) === null || _config2 === void 0 ? void 0 : _config2.enable) === "function") {
|
|
46
|
+
if (typeof (config === null || config === void 0 ? void 0 : config.enable) === "function") {
|
|
49
47
|
const enableMock = config.enable(context.req, context.res);
|
|
50
48
|
if (!enableMock) {
|
|
51
49
|
return next();
|
|
@@ -101,10 +101,7 @@ class ModernDevServer extends _prodserver.ModernServer {
|
|
|
101
101
|
}
|
|
102
102
|
async applyDefaultMiddlewares(app) {
|
|
103
103
|
const { pwd, dev, devMiddleware, conf } = this;
|
|
104
|
-
const isUseStreamingSSR = (routes) =>
|
|
105
|
-
var _routes;
|
|
106
|
-
return (_routes = routes) === null || _routes === void 0 ? void 0 : _routes.some((r) => r.isStream === true);
|
|
107
|
-
};
|
|
104
|
+
const isUseStreamingSSR = (routes) => routes === null || routes === void 0 ? void 0 : routes.some((r) => r.isStream === true);
|
|
108
105
|
const isUseSSRPreload = () => {
|
|
109
106
|
const { server: { ssr, ssrByEntries } } = conf;
|
|
110
107
|
const checkUsePreload = (ssr2) => typeof ssr2 === "object" && Boolean(ssr2.preload);
|
|
@@ -292,11 +289,11 @@ class ModernDevServer extends _prodserver.ModernServer {
|
|
|
292
289
|
}
|
|
293
290
|
}
|
|
294
291
|
startWatcher() {
|
|
295
|
-
var
|
|
292
|
+
var _this_conf_server;
|
|
296
293
|
const { pwd, distDir, appContext } = this;
|
|
297
294
|
const { mock } = _prodserver.AGGRED_DIR;
|
|
298
|
-
const apiDir = (
|
|
299
|
-
const sharedDir = (
|
|
295
|
+
const apiDir = (appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory) || _utils.API_DIR;
|
|
296
|
+
const sharedDir = (appContext === null || appContext === void 0 ? void 0 : appContext.sharedDirectory) || _utils.SHARED_DIR;
|
|
300
297
|
const defaultWatched = [
|
|
301
298
|
`${mock}/**/*`,
|
|
302
299
|
`${_utils.SERVER_DIR}/**/*`,
|
|
@@ -131,7 +131,6 @@ function tryApplyUpdates() {
|
|
|
131
131
|
tryApplyUpdates();
|
|
132
132
|
}
|
|
133
133
|
};
|
|
134
|
-
var _result;
|
|
135
134
|
if (!module.hot) {
|
|
136
135
|
window.location.reload();
|
|
137
136
|
return;
|
|
@@ -144,7 +143,7 @@ function tryApplyUpdates() {
|
|
|
144
143
|
true,
|
|
145
144
|
handleApplyUpdates
|
|
146
145
|
);
|
|
147
|
-
if (
|
|
146
|
+
if (result === null || result === void 0 ? void 0 : result.then) {
|
|
148
147
|
result.then(function(updatedModules) {
|
|
149
148
|
handleApplyUpdates(null, updatedModules);
|
|
150
149
|
}, function(err) {
|
|
@@ -13,11 +13,10 @@ import SocketServer from "./socketServer";
|
|
|
13
13
|
var noop = function() {
|
|
14
14
|
};
|
|
15
15
|
function getHMRClientPath(client) {
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var port = ((_client3 = client) === null || _client3 === void 0 ? void 0 : _client3.port) ? "&port=".concat(client.port) : "";
|
|
16
|
+
var protocol = (client === null || client === void 0 ? void 0 : client.protocol) ? "&protocol=".concat(client.protocol) : "";
|
|
17
|
+
var host = (client === null || client === void 0 ? void 0 : client.host) ? "&host=".concat(client.host) : "";
|
|
18
|
+
var path = (client === null || client === void 0 ? void 0 : client.path) ? "&path=".concat(client.path) : "";
|
|
19
|
+
var port = (client === null || client === void 0 ? void 0 : client.port) ? "&port=".concat(client.port) : "";
|
|
21
20
|
var clientEntry = "".concat(require.resolve("@modern-js/server/hmr-client"), "?").concat(host).concat(path).concat(port).concat(protocol);
|
|
22
21
|
return clientEntry.replace("".concat(sep, "cjs").concat(sep, "dev-tools"), "".concat(sep, "esm").concat(sep, "dev-tools"));
|
|
23
22
|
}
|
|
@@ -6,7 +6,6 @@ import { AGGRED_DIR } from "@modern-js/prod-server";
|
|
|
6
6
|
import getMockData, { getMatched } from "./getMockData";
|
|
7
7
|
export var createMockHandler = function(param) {
|
|
8
8
|
var pwd = param.pwd;
|
|
9
|
-
var _config;
|
|
10
9
|
var exts = [
|
|
11
10
|
".ts",
|
|
12
11
|
".js"
|
|
@@ -41,7 +40,7 @@ export var createMockHandler = function(param) {
|
|
|
41
40
|
}
|
|
42
41
|
var mod = compatRequire(filepath, false);
|
|
43
42
|
var tmp = mod.default, mockModule = tmp === void 0 ? mod : tmp, config = mod.config;
|
|
44
|
-
if ((
|
|
43
|
+
if ((config === null || config === void 0 ? void 0 : config.enable) === false) {
|
|
45
44
|
return null;
|
|
46
45
|
}
|
|
47
46
|
if (!mockModule) {
|
|
@@ -53,9 +52,9 @@ export var createMockHandler = function(param) {
|
|
|
53
52
|
}
|
|
54
53
|
return function() {
|
|
55
54
|
var _ref = _async_to_generator(function(context, next) {
|
|
56
|
-
var
|
|
55
|
+
var enableMock, res, matched;
|
|
57
56
|
return _ts_generator(this, function(_state) {
|
|
58
|
-
if (typeof (
|
|
57
|
+
if (typeof (config === null || config === void 0 ? void 0 : config.enable) === "function") {
|
|
59
58
|
enableMock = config.enable(context.req, context.res);
|
|
60
59
|
if (!enableMock) {
|
|
61
60
|
return [
|
|
@@ -210,8 +210,7 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
210
210
|
case 0:
|
|
211
211
|
pwd = _this.pwd, dev = _this.dev, devMiddleware = _this.devMiddleware, conf = _this.conf;
|
|
212
212
|
isUseStreamingSSR = function(routes) {
|
|
213
|
-
|
|
214
|
-
return (_routes = routes) === null || _routes === void 0 ? void 0 : _routes.some(function(r) {
|
|
213
|
+
return routes === null || routes === void 0 ? void 0 : routes.some(function(r) {
|
|
215
214
|
return r.isStream === true;
|
|
216
215
|
});
|
|
217
216
|
};
|
|
@@ -599,11 +598,11 @@ export var ModernDevServer = /* @__PURE__ */ function(ModernServer2) {
|
|
|
599
598
|
key: "startWatcher",
|
|
600
599
|
value: function startWatcher() {
|
|
601
600
|
var _this = this;
|
|
602
|
-
var
|
|
601
|
+
var _this_conf_server;
|
|
603
602
|
var _this1 = this, pwd = _this1.pwd, distDir = _this1.distDir, appContext = _this1.appContext;
|
|
604
603
|
var mock = AGGRED_DIR.mock;
|
|
605
|
-
var apiDir = (
|
|
606
|
-
var sharedDir = (
|
|
604
|
+
var apiDir = (appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory) || API_DIR;
|
|
605
|
+
var sharedDir = (appContext === null || appContext === void 0 ? void 0 : appContext.sharedDirectory) || SHARED_DIR;
|
|
607
606
|
var defaultWatched = [
|
|
608
607
|
"".concat(mock, "/**/*"),
|
|
609
608
|
"".concat(SERVER_DIR, "/**/*"),
|
|
@@ -104,7 +104,6 @@ function canApplyUpdates() {
|
|
|
104
104
|
return module.hot.status() === "idle";
|
|
105
105
|
}
|
|
106
106
|
function tryApplyUpdates() {
|
|
107
|
-
var _result;
|
|
108
107
|
if (!module.hot) {
|
|
109
108
|
window.location.reload();
|
|
110
109
|
return;
|
|
@@ -127,7 +126,7 @@ function tryApplyUpdates() {
|
|
|
127
126
|
true,
|
|
128
127
|
handleApplyUpdates
|
|
129
128
|
);
|
|
130
|
-
if (
|
|
129
|
+
if (result === null || result === void 0 ? void 0 : result.then) {
|
|
131
130
|
result.then((updatedModules) => {
|
|
132
131
|
handleApplyUpdates(null, updatedModules);
|
|
133
132
|
}, (err) => {
|
|
@@ -5,11 +5,10 @@ import SocketServer from "./socketServer";
|
|
|
5
5
|
const noop = () => {
|
|
6
6
|
};
|
|
7
7
|
function getHMRClientPath(client) {
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const port = ((_client3 = client) === null || _client3 === void 0 ? void 0 : _client3.port) ? `&port=${client.port}` : "";
|
|
8
|
+
const protocol = (client === null || client === void 0 ? void 0 : client.protocol) ? `&protocol=${client.protocol}` : "";
|
|
9
|
+
const host = (client === null || client === void 0 ? void 0 : client.host) ? `&host=${client.host}` : "";
|
|
10
|
+
const path = (client === null || client === void 0 ? void 0 : client.path) ? `&path=${client.path}` : "";
|
|
11
|
+
const port = (client === null || client === void 0 ? void 0 : client.port) ? `&port=${client.port}` : "";
|
|
13
12
|
const clientEntry = `${require.resolve("@modern-js/server/hmr-client")}?${host}${path}${port}${protocol}`;
|
|
14
13
|
return clientEntry.replace(`${sep}cjs${sep}dev-tools`, `${sep}esm${sep}dev-tools`);
|
|
15
14
|
}
|
|
@@ -3,7 +3,6 @@ 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
|
export const createMockHandler = ({ pwd }) => {
|
|
6
|
-
var _config;
|
|
7
6
|
const exts = [
|
|
8
7
|
".ts",
|
|
9
8
|
".js"
|
|
@@ -21,7 +20,7 @@ export const createMockHandler = ({ pwd }) => {
|
|
|
21
20
|
}
|
|
22
21
|
const mod = compatRequire(filepath, false);
|
|
23
22
|
const { default: mockModule = mod, config } = mod;
|
|
24
|
-
if ((
|
|
23
|
+
if ((config === null || config === void 0 ? void 0 : config.enable) === false) {
|
|
25
24
|
return null;
|
|
26
25
|
}
|
|
27
26
|
if (!mockModule) {
|
|
@@ -32,8 +31,7 @@ export const createMockHandler = ({ pwd }) => {
|
|
|
32
31
|
return null;
|
|
33
32
|
}
|
|
34
33
|
return async (context, next) => {
|
|
35
|
-
|
|
36
|
-
if (typeof ((_config2 = config) === null || _config2 === void 0 ? void 0 : _config2.enable) === "function") {
|
|
34
|
+
if (typeof (config === null || config === void 0 ? void 0 : config.enable) === "function") {
|
|
37
35
|
const enableMock = config.enable(context.req, context.res);
|
|
38
36
|
if (!enableMock) {
|
|
39
37
|
return next();
|
|
@@ -89,10 +89,7 @@ export class ModernDevServer extends ModernServer {
|
|
|
89
89
|
}
|
|
90
90
|
async applyDefaultMiddlewares(app) {
|
|
91
91
|
const { pwd, dev, devMiddleware, conf } = this;
|
|
92
|
-
const isUseStreamingSSR = (routes) =>
|
|
93
|
-
var _routes;
|
|
94
|
-
return (_routes = routes) === null || _routes === void 0 ? void 0 : _routes.some((r) => r.isStream === true);
|
|
95
|
-
};
|
|
92
|
+
const isUseStreamingSSR = (routes) => routes === null || routes === void 0 ? void 0 : routes.some((r) => r.isStream === true);
|
|
96
93
|
const isUseSSRPreload = () => {
|
|
97
94
|
const { server: { ssr, ssrByEntries } } = conf;
|
|
98
95
|
const checkUsePreload = (ssr2) => typeof ssr2 === "object" && Boolean(ssr2.preload);
|
|
@@ -280,11 +277,11 @@ export class ModernDevServer extends ModernServer {
|
|
|
280
277
|
}
|
|
281
278
|
}
|
|
282
279
|
startWatcher() {
|
|
283
|
-
var
|
|
280
|
+
var _this_conf_server;
|
|
284
281
|
const { pwd, distDir, appContext } = this;
|
|
285
282
|
const { mock } = AGGRED_DIR;
|
|
286
|
-
const apiDir = (
|
|
287
|
-
const sharedDir = (
|
|
283
|
+
const apiDir = (appContext === null || appContext === void 0 ? void 0 : appContext.apiDirectory) || API_DIR;
|
|
284
|
+
const sharedDir = (appContext === null || appContext === void 0 ? void 0 : appContext.sharedDirectory) || SHARED_DIR;
|
|
288
285
|
const defaultWatched = [
|
|
289
286
|
`${mock}/**/*`,
|
|
290
287
|
`${SERVER_DIR}/**/*`,
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.35.
|
|
18
|
+
"version": "2.35.1",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -48,10 +48,11 @@
|
|
|
48
48
|
"path-to-regexp": "^6.2.0",
|
|
49
49
|
"ws": "^8.2.0",
|
|
50
50
|
"axios": "^1.2.1",
|
|
51
|
-
"@modern-js/prod-server": "2.35.
|
|
52
|
-
"@modern-js/server-utils": "2.35.
|
|
53
|
-
"@modern-js/types": "2.35.
|
|
54
|
-
"@modern-js/utils": "2.35.
|
|
51
|
+
"@modern-js/prod-server": "2.35.1",
|
|
52
|
+
"@modern-js/server-utils": "2.35.1",
|
|
53
|
+
"@modern-js/types": "2.35.1",
|
|
54
|
+
"@modern-js/utils": "2.35.1",
|
|
55
|
+
"@modern-js/runtime-utils": "2.35.1"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@types/connect-history-api-fallback": "^1.3.5",
|
|
@@ -66,9 +67,9 @@
|
|
|
66
67
|
"typescript": "^5",
|
|
67
68
|
"webpack": "^5.88.1",
|
|
68
69
|
"websocket": "^1",
|
|
69
|
-
"@modern-js/server-core": "2.35.
|
|
70
|
-
"@scripts/
|
|
71
|
-
"@scripts/
|
|
70
|
+
"@modern-js/server-core": "2.35.1",
|
|
71
|
+
"@scripts/jest-config": "2.35.1",
|
|
72
|
+
"@scripts/build": "2.35.1"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
75
|
"devcert": "^1.0.0",
|