@modern-js/server 1.2.2-beta.0 → 1.3.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,35 @@
1
1
  # @modern-js/server
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cfe11628: Make Modern.js self bootstraping
8
+
9
+ ### Patch Changes
10
+
11
+ - 146dcd85: modify server framework plugin hook types and hook context
12
+ - c3d46ee4: fix: test config invalid
13
+ - 146dcd85: modify server framework plugin hook types
14
+ - 146dcd85: fix test case in babel compiler
15
+ - 1ebc7ee2: fix: @babel/core version
16
+ - Updated dependencies [2da09c69]
17
+ - Updated dependencies [fc71e36f]
18
+ - Updated dependencies [146dcd85]
19
+ - Updated dependencies [74ce3bb7]
20
+ - Updated dependencies [c3d46ee4]
21
+ - Updated dependencies [cfe11628]
22
+ - Updated dependencies [146dcd85]
23
+ - Updated dependencies [8e7603ee]
24
+ - Updated dependencies [146dcd85]
25
+ - Updated dependencies [1ebc7ee2]
26
+ - @modern-js/utils@1.2.0
27
+ - @modern-js/core@1.3.0
28
+ - @modern-js/server-utils@1.2.0
29
+ - @modern-js/hmr-client@1.2.0
30
+ - @modern-js/bff-utils@1.2.0
31
+ - @modern-js/server-plugin@1.2.0
32
+
3
33
  ## 1.2.1
4
34
 
5
35
  ### Patch Changes
@@ -19,11 +19,13 @@ export default class Watcher {
19
19
  this.watcher = void 0;
20
20
  }
21
21
 
22
- listen(files, options, callback) {
22
+ listen(files, callback) {
23
23
  const watched = files.filter(Boolean);
24
- const filenames = watched.map(filename => filename.replace(/\\/g, '/'));
25
24
  const cache = new StatsCache();
26
- const watcher = chokidar.watch(filenames, options);
25
+ const watcher = chokidar.watch(watched, {
26
+ // 初始化的时候不触发 add、addDir 事件
27
+ ignoreInitial: true
28
+ });
27
29
  watcher.on('ready', () => {
28
30
  cache.add(getWatchedFiles(watcher));
29
31
  });
@@ -239,22 +239,16 @@ export class ModernDevServer extends ModernServer {
239
239
  const {
240
240
  mock
241
241
  } = AGGRED_DIR;
242
- const defaultWatched = [`${mock}/**/*`, `${SERVER_DIR}/**/*`, `${API_DIR}/**`, `${SHARED_DIR}/**/*`];
243
- const defaultWatchedPaths = defaultWatched.map(p => path.normalize(path.join(pwd, p)));
244
- const mockPath = path.normalize(path.join(pwd, mock));
242
+ const defaultWatched = [`${pwd}/${mock}/**/*`, `${pwd}/${SERVER_DIR}/**/*`, `${pwd}/${API_DIR}/!(typings)/**`, `${pwd}/${SHARED_DIR}/**/*`];
245
243
  const watcher = new Watcher();
246
244
  watcher.createDepTree(); // 监听文件变动,如果有变动则给 client,也就是 start 启动的插件发消息
247
245
 
248
- watcher.listen(defaultWatchedPaths, {
249
- // 初始化的时候不触发 add、addDir 事件
250
- ignoreInitial: true,
251
- ignored: /api\/typings\/**/
252
- }, filepath => {
246
+ watcher.listen(defaultWatched, filepath => {
253
247
  watcher.updateDepTree();
254
248
  watcher.cleanDepCache(filepath);
255
249
  this.runner.reset();
256
250
 
257
- if (filepath.startsWith(mockPath)) {
251
+ if (filepath.startsWith(`${pwd}/${mock}`)) {
258
252
  this.mockHandler = createMockHandler({
259
253
  pwd
260
254
  });
@@ -30,12 +30,14 @@ class Watcher {
30
30
  this.watcher = void 0;
31
31
  }
32
32
 
33
- listen(files, options, callback) {
33
+ listen(files, callback) {
34
34
  const watched = files.filter(Boolean);
35
- const filenames = watched.map(filename => filename.replace(/\\/g, '/'));
36
35
  const cache = new _statsCache.StatsCache();
37
36
 
38
- const watcher = _chokidar.default.watch(filenames, options);
37
+ const watcher = _chokidar.default.watch(watched, {
38
+ // 初始化的时候不触发 add、addDir 事件
39
+ ignoreInitial: true
40
+ });
39
41
 
40
42
  watcher.on('ready', () => {
41
43
  cache.add(getWatchedFiles(watcher));
@@ -268,24 +268,16 @@ class ModernDevServer extends _modernServer.ModernServer {
268
268
  const {
269
269
  mock
270
270
  } = _constants.AGGRED_DIR;
271
- const defaultWatched = [`${mock}/**/*`, `${_utils.SERVER_DIR}/**/*`, `${_utils.API_DIR}/**`, `${_utils.SHARED_DIR}/**/*`];
272
- const defaultWatchedPaths = defaultWatched.map(p => _path.default.normalize(_path.default.join(pwd, p)));
273
-
274
- const mockPath = _path.default.normalize(_path.default.join(pwd, mock));
275
-
271
+ const defaultWatched = [`${pwd}/${mock}/**/*`, `${pwd}/${_utils.SERVER_DIR}/**/*`, `${pwd}/${_utils.API_DIR}/!(typings)/**`, `${pwd}/${_utils.SHARED_DIR}/**/*`];
276
272
  const watcher = new _watcher.default();
277
273
  watcher.createDepTree(); // 监听文件变动,如果有变动则给 client,也就是 start 启动的插件发消息
278
274
 
279
- watcher.listen(defaultWatchedPaths, {
280
- // 初始化的时候不触发 add、addDir 事件
281
- ignoreInitial: true,
282
- ignored: /api\/typings\/**/
283
- }, filepath => {
275
+ watcher.listen(defaultWatched, filepath => {
284
276
  watcher.updateDepTree();
285
277
  watcher.cleanDepCache(filepath);
286
278
  this.runner.reset();
287
279
 
288
- if (filepath.startsWith(mockPath)) {
280
+ if (filepath.startsWith(`${pwd}/${mock}`)) {
289
281
  this.mockHandler = (0, _mock.createMockHandler)({
290
282
  pwd
291
283
  });
@@ -1,8 +1,7 @@
1
- import { WatchOptions } from 'chokidar';
2
1
  export default class Watcher {
3
2
  private dependencyTree;
4
3
  private watcher;
5
- listen(files: string[], options: WatchOptions, callback: (changed: string) => void): void;
4
+ listen(files: string[], callback: (changed: string) => void): void;
6
5
  createDepTree(): void;
7
6
  updateDepTree(): void;
8
7
  cleanDepCache(filepath: string): void;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.2.2-beta.0",
14
+ "version": "1.3.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -28,18 +28,18 @@
28
28
  }
29
29
  },
30
30
  "dependencies": {
31
- "@babel/core": "^7.15.0",
31
+ "@babel/core": "7.16.7",
32
32
  "@babel/compat-data": "^7.15.0",
33
33
  "@babel/preset-env": "^7.15.0",
34
34
  "@babel/preset-typescript": "^7.15.0",
35
35
  "@babel/register": "^7.15.3",
36
36
  "@babel/runtime": "^7",
37
- "@modern-js/core": "^1.2.0",
38
- "@modern-js/hmr-client": "^1.1.1",
39
- "@modern-js/server-plugin": "^1.1.4",
40
- "@modern-js/server-utils": "^1.1.2",
41
- "@modern-js/bff-utils": "^1.1.1",
42
- "@modern-js/utils": "^1.1.6",
37
+ "@modern-js/core": "^1.3.0",
38
+ "@modern-js/hmr-client": "^1.2.0",
39
+ "@modern-js/server-plugin": "^1.2.0",
40
+ "@modern-js/server-utils": "^1.2.0",
41
+ "@modern-js/bff-utils": "^1.2.0",
42
+ "@modern-js/utils": "^1.2.0",
43
43
  "axios": "^0.21.4",
44
44
  "babel-plugin-module-resolver": "^4.1.0",
45
45
  "chokidar": "^3.5.2",
@@ -64,7 +64,7 @@
64
64
  },
65
65
  "devDependencies": {
66
66
  "@scripts/build": "0.0.0",
67
- "@modern-js/types": "^1.1.5",
67
+ "@modern-js/types": "^1.2.0",
68
68
  "@types/jest": "^26",
69
69
  "@types/lru-cache": "^5.1.1",
70
70
  "@types/mime-types": "^2.1.0",
@@ -1,5 +1,4 @@
1
- import path from 'path';
2
- import chokidar, { FSWatcher, WatchOptions } from 'chokidar';
1
+ import chokidar, { FSWatcher } from 'chokidar';
3
2
  import { DependencyTree } from './dependency-tree';
4
3
  import { StatsCache } from './stats-cache';
5
4
 
@@ -19,16 +18,14 @@ export default class Watcher {
19
18
 
20
19
  private watcher!: FSWatcher;
21
20
 
22
- public listen(
23
- files: string[],
24
- options: WatchOptions,
25
- callback: (changed: string) => void,
26
- ) {
21
+ public listen(files: string[], callback: (changed: string) => void) {
27
22
  const watched = files.filter(Boolean);
28
- const filenames = watched.map(filename => filename.replace(/\\/g, '/'));
29
23
 
30
24
  const cache = new StatsCache();
31
- const watcher = chokidar.watch(filenames, options);
25
+ const watcher = chokidar.watch(watched, {
26
+ // 初始化的时候不触发 add、addDir 事件
27
+ ignoreInitial: true,
28
+ });
32
29
 
33
30
  watcher.on('ready', () => {
34
31
  cache.add(getWatchedFiles(watcher));
@@ -252,45 +252,32 @@ export class ModernDevServer extends ModernServer {
252
252
  const { pwd } = this;
253
253
  const { mock } = AGGRED_DIR;
254
254
  const defaultWatched = [
255
- `${mock}/**/*`,
256
- `${SERVER_DIR}/**/*`,
257
- `${API_DIR}/**`,
258
- `${SHARED_DIR}/**/*`,
255
+ `${pwd}/${mock}/**/*`,
256
+ `${pwd}/${SERVER_DIR}/**/*`,
257
+ `${pwd}/${API_DIR}/!(typings)/**`,
258
+ `${pwd}/${SHARED_DIR}/**/*`,
259
259
  ];
260
260
 
261
- const defaultWatchedPaths = defaultWatched.map(p =>
262
- path.normalize(path.join(pwd, p)),
263
- );
264
- const mockPath = path.normalize(path.join(pwd, mock));
265
-
266
261
  const watcher = new Watcher();
267
262
  watcher.createDepTree();
268
263
 
269
264
  // 监听文件变动,如果有变动则给 client,也就是 start 启动的插件发消息
270
- watcher.listen(
271
- defaultWatchedPaths,
272
- {
273
- // 初始化的时候不触发 add、addDir 事件
274
- ignoreInitial: true,
275
- ignored: /api\/typings\/**/,
276
- },
277
- (filepath: string) => {
278
- watcher.updateDepTree();
279
- watcher.cleanDepCache(filepath);
280
-
281
- this.runner.reset();
282
-
283
- if (filepath.startsWith(mockPath)) {
284
- this.mockHandler = createMockHandler({ pwd });
285
- } else {
286
- try {
287
- this.prepareFrameHandler();
288
- } catch (e) {
289
- this.logger.error(e as Error);
290
- }
265
+ watcher.listen(defaultWatched, (filepath: string) => {
266
+ watcher.updateDepTree();
267
+ watcher.cleanDepCache(filepath);
268
+
269
+ this.runner.reset();
270
+
271
+ if (filepath.startsWith(`${pwd}/${mock}`)) {
272
+ this.mockHandler = createMockHandler({ pwd });
273
+ } else {
274
+ try {
275
+ this.prepareFrameHandler();
276
+ } catch (e) {
277
+ this.logger.error(e as Error);
291
278
  }
292
- },
293
- );
279
+ }
280
+ });
294
281
 
295
282
  this.watcher = watcher;
296
283
  }
package/dist.zip DELETED
Binary file