@modern-js/server 1.15.0 → 1.16.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
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @modern-js/server
|
|
2
2
|
|
|
3
|
+
## 1.16.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2808ff5a2: fix(dev-server): support enable hmr client by webpack target
|
|
8
|
+
|
|
9
|
+
fix(dev-server): 支持通过 webpack target 来判断是否启用 hmr client
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [641592f52]
|
|
12
|
+
- Updated dependencies [3904b30a5]
|
|
13
|
+
- Updated dependencies [1100dd58c]
|
|
14
|
+
- Updated dependencies [e04e6e76a]
|
|
15
|
+
- Updated dependencies [81c66e4a4]
|
|
16
|
+
- Updated dependencies [2c305b6f5]
|
|
17
|
+
- @modern-js/utils@1.16.0
|
|
18
|
+
- @modern-js/webpack@1.16.0
|
|
19
|
+
- @modern-js/server-utils@1.16.0
|
|
20
|
+
- @modern-js/prod-server@1.16.0
|
|
21
|
+
|
|
3
22
|
## 1.15.0
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -8,6 +8,7 @@ import stripAnsi from '@modern-js/utils/strip-ansi';
|
|
|
8
8
|
import { formatWebpackMessages } from '@modern-js/utils/format';
|
|
9
9
|
import { createSocketUrl } from "./createSocketUrl"; // declare any to fix the type of `module.hot`
|
|
10
10
|
|
|
11
|
+
// TODO hadRuntimeError should be fixed.
|
|
11
12
|
// We need to keep track of if there has been a runtime error.
|
|
12
13
|
// Essentially, we cannot guarantee application state was not corrupted by the
|
|
13
14
|
// runtime error. To prevent confusing behavior, we forcibly reload the entire
|
|
@@ -171,11 +172,9 @@ function tryApplyUpdates() {
|
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
function handleApplyUpdates(err, updatedModules) {
|
|
174
|
-
|
|
175
|
-
const hasReactRefresh = process.env.FAST_REFRESH;
|
|
176
|
-
const wantsForcedReload = err || !updatedModules || hadRuntimeError; // React refresh can handle hot-reloading over errors.
|
|
175
|
+
const wantsForcedReload = err || !updatedModules || hadRuntimeError;
|
|
177
176
|
|
|
178
|
-
if (
|
|
177
|
+
if (wantsForcedReload) {
|
|
179
178
|
window.location.reload();
|
|
180
179
|
return;
|
|
181
180
|
}
|
|
@@ -241,14 +241,30 @@ export class ModernDevServer extends ModernServer {
|
|
|
241
241
|
return this.setupDevMiddleware(compiler);
|
|
242
242
|
}
|
|
243
243
|
|
|
244
|
+
isClientCompiler(compiler) {
|
|
245
|
+
const {
|
|
246
|
+
target
|
|
247
|
+
} = compiler.options; // if target not contains `node`, it's a client compiler
|
|
248
|
+
|
|
249
|
+
if (target) {
|
|
250
|
+
if (Array.isArray(target)) {
|
|
251
|
+
return !target.includes('node');
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return target !== 'node';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
return compiler.name === 'client';
|
|
258
|
+
}
|
|
259
|
+
|
|
244
260
|
setupDevServerPlugin(compiler) {
|
|
245
261
|
const {
|
|
246
262
|
dev: devConf
|
|
247
|
-
} = this;
|
|
263
|
+
} = this; // apply dev server to client compiler, add hmr client to entry.
|
|
248
264
|
|
|
249
265
|
if (compiler.compilers) {
|
|
250
266
|
compiler.compilers.forEach(target => {
|
|
251
|
-
if (target
|
|
267
|
+
if (this.isClientCompiler(target)) {
|
|
252
268
|
new DevServerPlugin(devConf).apply(target);
|
|
253
269
|
}
|
|
254
270
|
});
|
|
@@ -14,6 +14,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
14
14
|
*
|
|
15
15
|
* Tips: this package will be bundled and running in the browser, do not import from the entry of @modern-js/utils.
|
|
16
16
|
*/
|
|
17
|
+
// TODO hadRuntimeError should be fixed.
|
|
17
18
|
// We need to keep track of if there has been a runtime error.
|
|
18
19
|
// Essentially, we cannot guarantee application state was not corrupted by the
|
|
19
20
|
// runtime error. To prevent confusing behavior, we forcibly reload the entire
|
|
@@ -177,11 +178,9 @@ function tryApplyUpdates() {
|
|
|
177
178
|
}
|
|
178
179
|
|
|
179
180
|
function handleApplyUpdates(err, updatedModules) {
|
|
180
|
-
|
|
181
|
-
const hasReactRefresh = process.env.FAST_REFRESH;
|
|
182
|
-
const wantsForcedReload = err || !updatedModules || hadRuntimeError; // React refresh can handle hot-reloading over errors.
|
|
181
|
+
const wantsForcedReload = err || !updatedModules || hadRuntimeError;
|
|
183
182
|
|
|
184
|
-
if (
|
|
183
|
+
if (wantsForcedReload) {
|
|
185
184
|
window.location.reload();
|
|
186
185
|
return;
|
|
187
186
|
}
|
|
@@ -268,14 +268,30 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
268
268
|
return this.setupDevMiddleware(compiler);
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
isClientCompiler(compiler) {
|
|
272
|
+
const {
|
|
273
|
+
target
|
|
274
|
+
} = compiler.options; // if target not contains `node`, it's a client compiler
|
|
275
|
+
|
|
276
|
+
if (target) {
|
|
277
|
+
if (Array.isArray(target)) {
|
|
278
|
+
return !target.includes('node');
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return target !== 'node';
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return compiler.name === 'client';
|
|
285
|
+
}
|
|
286
|
+
|
|
271
287
|
setupDevServerPlugin(compiler) {
|
|
272
288
|
const {
|
|
273
289
|
dev: devConf
|
|
274
|
-
} = this;
|
|
290
|
+
} = this; // apply dev server to client compiler, add hmr client to entry.
|
|
275
291
|
|
|
276
292
|
if (compiler.compilers) {
|
|
277
293
|
compiler.compilers.forEach(target => {
|
|
278
|
-
if (target
|
|
294
|
+
if (this.isClientCompiler(target)) {
|
|
279
295
|
new _devServerPlugin.default(devConf).apply(target);
|
|
280
296
|
}
|
|
281
297
|
});
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.16.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,19 +30,19 @@
|
|
|
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/webpack": "1.
|
|
36
|
-
"@modern-js/utils": "1.
|
|
33
|
+
"@modern-js/prod-server": "1.16.0",
|
|
34
|
+
"@modern-js/server-utils": "1.16.0",
|
|
35
|
+
"@modern-js/webpack": "1.16.0",
|
|
36
|
+
"@modern-js/utils": "1.16.0",
|
|
37
37
|
"devcert": "^1.2.2",
|
|
38
38
|
"minimatch": "^3.0.4",
|
|
39
39
|
"path-to-regexp": "^6.2.0",
|
|
40
40
|
"ws": "^8.2.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@modern-js/core": "1.
|
|
44
|
-
"@modern-js/server-core": "1.
|
|
45
|
-
"@modern-js/types": "1.
|
|
43
|
+
"@modern-js/core": "1.16.0",
|
|
44
|
+
"@modern-js/server-core": "1.16.0",
|
|
45
|
+
"@modern-js/types": "1.16.0",
|
|
46
46
|
"@scripts/build": "1.15.0",
|
|
47
47
|
"@scripts/jest-config": "1.15.0",
|
|
48
48
|
"@types/jest": "^27",
|