@modern-js/server 1.15.1-beta.1 → 1.15.1-beta.2
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.
|
@@ -7,16 +7,33 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
import path from 'path';
|
|
8
8
|
import { resolveBabelConfig } from '@modern-js/server-utils';
|
|
9
9
|
import { fs, getAlias } from '@modern-js/utils';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
|
|
11
|
+
const checkDep = (depName, paths) => {
|
|
12
|
+
let packagePath = '';
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
packagePath = require.resolve('ts-node', {
|
|
16
|
+
paths
|
|
17
|
+
});
|
|
18
|
+
} catch (error) {}
|
|
19
|
+
|
|
20
|
+
return Boolean(packagePath);
|
|
21
|
+
};
|
|
22
|
+
|
|
13
23
|
export const enableRegister = (projectRoot, config // eslint-disable-next-line consistent-return
|
|
14
24
|
) => {
|
|
25
|
+
const registerDirs = ['./api', './server', './config/mock', './shared'];
|
|
15
26
|
const TS_CONFIG_FILENAME = `tsconfig.json`;
|
|
16
27
|
const tsconfigPath = path.resolve(projectRoot, TS_CONFIG_FILENAME);
|
|
17
28
|
const isTsProject = fs.existsSync(tsconfigPath);
|
|
29
|
+
const existTsNode = checkDep('ts-node', [projectRoot]);
|
|
30
|
+
const existTsConfigPaths = checkDep('tsconfig-paths', [projectRoot]);
|
|
31
|
+
|
|
32
|
+
if (isTsProject && existTsNode && existTsConfigPaths) {
|
|
33
|
+
const tsNode = require('ts-node');
|
|
34
|
+
|
|
35
|
+
const tsConfigPaths = require('tsconfig-paths');
|
|
18
36
|
|
|
19
|
-
if (isTsProject) {
|
|
20
37
|
const {
|
|
21
38
|
alias
|
|
22
39
|
} = config.source;
|
|
@@ -11,14 +11,6 @@ var _serverUtils = require("@modern-js/server-utils");
|
|
|
11
11
|
|
|
12
12
|
var _utils = require("@modern-js/utils");
|
|
13
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
|
-
|
|
22
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
15
|
|
|
24
16
|
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; }
|
|
@@ -27,17 +19,35 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
27
19
|
|
|
28
20
|
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; }
|
|
29
21
|
|
|
30
|
-
const
|
|
22
|
+
const checkDep = (depName, paths) => {
|
|
23
|
+
let packagePath = '';
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
packagePath = require.resolve('ts-node', {
|
|
27
|
+
paths
|
|
28
|
+
});
|
|
29
|
+
} catch (error) {}
|
|
30
|
+
|
|
31
|
+
return Boolean(packagePath);
|
|
32
|
+
};
|
|
31
33
|
|
|
32
34
|
const enableRegister = (projectRoot, config // eslint-disable-next-line consistent-return
|
|
33
35
|
) => {
|
|
36
|
+
const registerDirs = ['./api', './server', './config/mock', './shared'];
|
|
34
37
|
const TS_CONFIG_FILENAME = `tsconfig.json`;
|
|
35
38
|
|
|
36
39
|
const tsconfigPath = _path.default.resolve(projectRoot, TS_CONFIG_FILENAME);
|
|
37
40
|
|
|
38
41
|
const isTsProject = _utils.fs.existsSync(tsconfigPath);
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
const existTsNode = checkDep('ts-node', [projectRoot]);
|
|
44
|
+
const existTsConfigPaths = checkDep('tsconfig-paths', [projectRoot]);
|
|
45
|
+
|
|
46
|
+
if (isTsProject && existTsNode && existTsConfigPaths) {
|
|
47
|
+
const tsNode = require('ts-node');
|
|
48
|
+
|
|
49
|
+
const tsConfigPaths = require('tsconfig-paths');
|
|
50
|
+
|
|
41
51
|
const {
|
|
42
52
|
alias
|
|
43
53
|
} = config.source;
|