@modern-js/server 1.5.0 → 1.5.1-beta.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/js/modern/dev-tools/watcher/index.js +3 -3
- package/dist/js/modern/server/dev-server.js +15 -6
- package/dist/js/node/dev-tools/watcher/index.js +3 -3
- package/dist/js/node/server/dev-server.js +15 -6
- package/dist/types/dev-tools/watcher/index.d.ts +1 -1
- package/dist/types/server/dev-server.d.ts +3 -1
- package/package.json +7 -6
|
@@ -59,18 +59,18 @@ export default class Watcher {
|
|
|
59
59
|
watcher.on('change', changed => {
|
|
60
60
|
if (!fs.existsSync(changed) || cache.isDiff(changed)) {
|
|
61
61
|
cache.refresh(changed);
|
|
62
|
-
callback(changed);
|
|
62
|
+
callback(changed, 'change');
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
watcher.on('add', changed => {
|
|
66
66
|
if (!cache.has(changed)) {
|
|
67
67
|
cache.add([changed]);
|
|
68
|
-
callback(changed);
|
|
68
|
+
callback(changed, 'add');
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
watcher.on('unlink', changed => {
|
|
72
72
|
cache.del(changed);
|
|
73
|
-
callback(changed);
|
|
73
|
+
callback(changed, 'unlink');
|
|
74
74
|
});
|
|
75
75
|
this.watcher = watcher;
|
|
76
76
|
}
|
|
@@ -195,7 +195,8 @@ export class ModernDevServer extends ModernServer {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
onServerChange({
|
|
198
|
-
filepath
|
|
198
|
+
filepath,
|
|
199
|
+
event
|
|
199
200
|
}) {
|
|
200
201
|
const {
|
|
201
202
|
pwd
|
|
@@ -212,9 +213,16 @@ export class ModernDevServer extends ModernServer {
|
|
|
212
213
|
});
|
|
213
214
|
} else {
|
|
214
215
|
try {
|
|
215
|
-
|
|
216
|
-
filepath
|
|
217
|
-
|
|
216
|
+
const success = this.runner.onApiChange([{
|
|
217
|
+
filename: filepath,
|
|
218
|
+
event
|
|
219
|
+
}]);
|
|
220
|
+
|
|
221
|
+
if (!success) {
|
|
222
|
+
super.onServerChange({
|
|
223
|
+
filepath
|
|
224
|
+
});
|
|
225
|
+
}
|
|
218
226
|
} catch (e) {
|
|
219
227
|
this.logger.error(e);
|
|
220
228
|
}
|
|
@@ -354,11 +362,12 @@ export class ModernDevServer extends ModernServer {
|
|
|
354
362
|
const watcher = new Watcher();
|
|
355
363
|
watcher.createDepTree(); // 监听文件变动,如果有变动则给 client,也就是 start 启动的插件发消息
|
|
356
364
|
|
|
357
|
-
watcher.listen(defaultWatchedPaths, watchOptions, filepath => {
|
|
365
|
+
watcher.listen(defaultWatchedPaths, watchOptions, (filepath, event) => {
|
|
358
366
|
watcher.updateDepTree();
|
|
359
367
|
watcher.cleanDepCache(filepath);
|
|
360
368
|
this.onServerChange({
|
|
361
|
-
filepath
|
|
369
|
+
filepath,
|
|
370
|
+
event
|
|
362
371
|
});
|
|
363
372
|
});
|
|
364
373
|
this.watcher = watcher;
|
|
@@ -82,18 +82,18 @@ class Watcher {
|
|
|
82
82
|
watcher.on('change', changed => {
|
|
83
83
|
if (!_utils.fs.existsSync(changed) || cache.isDiff(changed)) {
|
|
84
84
|
cache.refresh(changed);
|
|
85
|
-
callback(changed);
|
|
85
|
+
callback(changed, 'change');
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
watcher.on('add', changed => {
|
|
89
89
|
if (!cache.has(changed)) {
|
|
90
90
|
cache.add([changed]);
|
|
91
|
-
callback(changed);
|
|
91
|
+
callback(changed, 'add');
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
watcher.on('unlink', changed => {
|
|
95
95
|
cache.del(changed);
|
|
96
|
-
callback(changed);
|
|
96
|
+
callback(changed, 'unlink');
|
|
97
97
|
});
|
|
98
98
|
this.watcher = watcher;
|
|
99
99
|
}
|
|
@@ -220,7 +220,8 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
220
220
|
}
|
|
221
221
|
|
|
222
222
|
onServerChange({
|
|
223
|
-
filepath
|
|
223
|
+
filepath,
|
|
224
|
+
event
|
|
224
225
|
}) {
|
|
225
226
|
const {
|
|
226
227
|
pwd
|
|
@@ -239,9 +240,16 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
239
240
|
});
|
|
240
241
|
} else {
|
|
241
242
|
try {
|
|
242
|
-
|
|
243
|
-
filepath
|
|
244
|
-
|
|
243
|
+
const success = this.runner.onApiChange([{
|
|
244
|
+
filename: filepath,
|
|
245
|
+
event
|
|
246
|
+
}]);
|
|
247
|
+
|
|
248
|
+
if (!success) {
|
|
249
|
+
super.onServerChange({
|
|
250
|
+
filepath
|
|
251
|
+
});
|
|
252
|
+
}
|
|
245
253
|
} catch (e) {
|
|
246
254
|
this.logger.error(e);
|
|
247
255
|
}
|
|
@@ -381,11 +389,12 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
381
389
|
const watcher = new _watcher.default();
|
|
382
390
|
watcher.createDepTree(); // 监听文件变动,如果有变动则给 client,也就是 start 启动的插件发消息
|
|
383
391
|
|
|
384
|
-
watcher.listen(defaultWatchedPaths, watchOptions, filepath => {
|
|
392
|
+
watcher.listen(defaultWatchedPaths, watchOptions, (filepath, event) => {
|
|
385
393
|
watcher.updateDepTree();
|
|
386
394
|
watcher.cleanDepCache(filepath);
|
|
387
395
|
this.onServerChange({
|
|
388
|
-
filepath
|
|
396
|
+
filepath,
|
|
397
|
+
event
|
|
389
398
|
});
|
|
390
399
|
});
|
|
391
400
|
this.watcher = watcher;
|
|
@@ -24,7 +24,7 @@ export declare const mergeWatchOptions: (options?: WatchOptions) => {
|
|
|
24
24
|
export default class Watcher {
|
|
25
25
|
private dependencyTree;
|
|
26
26
|
private watcher;
|
|
27
|
-
listen(files: string[], options: WatchOptions, callback: (changed: string) => void): void;
|
|
27
|
+
listen(files: string[], options: WatchOptions, callback: (changed: string, event: 'add' | 'change' | 'unlink') => void): void;
|
|
28
28
|
createDepTree(): void;
|
|
29
29
|
updateDepTree(): void;
|
|
30
30
|
cleanDepCache(filepath: string): void;
|
|
@@ -19,9 +19,11 @@ export declare class ModernDevServer extends ModernServer {
|
|
|
19
19
|
createHTTPServer(handler: (req: IncomingMessage, res: ServerResponse, next?: () => void) => void): Promise<http.Server | import("https").Server>;
|
|
20
20
|
protected warmupSSRBundle(): void;
|
|
21
21
|
protected onServerChange({
|
|
22
|
-
filepath
|
|
22
|
+
filepath,
|
|
23
|
+
event
|
|
23
24
|
}: {
|
|
24
25
|
filepath: string;
|
|
26
|
+
event: 'add' | 'unlink' | 'change';
|
|
25
27
|
}): void;
|
|
26
28
|
private setupCompiler;
|
|
27
29
|
private setupDevServerPlugin;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.5.0",
|
|
14
|
+
"version": "1.5.1-beta.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"@modern-js/hmr-client": "^1.2.8",
|
|
34
34
|
"@modern-js/prod-server": "^1.1.9",
|
|
35
35
|
"@modern-js/server-utils": "^1.2.11",
|
|
36
|
-
"@modern-js/webpack": "^1.11.
|
|
37
|
-
"@modern-js/utils": "^1.7.
|
|
36
|
+
"@modern-js/webpack": "^1.11.5",
|
|
37
|
+
"@modern-js/utils": "^1.7.12",
|
|
38
38
|
"devcert": "^1.2.2",
|
|
39
39
|
"minimatch": "^3.0.4",
|
|
40
40
|
"path-to-regexp": "^6.2.0",
|
|
41
41
|
"ws": "^8.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@modern-js/core": "1.12.
|
|
44
|
+
"@modern-js/core": "1.12.4",
|
|
45
45
|
"@modern-js/server-core": "1.4.0",
|
|
46
|
-
"@modern-js/types": "1.5.
|
|
46
|
+
"@modern-js/types": "1.5.6",
|
|
47
47
|
"@scripts/build": "0.0.0",
|
|
48
48
|
"@scripts/jest-config": "0.0.0",
|
|
49
49
|
"@types/jest": "^27",
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
},
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"registry": "https://registry.npmjs.org/",
|
|
65
|
-
"access": "public"
|
|
65
|
+
"access": "public",
|
|
66
|
+
"types": "./dist/types/index.d.ts"
|
|
66
67
|
},
|
|
67
68
|
"wireit": {
|
|
68
69
|
"build": {
|