@modern-js/server 1.18.1-alpha.0 → 1.19.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/CHANGELOG.md +23 -4
- package/dist/js/modern/dev-tools/dev-middleware/dev-server-plugin.js +3 -3
- package/dist/js/modern/dev-tools/dev-middleware/socket-server.js +8 -4
- package/dist/js/node/dev-tools/dev-middleware/dev-server-plugin.js +3 -3
- package/dist/js/node/dev-tools/dev-middleware/socket-server.js +8 -4
- package/dist/types/index.d.ts +2 -2
- package/dist/types/types.d.ts +2 -22
- package/package.json +10 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,25 @@
|
|
|
1
1
|
# @modern-js/server
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.19.0
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- Updated dependencies [1903f68]
|
|
8
|
+
- @modern-js/prod-server@1.19.0
|
|
9
|
+
- @modern-js/server-utils@1.19.0
|
|
10
|
+
- @modern-js/types@1.19.0
|
|
11
|
+
- @modern-js/utils@1.19.0
|
|
12
|
+
|
|
13
|
+
## 1.18.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- 318e149: fix: tools.devServer type missing some properties
|
|
18
|
+
|
|
19
|
+
fix: 修复 tools.devServer 类型定义不完整的问题
|
|
20
|
+
|
|
21
|
+
- 60d95ad: fix: dev server config should be optional
|
|
22
|
+
fix: devServer 配置项应该是可选配置的
|
|
7
23
|
- 8016a8a: fix: invoke next() in dev-middleware directly if only api
|
|
8
24
|
fix: 在 api 服务的情况下,直接调用 next(),不执行 dev-middleware
|
|
9
25
|
- f6a3aa1: feat: support etag in dev server by default
|
|
@@ -19,14 +35,17 @@
|
|
|
19
35
|
fix: 使用 output.publicPath 作为 webpack-dev-middleware publicPath
|
|
20
36
|
|
|
21
37
|
- Updated dependencies [3586707]
|
|
38
|
+
- Updated dependencies [318e149]
|
|
39
|
+
- Updated dependencies [60d95ad]
|
|
22
40
|
- Updated dependencies [f6a3aa1]
|
|
23
41
|
- Updated dependencies [fb02c81]
|
|
24
42
|
- Updated dependencies [9f7bfa6]
|
|
25
43
|
- Updated dependencies [9fcfbd4]
|
|
26
44
|
- Updated dependencies [6c2c745]
|
|
27
|
-
- @modern-js/prod-server@1.18.1
|
|
28
|
-
- @modern-js/
|
|
29
|
-
- @modern-js/utils@1.18.1
|
|
45
|
+
- @modern-js/prod-server@1.18.1
|
|
46
|
+
- @modern-js/types@1.18.1
|
|
47
|
+
- @modern-js/server-utils@1.18.1
|
|
48
|
+
- @modern-js/utils@1.18.1
|
|
30
49
|
|
|
31
50
|
## 1.18.0
|
|
32
51
|
|
|
@@ -11,9 +11,9 @@ export default class DevServerPlugin {
|
|
|
11
11
|
const {
|
|
12
12
|
client
|
|
13
13
|
} = this.options;
|
|
14
|
-
const host = client.host ? `&host=${client.host}` : '';
|
|
15
|
-
const path = client.path ? `&path=${client.path}` : '';
|
|
16
|
-
const port = client.port ? `&port=${client.port}` : '';
|
|
14
|
+
const host = client !== null && client !== void 0 && client.host ? `&host=${client.host}` : '';
|
|
15
|
+
const path = client !== null && client !== void 0 && client.path ? `&path=${client.path}` : '';
|
|
16
|
+
const port = client !== null && client !== void 0 && client.port ? `&port=${client.port}` : '';
|
|
17
17
|
const clientEntry = `${require.resolve("./hmr-client")}?${host}${path}${port}`; // use a hook to add entries if available
|
|
18
18
|
|
|
19
19
|
new compiler.webpack.EntryPlugin(compiler.context, clientEntry, {
|
|
@@ -21,10 +21,12 @@ export default class SocketServer {
|
|
|
21
21
|
|
|
22
22
|
|
|
23
23
|
prepare(app) {
|
|
24
|
+
var _this$options$client;
|
|
25
|
+
|
|
24
26
|
this.app = app;
|
|
25
27
|
this.wsServer = new ws.Server({
|
|
26
28
|
noServer: true,
|
|
27
|
-
path: this.options.client.path
|
|
29
|
+
path: (_this$options$client = this.options.client) === null || _this$options$client === void 0 ? void 0 : _this$options$client.path
|
|
28
30
|
}); // listen upgrade event to handle socket
|
|
29
31
|
|
|
30
32
|
this.app.on('upgrade', (req, sock, head) => {
|
|
@@ -92,6 +94,8 @@ export default class SocketServer {
|
|
|
92
94
|
}
|
|
93
95
|
|
|
94
96
|
onConnect(socket) {
|
|
97
|
+
var _this$options$client2, _this$options$client3, _this$options$client4;
|
|
98
|
+
|
|
95
99
|
const connection = socket;
|
|
96
100
|
connection.isAlive = true;
|
|
97
101
|
connection.on('pong', () => {
|
|
@@ -111,7 +115,7 @@ export default class SocketServer {
|
|
|
111
115
|
}
|
|
112
116
|
});
|
|
113
117
|
|
|
114
|
-
if (this.options.client.logging) {
|
|
118
|
+
if ((_this$options$client2 = this.options.client) !== null && _this$options$client2 !== void 0 && _this$options$client2.logging) {
|
|
115
119
|
this.singleWrite(connection, 'logging', this.options.client.logging);
|
|
116
120
|
}
|
|
117
121
|
|
|
@@ -123,11 +127,11 @@ export default class SocketServer {
|
|
|
123
127
|
this.singleWrite(connection, 'liveReload');
|
|
124
128
|
}
|
|
125
129
|
|
|
126
|
-
if (this.options.client.progress) {
|
|
130
|
+
if ((_this$options$client3 = this.options.client) !== null && _this$options$client3 !== void 0 && _this$options$client3.progress) {
|
|
127
131
|
this.singleWrite(connection, 'progress', this.options.client.progress);
|
|
128
132
|
}
|
|
129
133
|
|
|
130
|
-
if (this.options.client.overlay) {
|
|
134
|
+
if ((_this$options$client4 = this.options.client) !== null && _this$options$client4 !== void 0 && _this$options$client4.overlay) {
|
|
131
135
|
this.singleWrite(connection, 'overlay', this.options.client.overlay);
|
|
132
136
|
} // send first stats to active client sock if stats exist
|
|
133
137
|
|
|
@@ -18,9 +18,9 @@ class DevServerPlugin {
|
|
|
18
18
|
const {
|
|
19
19
|
client
|
|
20
20
|
} = this.options;
|
|
21
|
-
const host = client.host ? `&host=${client.host}` : '';
|
|
22
|
-
const path = client.path ? `&path=${client.path}` : '';
|
|
23
|
-
const port = client.port ? `&port=${client.port}` : '';
|
|
21
|
+
const host = client !== null && client !== void 0 && client.host ? `&host=${client.host}` : '';
|
|
22
|
+
const path = client !== null && client !== void 0 && client.path ? `&path=${client.path}` : '';
|
|
23
|
+
const port = client !== null && client !== void 0 && client.port ? `&port=${client.port}` : '';
|
|
24
24
|
const clientEntry = `${require.resolve("./hmr-client")}?${host}${path}${port}`; // use a hook to add entries if available
|
|
25
25
|
|
|
26
26
|
new compiler.webpack.EntryPlugin(compiler.context, clientEntry, {
|
|
@@ -32,10 +32,12 @@ class SocketServer {
|
|
|
32
32
|
|
|
33
33
|
|
|
34
34
|
prepare(app) {
|
|
35
|
+
var _this$options$client;
|
|
36
|
+
|
|
35
37
|
this.app = app;
|
|
36
38
|
this.wsServer = new _ws.default.Server({
|
|
37
39
|
noServer: true,
|
|
38
|
-
path: this.options.client.path
|
|
40
|
+
path: (_this$options$client = this.options.client) === null || _this$options$client === void 0 ? void 0 : _this$options$client.path
|
|
39
41
|
}); // listen upgrade event to handle socket
|
|
40
42
|
|
|
41
43
|
this.app.on('upgrade', (req, sock, head) => {
|
|
@@ -103,6 +105,8 @@ class SocketServer {
|
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
onConnect(socket) {
|
|
108
|
+
var _this$options$client2, _this$options$client3, _this$options$client4;
|
|
109
|
+
|
|
106
110
|
const connection = socket;
|
|
107
111
|
connection.isAlive = true;
|
|
108
112
|
connection.on('pong', () => {
|
|
@@ -122,7 +126,7 @@ class SocketServer {
|
|
|
122
126
|
}
|
|
123
127
|
});
|
|
124
128
|
|
|
125
|
-
if (this.options.client.logging) {
|
|
129
|
+
if ((_this$options$client2 = this.options.client) !== null && _this$options$client2 !== void 0 && _this$options$client2.logging) {
|
|
126
130
|
this.singleWrite(connection, 'logging', this.options.client.logging);
|
|
127
131
|
}
|
|
128
132
|
|
|
@@ -134,11 +138,11 @@ class SocketServer {
|
|
|
134
138
|
this.singleWrite(connection, 'liveReload');
|
|
135
139
|
}
|
|
136
140
|
|
|
137
|
-
if (this.options.client.progress) {
|
|
141
|
+
if ((_this$options$client3 = this.options.client) !== null && _this$options$client3 !== void 0 && _this$options$client3.progress) {
|
|
138
142
|
this.singleWrite(connection, 'progress', this.options.client.progress);
|
|
139
143
|
}
|
|
140
144
|
|
|
141
|
-
if (this.options.client.overlay) {
|
|
145
|
+
if ((_this$options$client4 = this.options.client) !== null && _this$options$client4 !== void 0 && _this$options$client4.overlay) {
|
|
142
146
|
this.singleWrite(connection, 'overlay', this.options.client.overlay);
|
|
143
147
|
} // send first stats to active client sock if stats exist
|
|
144
148
|
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DevServer as Server } from './server';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ModernDevServerOptions } from './types';
|
|
3
3
|
export { Server };
|
|
4
|
-
export type {
|
|
4
|
+
export type { ModernDevServerOptions };
|
|
5
5
|
|
|
6
6
|
declare const _default: (options: ModernDevServerOptions) => Promise<Server>;
|
|
7
7
|
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
import type webpack from 'webpack';
|
|
2
|
+
import type { DevServerOptions, DevServerHttpsOptions } from '@modern-js/types';
|
|
2
3
|
import type { ModernServerOptions } from '@modern-js/prod-server';
|
|
3
|
-
export
|
|
4
|
-
key: string;
|
|
5
|
-
cert: string;
|
|
6
|
-
};
|
|
7
|
-
export declare type DevServerOptions = {
|
|
8
|
-
client: {
|
|
9
|
-
path?: string;
|
|
10
|
-
port?: string;
|
|
11
|
-
host?: string;
|
|
12
|
-
logging?: string;
|
|
13
|
-
overlay?: boolean;
|
|
14
|
-
progress?: boolean;
|
|
15
|
-
};
|
|
16
|
-
devMiddleware: {
|
|
17
|
-
writeToDisk: boolean | ((filename: string) => boolean);
|
|
18
|
-
};
|
|
19
|
-
watch: boolean;
|
|
20
|
-
hot: boolean | string;
|
|
21
|
-
liveReload: boolean;
|
|
22
|
-
https?: DevServerHttpsOptions;
|
|
23
|
-
[propName: string]: any;
|
|
24
|
-
};
|
|
4
|
+
export type { DevServerOptions, DevServerHttpsOptions };
|
|
25
5
|
export declare type ExtraOptions = {
|
|
26
6
|
dev: boolean | Partial<DevServerOptions>;
|
|
27
7
|
compiler: webpack.MultiCompiler | webpack.Compiler | null;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.19.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/core": "^7.18.0",
|
|
32
32
|
"@babel/register": "^7.17.7",
|
|
33
|
-
"@modern-js/prod-server": "1.
|
|
34
|
-
"@modern-js/server-utils": "1.
|
|
35
|
-
"@modern-js/
|
|
33
|
+
"@modern-js/prod-server": "1.19.0",
|
|
34
|
+
"@modern-js/server-utils": "1.19.0",
|
|
35
|
+
"@modern-js/types": "1.19.0",
|
|
36
|
+
"@modern-js/utils": "1.19.0",
|
|
36
37
|
"devcert": "^1.2.2",
|
|
37
38
|
"minimatch": "^3.0.4",
|
|
38
39
|
"path-to-regexp": "^6.2.0",
|
|
39
40
|
"ws": "^8.2.0"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|
|
42
|
-
"@modern-js/core": "1.
|
|
43
|
-
"@modern-js/server-core": "1.
|
|
44
|
-
"@
|
|
45
|
-
"@scripts/
|
|
46
|
-
"@scripts/jest-config": "1.18.1-alpha.0",
|
|
43
|
+
"@modern-js/core": "1.19.0",
|
|
44
|
+
"@modern-js/server-core": "1.19.0",
|
|
45
|
+
"@scripts/build": "1.19.0",
|
|
46
|
+
"@scripts/jest-config": "1.19.0",
|
|
47
47
|
"@types/jest": "^27",
|
|
48
48
|
"@types/minimatch": "^3.0.5",
|
|
49
49
|
"@types/node": "^14",
|
|
@@ -97,6 +97,5 @@
|
|
|
97
97
|
"build": "wireit",
|
|
98
98
|
"dev": "modern build --watch",
|
|
99
99
|
"test": "wireit"
|
|
100
|
-
}
|
|
101
|
-
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
|
100
|
+
}
|
|
102
101
|
}
|