@modern-js/server 1.5.0-alpha.0 → 1.5.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 +15 -15
- package/dist/js/modern/dev-tools/watcher/index.js +27 -0
- package/dist/js/modern/server/dev-server.js +3 -6
- package/dist/js/node/dev-tools/watcher/index.js +33 -1
- package/dist/js/node/server/dev-server.js +7 -6
- package/dist/types/dev-tools/watcher/index.d.ts +21 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
# @modern-js/server
|
|
2
2
|
|
|
3
|
-
## 1.5.0
|
|
3
|
+
## 1.5.0
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- 77a8e9e: feat: support bff operators
|
|
8
8
|
|
|
9
9
|
### Patch Changes
|
|
10
10
|
|
|
11
|
-
-
|
|
12
|
-
- Updated dependencies [
|
|
13
|
-
- Updated dependencies [
|
|
14
|
-
- Updated dependencies [
|
|
15
|
-
- Updated dependencies [
|
|
16
|
-
- Updated dependencies [
|
|
17
|
-
- Updated dependencies [
|
|
18
|
-
- Updated dependencies [
|
|
19
|
-
|
|
20
|
-
- @modern-js/webpack@1.11.3
|
|
21
|
-
- @modern-js/prod-server@1.1.9
|
|
22
|
-
- @modern-js/
|
|
23
|
-
- @modern-js/server-utils@1.2.
|
|
11
|
+
- d9564f2: feat: add watchOptions for server watcher
|
|
12
|
+
- Updated dependencies [550e2bd]
|
|
13
|
+
- Updated dependencies [87eb9f8]
|
|
14
|
+
- Updated dependencies [2b06fe3]
|
|
15
|
+
- Updated dependencies [3050acc]
|
|
16
|
+
- Updated dependencies [f29e9ba]
|
|
17
|
+
- Updated dependencies [2dacc89]
|
|
18
|
+
- Updated dependencies [338496c]
|
|
19
|
+
- Updated dependencies [a90bc96]
|
|
20
|
+
- @modern-js/webpack@1.11.3
|
|
21
|
+
- @modern-js/prod-server@1.1.9
|
|
22
|
+
- @modern-js/utils@1.7.9
|
|
23
|
+
- @modern-js/server-utils@1.2.11
|
|
24
24
|
|
|
25
25
|
## 1.4.21
|
|
26
26
|
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
+
|
|
1
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
2
6
|
|
|
3
7
|
import path from 'path';
|
|
4
8
|
import { fs, chokidar } from '@modern-js/utils';
|
|
5
9
|
import { DependencyTree } from "./dependency-tree";
|
|
6
10
|
import { StatsCache } from "./stats-cache";
|
|
11
|
+
export const defaultWatchOptions = {
|
|
12
|
+
// 初始化的时候不触发 add、addDir 事件
|
|
13
|
+
ignoreInitial: true,
|
|
14
|
+
ignored: /api\/typings\/.*/
|
|
15
|
+
};
|
|
7
16
|
export const getWatchedFiles = watcher => {
|
|
8
17
|
const watched = watcher.getWatched();
|
|
9
18
|
const files = [];
|
|
@@ -14,6 +23,24 @@ export const getWatchedFiles = watcher => {
|
|
|
14
23
|
});
|
|
15
24
|
return files;
|
|
16
25
|
};
|
|
26
|
+
export const mergeWatchOptions = options => {
|
|
27
|
+
const watchOptions = _objectSpread({}, options);
|
|
28
|
+
|
|
29
|
+
if (watchOptions) {
|
|
30
|
+
const {
|
|
31
|
+
ignored
|
|
32
|
+
} = watchOptions;
|
|
33
|
+
const finalIgnored = ignored ? [defaultWatchOptions.ignored, ...(Array.isArray(ignored) ? ignored : [ignored])] : ignored;
|
|
34
|
+
|
|
35
|
+
if (finalIgnored) {
|
|
36
|
+
watchOptions.ignored = finalIgnored;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const finalWatchOptions = _objectSpread(_objectSpread({}, defaultWatchOptions), watchOptions);
|
|
41
|
+
|
|
42
|
+
return finalWatchOptions;
|
|
43
|
+
};
|
|
17
44
|
export default class Watcher {
|
|
18
45
|
constructor() {
|
|
19
46
|
_defineProperty(this, "dependencyTree", null);
|
|
@@ -15,7 +15,7 @@ import { createMockHandler } from "../dev-tools/mock";
|
|
|
15
15
|
import SocketServer from "../dev-tools/socket-server";
|
|
16
16
|
import DevServerPlugin from "../dev-tools/dev-server-plugin";
|
|
17
17
|
import { enableRegister } from "../dev-tools/babel/register";
|
|
18
|
-
import Watcher from "../dev-tools/watcher";
|
|
18
|
+
import Watcher, { mergeWatchOptions } from "../dev-tools/watcher";
|
|
19
19
|
export class ModernDevServer extends ModernServer {
|
|
20
20
|
constructor(options) {
|
|
21
21
|
super(options); // dev server should work in pwd
|
|
@@ -349,15 +349,12 @@ export class ModernDevServer extends ModernServer {
|
|
|
349
349
|
mock
|
|
350
350
|
} = AGGRED_DIR;
|
|
351
351
|
const defaultWatched = [`${mock}/**/*`, `${SERVER_DIR}/**/*`, `${API_DIR}/**`, `${SHARED_DIR}/**/*`];
|
|
352
|
+
const watchOptions = mergeWatchOptions(this.conf.server.watchOptions);
|
|
352
353
|
const defaultWatchedPaths = defaultWatched.map(p => path.normalize(path.join(pwd, p)));
|
|
353
354
|
const watcher = new Watcher();
|
|
354
355
|
watcher.createDepTree(); // 监听文件变动,如果有变动则给 client,也就是 start 启动的插件发消息
|
|
355
356
|
|
|
356
|
-
watcher.listen(defaultWatchedPaths, {
|
|
357
|
-
// 初始化的时候不触发 add、addDir 事件
|
|
358
|
-
ignoreInitial: true,
|
|
359
|
-
ignored: /api\/typings\/.*/
|
|
360
|
-
}, filepath => {
|
|
357
|
+
watcher.listen(defaultWatchedPaths, watchOptions, filepath => {
|
|
361
358
|
watcher.updateDepTree();
|
|
362
359
|
watcher.cleanDepCache(filepath);
|
|
363
360
|
this.onServerChange({
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getWatchedFiles = exports.default = void 0;
|
|
6
|
+
exports.mergeWatchOptions = exports.getWatchedFiles = exports.defaultWatchOptions = exports.default = void 0;
|
|
7
7
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
@@ -15,8 +15,19 @@ var _statsCache = require("./stats-cache");
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
|
|
18
22
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
23
|
|
|
24
|
+
const defaultWatchOptions = {
|
|
25
|
+
// 初始化的时候不触发 add、addDir 事件
|
|
26
|
+
ignoreInitial: true,
|
|
27
|
+
ignored: /api\/typings\/.*/
|
|
28
|
+
};
|
|
29
|
+
exports.defaultWatchOptions = defaultWatchOptions;
|
|
30
|
+
|
|
20
31
|
const getWatchedFiles = watcher => {
|
|
21
32
|
const watched = watcher.getWatched();
|
|
22
33
|
const files = [];
|
|
@@ -30,6 +41,27 @@ const getWatchedFiles = watcher => {
|
|
|
30
41
|
|
|
31
42
|
exports.getWatchedFiles = getWatchedFiles;
|
|
32
43
|
|
|
44
|
+
const mergeWatchOptions = options => {
|
|
45
|
+
const watchOptions = _objectSpread({}, options);
|
|
46
|
+
|
|
47
|
+
if (watchOptions) {
|
|
48
|
+
const {
|
|
49
|
+
ignored
|
|
50
|
+
} = watchOptions;
|
|
51
|
+
const finalIgnored = ignored ? [defaultWatchOptions.ignored, ...(Array.isArray(ignored) ? ignored : [ignored])] : ignored;
|
|
52
|
+
|
|
53
|
+
if (finalIgnored) {
|
|
54
|
+
watchOptions.ignored = finalIgnored;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const finalWatchOptions = _objectSpread(_objectSpread({}, defaultWatchOptions), watchOptions);
|
|
59
|
+
|
|
60
|
+
return finalWatchOptions;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
exports.mergeWatchOptions = mergeWatchOptions;
|
|
64
|
+
|
|
33
65
|
class Watcher {
|
|
34
66
|
constructor() {
|
|
35
67
|
_defineProperty(this, "dependencyTree", null);
|
|
@@ -27,7 +27,11 @@ var _devServerPlugin = _interopRequireDefault(require("../dev-tools/dev-server-p
|
|
|
27
27
|
|
|
28
28
|
var _register = require("../dev-tools/babel/register");
|
|
29
29
|
|
|
30
|
-
var _watcher =
|
|
30
|
+
var _watcher = _interopRequireWildcard(require("../dev-tools/watcher"));
|
|
31
|
+
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
+
|
|
34
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
35
|
|
|
32
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
37
|
|
|
@@ -372,15 +376,12 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
372
376
|
mock
|
|
373
377
|
} = _prodServer.AGGRED_DIR;
|
|
374
378
|
const defaultWatched = [`${mock}/**/*`, `${_utils.SERVER_DIR}/**/*`, `${_utils.API_DIR}/**`, `${_utils.SHARED_DIR}/**/*`];
|
|
379
|
+
const watchOptions = (0, _watcher.mergeWatchOptions)(this.conf.server.watchOptions);
|
|
375
380
|
const defaultWatchedPaths = defaultWatched.map(p => _path.default.normalize(_path.default.join(pwd, p)));
|
|
376
381
|
const watcher = new _watcher.default();
|
|
377
382
|
watcher.createDepTree(); // 监听文件变动,如果有变动则给 client,也就是 start 启动的插件发消息
|
|
378
383
|
|
|
379
|
-
watcher.listen(defaultWatchedPaths, {
|
|
380
|
-
// 初始化的时候不触发 add、addDir 事件
|
|
381
|
-
ignoreInitial: true,
|
|
382
|
-
ignored: /api\/typings\/.*/
|
|
383
|
-
}, filepath => {
|
|
384
|
+
watcher.listen(defaultWatchedPaths, watchOptions, filepath => {
|
|
384
385
|
watcher.updateDepTree();
|
|
385
386
|
watcher.cleanDepCache(filepath);
|
|
386
387
|
this.onServerChange({
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import { FSWatcher, WatchOptions } from '@modern-js/utils';
|
|
2
|
+
export declare const defaultWatchOptions: {
|
|
3
|
+
ignoreInitial: boolean;
|
|
4
|
+
ignored: RegExp;
|
|
5
|
+
};
|
|
2
6
|
export declare const getWatchedFiles: (watcher: FSWatcher) => string[];
|
|
7
|
+
export declare const mergeWatchOptions: (options?: WatchOptions) => {
|
|
8
|
+
persistent?: boolean | undefined;
|
|
9
|
+
ignored: import("@modern-js/utils/compiled/chokidar/anymatch").Matcher;
|
|
10
|
+
ignoreInitial: boolean;
|
|
11
|
+
followSymlinks?: boolean | undefined;
|
|
12
|
+
cwd?: string | undefined;
|
|
13
|
+
disableGlobbing?: boolean | undefined;
|
|
14
|
+
usePolling?: boolean | undefined;
|
|
15
|
+
useFsEvents?: boolean | undefined;
|
|
16
|
+
alwaysStat?: boolean | undefined;
|
|
17
|
+
depth?: number | undefined;
|
|
18
|
+
interval?: number | undefined;
|
|
19
|
+
binaryInterval?: number | undefined;
|
|
20
|
+
ignorePermissionErrors?: boolean | undefined;
|
|
21
|
+
atomic?: number | boolean | undefined;
|
|
22
|
+
awaitWriteFinish?: boolean | import("@modern-js/utils/compiled/chokidar").AwaitWriteFinishOptions | undefined;
|
|
23
|
+
};
|
|
3
24
|
export default class Watcher {
|
|
4
25
|
private dependencyTree;
|
|
5
26
|
private watcher;
|
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.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/hmr-client": "^1.2.
|
|
34
|
-
"@modern-js/prod-server": "^1.1.9
|
|
35
|
-
"@modern-js/server-utils": "^1.2.
|
|
36
|
-
"@modern-js/webpack": "^1.11.3
|
|
37
|
-
"@modern-js/utils": "^1.7.9
|
|
33
|
+
"@modern-js/hmr-client": "^1.2.8",
|
|
34
|
+
"@modern-js/prod-server": "^1.1.9",
|
|
35
|
+
"@modern-js/server-utils": "^1.2.11",
|
|
36
|
+
"@modern-js/webpack": "^1.11.3",
|
|
37
|
+
"@modern-js/utils": "^1.7.9",
|
|
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.2
|
|
45
|
-
"@modern-js/server-core": "1.4.0
|
|
46
|
-
"@modern-js/types": "1.5.5
|
|
44
|
+
"@modern-js/core": "1.12.2",
|
|
45
|
+
"@modern-js/server-core": "1.4.0",
|
|
46
|
+
"@modern-js/types": "1.5.5",
|
|
47
47
|
"@scripts/build": "0.0.0",
|
|
48
48
|
"@scripts/jest-config": "0.0.0",
|
|
49
49
|
"@types/jest": "^27",
|