@modern-js/server 1.6.0 → 1.15.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/CHANGELOG.md +18 -0
- package/dist/js/modern/dev-tools/babel/register.js +62 -19
- package/dist/js/modern/server/dev-server.js +2 -2
- package/dist/js/node/dev-tools/babel/register.js +69 -19
- package/dist/js/node/server/dev-server.js +2 -2
- package/dist/types/server/dev-server.d.ts +1 -1
- package/package.json +19 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @modern-js/server
|
|
2
2
|
|
|
3
|
+
## 1.15.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b1f7000: fix: Adjust createServer logic in bff test plugin
|
|
8
|
+
fix: 调整 BFF 测试中 create server 的逻辑
|
|
9
|
+
- Updated dependencies [8658a78]
|
|
10
|
+
- Updated dependencies [0df4970]
|
|
11
|
+
- Updated dependencies [05d4a4f]
|
|
12
|
+
- Updated dependencies [ad05af9]
|
|
13
|
+
- Updated dependencies [5d53d1c]
|
|
14
|
+
- Updated dependencies [c087148]
|
|
15
|
+
- Updated dependencies [37cd159]
|
|
16
|
+
- @modern-js/utils@1.15.0
|
|
17
|
+
- @modern-js/webpack@1.15.0
|
|
18
|
+
- @modern-js/prod-server@1.15.0
|
|
19
|
+
- @modern-js/server-utils@1.15.0
|
|
20
|
+
|
|
3
21
|
## 1.6.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -6,28 +6,71 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
6
6
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { resolveBabelConfig } from '@modern-js/server-utils';
|
|
9
|
+
import { fs, getAlias } from '@modern-js/utils';
|
|
10
|
+
import * as tsNode from 'ts-node';
|
|
11
|
+
import * as tsConfigPaths from 'tsconfig-paths';
|
|
9
12
|
const registerDirs = ['./api', './server', './config/mock', './shared'];
|
|
10
|
-
export const enableRegister = (projectRoot, config
|
|
13
|
+
export const enableRegister = (projectRoot, config // eslint-disable-next-line consistent-return
|
|
14
|
+
) => {
|
|
11
15
|
const TS_CONFIG_FILENAME = `tsconfig.json`;
|
|
12
16
|
const tsconfigPath = path.resolve(projectRoot, TS_CONFIG_FILENAME);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
const isTsProject = fs.existsSync(tsconfigPath);
|
|
18
|
+
|
|
19
|
+
if (isTsProject) {
|
|
20
|
+
const {
|
|
21
|
+
alias
|
|
22
|
+
} = config.source;
|
|
23
|
+
const aliasOption = getAlias(alias || {}, {
|
|
24
|
+
appDirectory: projectRoot,
|
|
25
|
+
tsconfigPath
|
|
26
|
+
});
|
|
27
|
+
const {
|
|
28
|
+
paths = {},
|
|
29
|
+
absoluteBaseUrl = './'
|
|
30
|
+
} = aliasOption;
|
|
31
|
+
const tsPaths = Object.keys(paths).reduce((o, key) => {
|
|
32
|
+
let tsPath = paths[key]; // 要不要把对 modern 的判断去掉
|
|
33
|
+
|
|
34
|
+
if (typeof tsPath === 'string' && path.isAbsolute(tsPath)) {
|
|
35
|
+
tsPath = path.relative(absoluteBaseUrl, tsPath);
|
|
24
36
|
}
|
|
25
37
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
if (typeof tsPath === 'string') {
|
|
39
|
+
tsPath = [tsPath];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return _objectSpread(_objectSpread({}, o), {}, {
|
|
43
|
+
[`${key}`]: tsPath
|
|
44
|
+
});
|
|
45
|
+
}, {});
|
|
46
|
+
tsConfigPaths.register({
|
|
47
|
+
baseUrl: absoluteBaseUrl || './',
|
|
48
|
+
paths: tsPaths
|
|
49
|
+
});
|
|
50
|
+
tsNode.register({
|
|
51
|
+
project: tsconfigPath,
|
|
52
|
+
transpileOnly: true
|
|
53
|
+
});
|
|
54
|
+
} else {
|
|
55
|
+
const babelConfig = resolveBabelConfig(projectRoot, config, {
|
|
56
|
+
tsconfigPath,
|
|
57
|
+
syntax: 'es6+',
|
|
58
|
+
type: 'commonjs'
|
|
59
|
+
});
|
|
60
|
+
return require('@babel/register')(_objectSpread(_objectSpread({}, babelConfig), {}, {
|
|
61
|
+
only: [function (filePath) {
|
|
62
|
+
// TODO: wait params
|
|
63
|
+
// FIXME: 删除hardcode,根据 AppContext 中的 metaName 设置路径
|
|
64
|
+
if (filePath.includes(`node_modules${path.sep}.modern-js`)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return registerDirs.some(registerDir => filePath.startsWith(path.join(projectRoot, registerDir)));
|
|
69
|
+
}],
|
|
70
|
+
extensions: ['.js', '.ts'],
|
|
71
|
+
babelrc: false,
|
|
72
|
+
configFile: false,
|
|
73
|
+
root: projectRoot
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
33
76
|
};
|
|
@@ -138,10 +138,10 @@ export class ModernDevServer extends ModernServer {
|
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
async onClose() {
|
|
141
|
-
var _this$socketServer;
|
|
141
|
+
var _this$watcher, _this$socketServer;
|
|
142
142
|
|
|
143
143
|
await super.onClose();
|
|
144
|
-
await this.watcher.close();
|
|
144
|
+
await ((_this$watcher = this.watcher) === null || _this$watcher === void 0 ? void 0 : _this$watcher.close());
|
|
145
145
|
await new Promise(resolve => {
|
|
146
146
|
if (this.devMiddleware) {
|
|
147
147
|
this.devMiddleware.close(() => {
|
|
@@ -9,6 +9,16 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
9
9
|
|
|
10
10
|
var _serverUtils = require("@modern-js/server-utils");
|
|
11
11
|
|
|
12
|
+
var _utils = require("@modern-js/utils");
|
|
13
|
+
|
|
14
|
+
var tsNode = _interopRequireWildcard(require("ts-node"));
|
|
15
|
+
|
|
16
|
+
var tsConfigPaths = _interopRequireWildcard(require("tsconfig-paths"));
|
|
17
|
+
|
|
18
|
+
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); }
|
|
19
|
+
|
|
20
|
+
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; }
|
|
21
|
+
|
|
12
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
23
|
|
|
14
24
|
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,31 +29,71 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
19
29
|
|
|
20
30
|
const registerDirs = ['./api', './server', './config/mock', './shared'];
|
|
21
31
|
|
|
22
|
-
const enableRegister = (projectRoot, config
|
|
32
|
+
const enableRegister = (projectRoot, config // eslint-disable-next-line consistent-return
|
|
33
|
+
) => {
|
|
23
34
|
const TS_CONFIG_FILENAME = `tsconfig.json`;
|
|
24
35
|
|
|
25
36
|
const tsconfigPath = _path.default.resolve(projectRoot, TS_CONFIG_FILENAME);
|
|
26
37
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
const isTsProject = _utils.fs.existsSync(tsconfigPath);
|
|
39
|
+
|
|
40
|
+
if (isTsProject) {
|
|
41
|
+
const {
|
|
42
|
+
alias
|
|
43
|
+
} = config.source;
|
|
44
|
+
const aliasOption = (0, _utils.getAlias)(alias || {}, {
|
|
45
|
+
appDirectory: projectRoot,
|
|
46
|
+
tsconfigPath
|
|
47
|
+
});
|
|
48
|
+
const {
|
|
49
|
+
paths = {},
|
|
50
|
+
absoluteBaseUrl = './'
|
|
51
|
+
} = aliasOption;
|
|
52
|
+
const tsPaths = Object.keys(paths).reduce((o, key) => {
|
|
53
|
+
let tsPath = paths[key]; // 要不要把对 modern 的判断去掉
|
|
54
|
+
|
|
55
|
+
if (typeof tsPath === 'string' && _path.default.isAbsolute(tsPath)) {
|
|
56
|
+
tsPath = _path.default.relative(absoluteBaseUrl, tsPath);
|
|
38
57
|
}
|
|
39
58
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
59
|
+
if (typeof tsPath === 'string') {
|
|
60
|
+
tsPath = [tsPath];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return _objectSpread(_objectSpread({}, o), {}, {
|
|
64
|
+
[`${key}`]: tsPath
|
|
65
|
+
});
|
|
66
|
+
}, {});
|
|
67
|
+
tsConfigPaths.register({
|
|
68
|
+
baseUrl: absoluteBaseUrl || './',
|
|
69
|
+
paths: tsPaths
|
|
70
|
+
});
|
|
71
|
+
tsNode.register({
|
|
72
|
+
project: tsconfigPath,
|
|
73
|
+
transpileOnly: true
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
const babelConfig = (0, _serverUtils.resolveBabelConfig)(projectRoot, config, {
|
|
77
|
+
tsconfigPath,
|
|
78
|
+
syntax: 'es6+',
|
|
79
|
+
type: 'commonjs'
|
|
80
|
+
});
|
|
81
|
+
return require('@babel/register')(_objectSpread(_objectSpread({}, babelConfig), {}, {
|
|
82
|
+
only: [function (filePath) {
|
|
83
|
+
// TODO: wait params
|
|
84
|
+
// FIXME: 删除hardcode,根据 AppContext 中的 metaName 设置路径
|
|
85
|
+
if (filePath.includes(`node_modules${_path.default.sep}.modern-js`)) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return registerDirs.some(registerDir => filePath.startsWith(_path.default.join(projectRoot, registerDir)));
|
|
90
|
+
}],
|
|
91
|
+
extensions: ['.js', '.ts'],
|
|
92
|
+
babelrc: false,
|
|
93
|
+
configFile: false,
|
|
94
|
+
root: projectRoot
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
47
97
|
};
|
|
48
98
|
|
|
49
99
|
exports.enableRegister = enableRegister;
|
|
@@ -163,10 +163,10 @@ class ModernDevServer extends _prodServer.ModernServer {
|
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
async onClose() {
|
|
166
|
-
var _this$socketServer;
|
|
166
|
+
var _this$watcher, _this$socketServer;
|
|
167
167
|
|
|
168
168
|
await super.onClose();
|
|
169
|
-
await this.watcher.close();
|
|
169
|
+
await ((_this$watcher = this.watcher) === null || _this$watcher === void 0 ? void 0 : _this$watcher.close());
|
|
170
170
|
await new Promise(resolve => {
|
|
171
171
|
if (this.devMiddleware) {
|
|
172
172
|
this.devMiddleware.close(() => {
|
|
@@ -9,7 +9,7 @@ export declare class ModernDevServer extends ModernServer {
|
|
|
9
9
|
private readonly dev;
|
|
10
10
|
private readonly compiler?;
|
|
11
11
|
private socketServer;
|
|
12
|
-
private watcher
|
|
12
|
+
private watcher?;
|
|
13
13
|
private devMiddleware;
|
|
14
14
|
constructor(options: ModernDevServerOptions);
|
|
15
15
|
private getDevOptions;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.15.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",
|
|
@@ -30,29 +30,34 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@babel/core": "^7.18.0",
|
|
32
32
|
"@babel/register": "^7.17.7",
|
|
33
|
-
"@modern-js/prod-server": "
|
|
34
|
-
"@modern-js/server-utils": "
|
|
35
|
-
"@modern-js/
|
|
36
|
-
"@modern-js/
|
|
33
|
+
"@modern-js/prod-server": "1.15.0",
|
|
34
|
+
"@modern-js/server-utils": "1.15.0",
|
|
35
|
+
"@modern-js/utils": "1.15.0",
|
|
36
|
+
"@modern-js/webpack": "1.15.0",
|
|
37
37
|
"devcert": "^1.2.2",
|
|
38
38
|
"minimatch": "^3.0.4",
|
|
39
39
|
"path-to-regexp": "^6.2.0",
|
|
40
|
+
"tsconfig-paths": "3.14.1",
|
|
40
41
|
"ws": "^8.2.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
|
-
"@modern-js/core": "1.
|
|
44
|
-
"@modern-js/server-core": "1.
|
|
45
|
-
"@modern-js/types": "1.
|
|
46
|
-
"@scripts/build": "
|
|
47
|
-
"@scripts/jest-config": "
|
|
44
|
+
"@modern-js/core": "1.15.0",
|
|
45
|
+
"@modern-js/server-core": "1.15.0",
|
|
46
|
+
"@modern-js/types": "1.15.0",
|
|
47
|
+
"@scripts/build": "1.15.0",
|
|
48
|
+
"@scripts/jest-config": "1.15.0",
|
|
48
49
|
"@types/jest": "^27",
|
|
49
50
|
"@types/minimatch": "^3.0.5",
|
|
50
51
|
"@types/node": "^14",
|
|
51
52
|
"@types/ws": "^7.4.7",
|
|
52
53
|
"jest": "^27",
|
|
54
|
+
"ts-node": "^10.1.0",
|
|
53
55
|
"typescript": "^4",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
+
"webpack": "^5.71.0",
|
|
57
|
+
"websocket": "^1"
|
|
58
|
+
},
|
|
59
|
+
"peerDependencies": {
|
|
60
|
+
"ts-node": "^10.1.0"
|
|
56
61
|
},
|
|
57
62
|
"sideEffects": false,
|
|
58
63
|
"modernConfig": {
|
|
@@ -62,7 +67,8 @@
|
|
|
62
67
|
},
|
|
63
68
|
"publishConfig": {
|
|
64
69
|
"registry": "https://registry.npmjs.org/",
|
|
65
|
-
"access": "public"
|
|
70
|
+
"access": "public",
|
|
71
|
+
"types": "./dist/types/index.d.ts"
|
|
66
72
|
},
|
|
67
73
|
"wireit": {
|
|
68
74
|
"build": {
|