@modern-js/server 1.4.17 → 1.4.19
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 +18 -0
- package/dist/js/modern/dev-tools/dev-server-plugin.js +10 -7
- package/dist/js/modern/server/dev-server.js +11 -0
- package/dist/js/node/dev-tools/dev-server-plugin.js +10 -7
- package/dist/js/node/server/dev-server.js +11 -0
- package/dist/types/dev-tools/dev-server-plugin.d.ts +1 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @modern-js/server
|
|
2
2
|
|
|
3
|
+
## 1.4.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8d508c6ed: feat(devServer): support disable hmr or live reload
|
|
8
|
+
- a1198d509: feat: bump babel 7.18.0
|
|
9
|
+
- Updated dependencies [8d508c6ed]
|
|
10
|
+
- Updated dependencies [a1198d509]
|
|
11
|
+
- Updated dependencies [29728812e]
|
|
12
|
+
- Updated dependencies [147e090f7]
|
|
13
|
+
- Updated dependencies [18892c65c]
|
|
14
|
+
- Updated dependencies [a1198d509]
|
|
15
|
+
- @modern-js/webpack@1.10.0
|
|
16
|
+
- @modern-js/bff-utils@1.2.9
|
|
17
|
+
- @modern-js/hmr-client@1.2.8
|
|
18
|
+
- @modern-js/prod-server@1.1.8
|
|
19
|
+
- @modern-js/server-utils@1.2.10
|
|
20
|
+
|
|
3
21
|
## 1.4.17
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -11,20 +11,23 @@ export default class DevServerPlugin {
|
|
|
11
11
|
this.options = options;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
injectHMRClient(compiler) {
|
|
15
15
|
const {
|
|
16
16
|
client
|
|
17
17
|
} = this.options;
|
|
18
18
|
const host = client.host ? `&host=${client.host}` : '';
|
|
19
19
|
const path = client.path ? `&path=${client.path}` : '';
|
|
20
20
|
const port = client.port ? `&port=${client.port}` : '';
|
|
21
|
-
const clientEntry = `${require.resolve('@modern-js/hmr-client')}?${host}${path}${port}`;
|
|
22
|
-
|
|
21
|
+
const clientEntry = `${require.resolve('@modern-js/hmr-client')}?${host}${path}${port}`; // use a hook to add entries if available
|
|
22
|
+
|
|
23
|
+
new EntryPlugin(compiler.context, clientEntry, {
|
|
24
|
+
name: undefined
|
|
25
|
+
}).apply(compiler);
|
|
26
|
+
}
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}).apply(compiler);
|
|
28
|
+
apply(compiler) {
|
|
29
|
+
if (this.options.hot || this.options.liveReload) {
|
|
30
|
+
this.injectHMRClient(compiler);
|
|
28
31
|
} // Todo remove, client must inject.
|
|
29
32
|
|
|
30
33
|
|
|
@@ -71,10 +71,21 @@ export class ModernDevServer extends ModernServer {
|
|
|
71
71
|
});
|
|
72
72
|
});
|
|
73
73
|
this.addHandler((ctx, next) => {
|
|
74
|
+
var _this$conf$tools$devS;
|
|
75
|
+
|
|
74
76
|
// allow hmr request cross-domain, because the user may use global proxy
|
|
75
77
|
if (ctx.path.includes('hot-update')) {
|
|
76
78
|
ctx.res.setHeader('Access-Control-Allow-Origin', '*');
|
|
77
79
|
ctx.res.setHeader('Access-Control-Allow-Credentials', 'false');
|
|
80
|
+
} // 用户在 devServer 上配置的 headers 不会对 html 的请求生效,加入下面代码,使配置的 headers 对所有请求生效
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
const confHeaders = (_this$conf$tools$devS = this.conf.tools.devServer) === null || _this$conf$tools$devS === void 0 ? void 0 : _this$conf$tools$devS.headers;
|
|
84
|
+
|
|
85
|
+
if (confHeaders) {
|
|
86
|
+
for (const [key, value] of Object.entries(confHeaders)) {
|
|
87
|
+
ctx.res.setHeader(key, value);
|
|
88
|
+
}
|
|
78
89
|
}
|
|
79
90
|
|
|
80
91
|
next();
|
|
@@ -20,20 +20,23 @@ class DevServerPlugin {
|
|
|
20
20
|
this.options = options;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
injectHMRClient(compiler) {
|
|
24
24
|
const {
|
|
25
25
|
client
|
|
26
26
|
} = this.options;
|
|
27
27
|
const host = client.host ? `&host=${client.host}` : '';
|
|
28
28
|
const path = client.path ? `&path=${client.path}` : '';
|
|
29
29
|
const port = client.port ? `&port=${client.port}` : '';
|
|
30
|
-
const clientEntry = `${require.resolve('@modern-js/hmr-client')}?${host}${path}${port}`;
|
|
31
|
-
|
|
30
|
+
const clientEntry = `${require.resolve('@modern-js/hmr-client')}?${host}${path}${port}`; // use a hook to add entries if available
|
|
31
|
+
|
|
32
|
+
new EntryPlugin(compiler.context, clientEntry, {
|
|
33
|
+
name: undefined
|
|
34
|
+
}).apply(compiler);
|
|
35
|
+
}
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}).apply(compiler);
|
|
37
|
+
apply(compiler) {
|
|
38
|
+
if (this.options.hot || this.options.liveReload) {
|
|
39
|
+
this.injectHMRClient(compiler);
|
|
37
40
|
} // Todo remove, client must inject.
|
|
38
41
|
|
|
39
42
|
|
|
@@ -92,10 +92,21 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
92
92
|
});
|
|
93
93
|
});
|
|
94
94
|
this.addHandler((ctx, next) => {
|
|
95
|
+
var _this$conf$tools$devS;
|
|
96
|
+
|
|
95
97
|
// allow hmr request cross-domain, because the user may use global proxy
|
|
96
98
|
if (ctx.path.includes('hot-update')) {
|
|
97
99
|
ctx.res.setHeader('Access-Control-Allow-Origin', '*');
|
|
98
100
|
ctx.res.setHeader('Access-Control-Allow-Credentials', 'false');
|
|
101
|
+
} // 用户在 devServer 上配置的 headers 不会对 html 的请求生效,加入下面代码,使配置的 headers 对所有请求生效
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
const confHeaders = (_this$conf$tools$devS = this.conf.tools.devServer) === null || _this$conf$tools$devS === void 0 ? void 0 : _this$conf$tools$devS.headers;
|
|
105
|
+
|
|
106
|
+
if (confHeaders) {
|
|
107
|
+
for (const [key, value] of Object.entries(confHeaders)) {
|
|
108
|
+
ctx.res.setHeader(key, value);
|
|
109
|
+
}
|
|
99
110
|
}
|
|
100
111
|
|
|
101
112
|
next();
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.19",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@babel/core": "^7.
|
|
32
|
-
"@babel/register": "^7.
|
|
33
|
-
"@modern-js/bff-utils": "^1.2.
|
|
34
|
-
"@modern-js/hmr-client": "^1.2.
|
|
35
|
-
"@modern-js/prod-server": "^1.1.
|
|
36
|
-
"@modern-js/server-utils": "^1.2.
|
|
37
|
-
"@modern-js/webpack": "^1.
|
|
31
|
+
"@babel/core": "^7.18.0",
|
|
32
|
+
"@babel/register": "^7.17.7",
|
|
33
|
+
"@modern-js/bff-utils": "^1.2.9",
|
|
34
|
+
"@modern-js/hmr-client": "^1.2.8",
|
|
35
|
+
"@modern-js/prod-server": "^1.1.8",
|
|
36
|
+
"@modern-js/server-utils": "^1.2.10",
|
|
37
|
+
"@modern-js/webpack": "^1.10.0",
|
|
38
38
|
"@modern-js/utils": "^1.7.6",
|
|
39
39
|
"devcert": "1.2.0",
|
|
40
40
|
"minimatch": "^3.0.4",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"ws": "^8.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@modern-js/core": "1.11.
|
|
45
|
+
"@modern-js/core": "1.11.2",
|
|
46
46
|
"@modern-js/server-core": "1.3.5",
|
|
47
47
|
"@modern-js/types": "1.5.4",
|
|
48
48
|
"@scripts/build": "0.0.0",
|