@modern-js/server-utils 2.0.0-beta.2 → 2.0.0-beta.4
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 +102 -0
- package/dist/js/modern/common/index.js +42 -17
- package/dist/js/modern/compilers/babel/index.js +128 -82
- package/dist/js/modern/compilers/typescript/index.js +87 -61
- package/dist/js/modern/compilers/typescript/tsconfig-paths-plugin.js +77 -47
- package/dist/js/modern/compilers/typescript/typescript-loader.js +10 -10
- package/dist/js/modern/index.js +4 -1
- package/dist/js/node/common/index.js +68 -28
- package/dist/js/node/compilers/babel/index.js +151 -113
- package/dist/js/node/compilers/typescript/index.js +118 -75
- package/dist/js/node/compilers/typescript/tsconfig-paths-plugin.js +102 -55
- package/dist/js/node/compilers/typescript/typescript-loader.js +26 -14
- package/dist/js/node/index.js +22 -24
- package/dist/js/treeshaking/common/index.js +199 -60
- package/dist/js/treeshaking/compilers/babel/index.js +362 -136
- package/dist/js/treeshaking/compilers/typescript/index.js +332 -149
- package/dist/js/treeshaking/compilers/typescript/tsconfig-paths-plugin.js +229 -154
- package/dist/js/treeshaking/compilers/typescript/typescript-loader.js +63 -28
- package/dist/js/treeshaking/index.js +2 -1
- package/package.json +8 -9
|
@@ -1,105 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
compileByTs: () => compileByTs
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var import_path = __toESM(require("path"));
|
|
30
|
+
var import_utils = require("@modern-js/utils");
|
|
31
|
+
var import_typescript = __toESM(require("typescript"));
|
|
32
|
+
var import_typescript_loader = require("./typescript-loader");
|
|
33
|
+
var import_tsconfig_paths_plugin = require("./tsconfig-paths-plugin");
|
|
34
|
+
var __defProp2 = Object.defineProperty;
|
|
35
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
36
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
37
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
38
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
39
|
+
var __spreadValues = (a, b) => {
|
|
40
|
+
for (var prop in b || (b = {}))
|
|
41
|
+
if (__hasOwnProp2.call(b, prop))
|
|
42
|
+
__defNormalProp(a, prop, b[prop]);
|
|
43
|
+
if (__getOwnPropSymbols)
|
|
44
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
45
|
+
if (__propIsEnum.call(b, prop))
|
|
46
|
+
__defNormalProp(a, prop, b[prop]);
|
|
47
|
+
}
|
|
48
|
+
return a;
|
|
49
|
+
};
|
|
50
|
+
var __async = (__this, __arguments, generator) => {
|
|
51
|
+
return new Promise((resolve, reject) => {
|
|
52
|
+
var fulfilled = (value) => {
|
|
53
|
+
try {
|
|
54
|
+
step(generator.next(value));
|
|
55
|
+
} catch (e) {
|
|
56
|
+
reject(e);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
var rejected = (value) => {
|
|
60
|
+
try {
|
|
61
|
+
step(generator.throw(value));
|
|
62
|
+
} catch (e) {
|
|
63
|
+
reject(e);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
67
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
68
|
+
});
|
|
28
69
|
};
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
70
|
+
const readTsConfigByFile = (tsConfigFile) => {
|
|
71
|
+
const parsedCmd = import_typescript.default.getParsedCommandLineOfConfigFile(
|
|
72
|
+
tsConfigFile,
|
|
73
|
+
void 0,
|
|
74
|
+
import_typescript.default.sys
|
|
75
|
+
);
|
|
76
|
+
const { options, fileNames, projectReferences } = parsedCmd;
|
|
77
|
+
return { options, fileNames, projectReferences };
|
|
78
|
+
};
|
|
79
|
+
const copyFiles = (from, to, tsconfigPath) => __async(void 0, null, function* () {
|
|
80
|
+
if (yield import_utils.fs.pathExists(from)) {
|
|
81
|
+
const basename = import_path.default.basename(from);
|
|
82
|
+
const targetDir = import_path.default.join(to, basename);
|
|
83
|
+
yield import_utils.fs.copy(from, targetDir, {
|
|
84
|
+
filter: (src) => ![".ts"].includes(import_path.default.extname(src)) && src !== tsconfigPath
|
|
35
85
|
});
|
|
36
86
|
}
|
|
37
|
-
};
|
|
38
|
-
const compileByTs =
|
|
39
|
-
|
|
40
|
-
const {
|
|
41
|
-
sourceDirs,
|
|
42
|
-
distDir,
|
|
43
|
-
tsconfigPath
|
|
44
|
-
} = compileOptions;
|
|
87
|
+
});
|
|
88
|
+
const compileByTs = (appDirectory, config, compileOptions) => __async(void 0, null, function* () {
|
|
89
|
+
import_utils.logger.info(`Running ts compile...`);
|
|
90
|
+
const { sourceDirs, distDir, tsconfigPath } = compileOptions;
|
|
45
91
|
if (!tsconfigPath) {
|
|
46
92
|
return;
|
|
47
93
|
}
|
|
48
|
-
const
|
|
94
|
+
const ts2 = new import_typescript_loader.TypescriptLoader({
|
|
49
95
|
appDirectory
|
|
50
96
|
}).load();
|
|
51
|
-
const createProgram =
|
|
52
|
-
const formatHost = getFormatHost(
|
|
53
|
-
const {
|
|
54
|
-
|
|
55
|
-
} = config;
|
|
56
|
-
const aliasOption = (0, _utils.getAliasConfig)(alias, {
|
|
97
|
+
const createProgram = ts2.createIncrementalProgram || ts2.createProgram;
|
|
98
|
+
const formatHost = getFormatHost(ts2);
|
|
99
|
+
const { alias } = config;
|
|
100
|
+
const aliasOption = (0, import_utils.getAliasConfig)(alias, {
|
|
57
101
|
appDirectory,
|
|
58
102
|
tsconfigPath
|
|
59
103
|
});
|
|
60
|
-
const {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
projectReferences
|
|
68
|
-
} = readTsConfigByFile(tsconfigPath);
|
|
69
|
-
const sourcePosixPaths = sourceDirs.map(sourceDir => sourceDir.split(_path.default.sep).join(_path.default.posix.sep));
|
|
70
|
-
const rootNames = fileNames.filter(fileName => {
|
|
71
|
-
return fileName.endsWith('.d.ts') || sourcePosixPaths.some(sourceDir => {
|
|
104
|
+
const { paths = {}, absoluteBaseUrl = "./" } = aliasOption;
|
|
105
|
+
const { options, fileNames, projectReferences } = readTsConfigByFile(tsconfigPath);
|
|
106
|
+
const sourcePosixPaths = sourceDirs.map(
|
|
107
|
+
(sourceDir) => sourceDir.split(import_path.default.sep).join(import_path.default.posix.sep)
|
|
108
|
+
);
|
|
109
|
+
const rootNames = fileNames.filter((fileName) => {
|
|
110
|
+
return fileName.endsWith(".d.ts") || sourcePosixPaths.some((sourceDir) => {
|
|
72
111
|
return fileName.includes(sourceDir);
|
|
73
112
|
});
|
|
74
113
|
});
|
|
75
|
-
const program = createProgram.call(
|
|
114
|
+
const program = createProgram.call(ts2, {
|
|
76
115
|
rootNames,
|
|
77
116
|
projectReferences,
|
|
78
|
-
options:
|
|
117
|
+
options: __spreadValues({
|
|
79
118
|
rootDir: appDirectory,
|
|
80
119
|
outDir: distDir
|
|
81
120
|
}, options)
|
|
82
121
|
});
|
|
83
|
-
const tsconfigPathsPlugin = (0,
|
|
84
|
-
|
|
122
|
+
const tsconfigPathsPlugin = (0, import_tsconfig_paths_plugin.tsconfigPathsBeforeHookFactory)(
|
|
123
|
+
ts2,
|
|
124
|
+
absoluteBaseUrl,
|
|
125
|
+
paths
|
|
126
|
+
);
|
|
127
|
+
const emitResult = program.emit(void 0, void 0, void 0, void 0, {
|
|
85
128
|
before: [tsconfigPathsPlugin]
|
|
86
129
|
});
|
|
87
|
-
const allDiagnostics =
|
|
130
|
+
const allDiagnostics = ts2.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
88
131
|
if (allDiagnostics.length > 0) {
|
|
89
|
-
|
|
90
|
-
|
|
132
|
+
import_utils.logger.error(
|
|
133
|
+
ts2.formatDiagnosticsWithColorAndContext(allDiagnostics, formatHost)
|
|
134
|
+
);
|
|
91
135
|
process.exit(1);
|
|
92
136
|
}
|
|
93
137
|
for (const source of sourceDirs) {
|
|
94
|
-
|
|
138
|
+
yield copyFiles(source, distDir, tsconfigPath);
|
|
95
139
|
}
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const getFormatHost = ts => {
|
|
140
|
+
import_utils.logger.info(`Ts compile succeed`);
|
|
141
|
+
});
|
|
142
|
+
const getFormatHost = (ts2) => {
|
|
100
143
|
return {
|
|
101
|
-
getCanonicalFileName:
|
|
102
|
-
getCurrentDirectory:
|
|
103
|
-
getNewLine: () =>
|
|
144
|
+
getCanonicalFileName: (path2) => path2,
|
|
145
|
+
getCurrentDirectory: ts2.sys.getCurrentDirectory,
|
|
146
|
+
getNewLine: () => ts2.sys.newLine
|
|
104
147
|
};
|
|
105
|
-
};
|
|
148
|
+
};
|
|
@@ -1,22 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var stdin_exports = {};
|
|
25
|
+
__export(stdin_exports, {
|
|
26
|
+
tsconfigPathsBeforeHookFactory: () => tsconfigPathsBeforeHookFactory
|
|
5
27
|
});
|
|
6
|
-
exports
|
|
7
|
-
var os =
|
|
8
|
-
var
|
|
9
|
-
var ts =
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const isRegExpKey = str => {
|
|
14
|
-
return str.startsWith('^') || str.endsWith('$');
|
|
28
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
29
|
+
var os = __toESM(require("os"));
|
|
30
|
+
var import_path = __toESM(require("path"));
|
|
31
|
+
var ts = __toESM(require("typescript"));
|
|
32
|
+
var import_tsconfig_paths = require("@modern-js/utils/tsconfig-paths");
|
|
33
|
+
const isRegExpKey = (str) => {
|
|
34
|
+
return str.startsWith("^") || str.endsWith("$");
|
|
15
35
|
};
|
|
16
36
|
const resolveAliasPath = (baseUrl, filePath) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
return _path.default.resolve(baseUrl, filePath);
|
|
37
|
+
if (filePath.startsWith(".") || filePath.startsWith("..")) {
|
|
38
|
+
return import_path.default.resolve(baseUrl, filePath);
|
|
20
39
|
}
|
|
21
40
|
return filePath;
|
|
22
41
|
};
|
|
@@ -32,10 +51,8 @@ const createAliasMatcher = (baseUrl, alias) => {
|
|
|
32
51
|
}
|
|
33
52
|
return o;
|
|
34
53
|
}, []);
|
|
35
|
-
const cacheMap = new Map();
|
|
36
|
-
|
|
37
|
-
// eslint-disable-next-line consistent-return
|
|
38
|
-
return requestedModule => {
|
|
54
|
+
const cacheMap = /* @__PURE__ */ new Map();
|
|
55
|
+
return (requestedModule) => {
|
|
39
56
|
if (cacheMap.has(requestedModule)) {
|
|
40
57
|
return cacheMap.get(requestedModule);
|
|
41
58
|
}
|
|
@@ -59,7 +76,7 @@ const isDynamicImport = (tsBinary, node) => {
|
|
|
59
76
|
function tsconfigPathsBeforeHookFactory(tsBinary, baseUrl, paths) {
|
|
60
77
|
const tsPaths = {};
|
|
61
78
|
const alias = {};
|
|
62
|
-
Object.keys(paths).forEach(key => {
|
|
79
|
+
Object.keys(paths).forEach((key) => {
|
|
63
80
|
if (Array.isArray(paths[key])) {
|
|
64
81
|
tsPaths[key] = paths[key];
|
|
65
82
|
} else {
|
|
@@ -67,37 +84,55 @@ function tsconfigPathsBeforeHookFactory(tsBinary, baseUrl, paths) {
|
|
|
67
84
|
}
|
|
68
85
|
});
|
|
69
86
|
const matchAliasPath = createAliasMatcher(baseUrl, alias);
|
|
70
|
-
const matchTsPath = (0,
|
|
87
|
+
const matchTsPath = (0, import_tsconfig_paths.createMatchPath)(baseUrl, tsPaths, ["main"]);
|
|
71
88
|
const matchPath = (requestedModule, readJSONSync, fileExists, extensions) => {
|
|
72
|
-
const result = matchTsPath(
|
|
89
|
+
const result = matchTsPath(
|
|
90
|
+
requestedModule,
|
|
91
|
+
readJSONSync,
|
|
92
|
+
fileExists,
|
|
93
|
+
extensions
|
|
94
|
+
);
|
|
73
95
|
if (result) {
|
|
74
96
|
return result;
|
|
75
97
|
}
|
|
76
98
|
return matchAliasPath(requestedModule);
|
|
77
99
|
};
|
|
78
100
|
if (Object.keys(paths).length === 0) {
|
|
79
|
-
return
|
|
101
|
+
return void 0;
|
|
80
102
|
}
|
|
81
|
-
return ctx => {
|
|
82
|
-
return sf => {
|
|
83
|
-
const visitNode = node => {
|
|
103
|
+
return (ctx) => {
|
|
104
|
+
return (sf) => {
|
|
105
|
+
const visitNode = (node) => {
|
|
106
|
+
var _a;
|
|
84
107
|
if (isDynamicImport(tsBinary, node)) {
|
|
85
108
|
const importPathWithQuotes = node.arguments[0].getText(sf);
|
|
86
|
-
const text = importPathWithQuotes.slice(
|
|
109
|
+
const text = importPathWithQuotes.slice(
|
|
110
|
+
1,
|
|
111
|
+
importPathWithQuotes.length - 1
|
|
112
|
+
);
|
|
87
113
|
const result = getNotAliasedPath(sf, matchPath, text);
|
|
88
114
|
if (!result) {
|
|
89
115
|
return node;
|
|
90
116
|
}
|
|
91
|
-
return tsBinary.factory.updateCallExpression(
|
|
117
|
+
return tsBinary.factory.updateCallExpression(
|
|
118
|
+
node,
|
|
119
|
+
node.expression,
|
|
120
|
+
node.typeArguments,
|
|
121
|
+
tsBinary.factory.createNodeArray([
|
|
122
|
+
tsBinary.factory.createStringLiteral(result)
|
|
123
|
+
])
|
|
124
|
+
);
|
|
92
125
|
}
|
|
93
126
|
if (tsBinary.isImportDeclaration(node) || tsBinary.isExportDeclaration(node) && node.moduleSpecifier) {
|
|
94
127
|
try {
|
|
95
|
-
|
|
96
|
-
const importPathWithQuotes = node === null || node === void 0 ? void 0 : (_node$moduleSpecifier = node.moduleSpecifier) === null || _node$moduleSpecifier === void 0 ? void 0 : _node$moduleSpecifier.getText();
|
|
128
|
+
const importPathWithQuotes = (_a = node == null ? void 0 : node.moduleSpecifier) == null ? void 0 : _a.getText();
|
|
97
129
|
if (!importPathWithQuotes) {
|
|
98
130
|
return node;
|
|
99
131
|
}
|
|
100
|
-
const text = importPathWithQuotes.substring(
|
|
132
|
+
const text = importPathWithQuotes.substring(
|
|
133
|
+
1,
|
|
134
|
+
importPathWithQuotes.length - 1
|
|
135
|
+
);
|
|
101
136
|
const result = getNotAliasedPath(sf, matchPath, text);
|
|
102
137
|
if (!result) {
|
|
103
138
|
return node;
|
|
@@ -106,13 +141,28 @@ function tsconfigPathsBeforeHookFactory(tsBinary, baseUrl, paths) {
|
|
|
106
141
|
moduleSpecifier.parent = node.moduleSpecifier.parent;
|
|
107
142
|
let newNode;
|
|
108
143
|
if (tsBinary.isImportDeclaration(node)) {
|
|
109
|
-
newNode = tsBinary.factory.updateImportDeclaration(
|
|
144
|
+
newNode = tsBinary.factory.updateImportDeclaration(
|
|
145
|
+
node,
|
|
146
|
+
node.decorators,
|
|
147
|
+
node.modifiers,
|
|
148
|
+
node.importClause,
|
|
149
|
+
moduleSpecifier,
|
|
150
|
+
node.assertClause
|
|
151
|
+
);
|
|
110
152
|
} else {
|
|
111
|
-
newNode = tsBinary.factory.updateExportDeclaration(
|
|
153
|
+
newNode = tsBinary.factory.updateExportDeclaration(
|
|
154
|
+
node,
|
|
155
|
+
node.decorators,
|
|
156
|
+
node.modifiers,
|
|
157
|
+
node.isTypeOnly,
|
|
158
|
+
node.exportClause,
|
|
159
|
+
moduleSpecifier,
|
|
160
|
+
node.assertClause
|
|
161
|
+
);
|
|
112
162
|
}
|
|
113
163
|
newNode.flags = node.flags;
|
|
114
164
|
return newNode;
|
|
115
|
-
} catch (
|
|
165
|
+
} catch (e) {
|
|
116
166
|
return node;
|
|
117
167
|
}
|
|
118
168
|
}
|
|
@@ -122,44 +172,41 @@ function tsconfigPathsBeforeHookFactory(tsBinary, baseUrl, paths) {
|
|
|
122
172
|
};
|
|
123
173
|
};
|
|
124
174
|
}
|
|
125
|
-
|
|
126
|
-
// fork from https://github.com/nestjs/nest-cli/blob/HEAD/lib/compiler/hooks/tsconfig-paths.hook.ts
|
|
127
175
|
function getNotAliasedPath(sf, matcher, text) {
|
|
128
|
-
let result = matcher(text,
|
|
176
|
+
let result = matcher(text, void 0, void 0, [
|
|
177
|
+
".ts",
|
|
178
|
+
".tsx",
|
|
179
|
+
".js",
|
|
180
|
+
".jsx"
|
|
181
|
+
]);
|
|
129
182
|
if (!result) {
|
|
130
183
|
return;
|
|
131
184
|
}
|
|
132
|
-
if (os.platform() ===
|
|
133
|
-
result = result.replace(/\\/g,
|
|
185
|
+
if (os.platform() === "win32") {
|
|
186
|
+
result = result.replace(/\\/g, "/");
|
|
134
187
|
}
|
|
135
|
-
if (!
|
|
136
|
-
|
|
137
|
-
if (!result.startsWith('.') && !result.startsWith('..')) {
|
|
188
|
+
if (!import_path.default.isAbsolute(result)) {
|
|
189
|
+
if (!result.startsWith(".") && !result.startsWith("..")) {
|
|
138
190
|
try {
|
|
139
|
-
// Installed packages (node modules) should take precedence over root files with the same name.
|
|
140
|
-
// Ref: https://github.com/nestjs/nest-cli/issues/838
|
|
141
191
|
const packagePath = require.resolve(result, {
|
|
142
192
|
paths: [process.cwd(), ...module.paths]
|
|
143
193
|
});
|
|
144
194
|
if (packagePath) {
|
|
145
|
-
// eslint-disable-next-line consistent-return
|
|
146
195
|
return result;
|
|
147
196
|
}
|
|
148
|
-
} catch (
|
|
197
|
+
} catch (e) {
|
|
198
|
+
}
|
|
149
199
|
}
|
|
150
200
|
try {
|
|
151
|
-
// Installed packages (node modules) should take precedence over root files with the same name.
|
|
152
|
-
// Ref: https://github.com/nestjs/nest-cli/issues/838
|
|
153
201
|
const packagePath = require.resolve(text, {
|
|
154
202
|
paths: [process.cwd(), ...module.paths]
|
|
155
203
|
});
|
|
156
204
|
if (packagePath) {
|
|
157
|
-
// eslint-disable-next-line consistent-return
|
|
158
205
|
return text;
|
|
159
206
|
}
|
|
160
|
-
} catch (
|
|
207
|
+
} catch (e) {
|
|
208
|
+
}
|
|
161
209
|
}
|
|
162
|
-
const resolvedPath =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
210
|
+
const resolvedPath = import_path.posix.relative((0, import_path.dirname)(sf.fileName), result) || "./";
|
|
211
|
+
return resolvedPath[0] === "." ? resolvedPath : `./${resolvedPath}`;
|
|
212
|
+
}
|
|
@@ -1,16 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var stdin_exports = {};
|
|
19
|
+
__export(stdin_exports, {
|
|
20
|
+
TypescriptLoader: () => TypescriptLoader
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
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; }
|
|
22
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
8
23
|
class TypescriptLoader {
|
|
9
|
-
constructor({
|
|
10
|
-
appDirectory
|
|
11
|
-
}) {
|
|
12
|
-
_defineProperty(this, "tsBinary", void 0);
|
|
13
|
-
_defineProperty(this, "appDirectory", void 0);
|
|
24
|
+
constructor({ appDirectory }) {
|
|
14
25
|
this.appDirectory = appDirectory;
|
|
15
26
|
}
|
|
16
27
|
load() {
|
|
@@ -18,14 +29,15 @@ class TypescriptLoader {
|
|
|
18
29
|
return this.tsBinary;
|
|
19
30
|
}
|
|
20
31
|
try {
|
|
21
|
-
const tsPath = require.resolve(
|
|
32
|
+
const tsPath = require.resolve("typescript", {
|
|
22
33
|
paths: [this.appDirectory || process.cwd()]
|
|
23
34
|
});
|
|
24
35
|
const ts = require(tsPath);
|
|
25
36
|
return ts;
|
|
26
37
|
} catch (error) {
|
|
27
|
-
throw new Error(
|
|
38
|
+
throw new Error(
|
|
39
|
+
'TypeScript could not be found! Please, install "typescript" package.'
|
|
40
|
+
);
|
|
28
41
|
}
|
|
29
42
|
}
|
|
30
43
|
}
|
|
31
|
-
exports.TypescriptLoader = TypescriptLoader;
|
package/dist/js/node/index.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var
|
|
7
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
8
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
14
|
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var stdin_exports = {};
|
|
20
|
+
__export(stdin_exports, {
|
|
21
|
+
compile: () => import_common.compile
|
|
14
22
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
-
if (key in exports && exports[key] === _babel[key]) return;
|
|
20
|
-
Object.defineProperty(exports, key, {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
get: function () {
|
|
23
|
-
return _babel[key];
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
var _common = require("./common");
|
|
23
|
+
module.exports = __toCommonJS(stdin_exports);
|
|
24
|
+
__reExport(stdin_exports, require("./compilers/babel"), module.exports);
|
|
25
|
+
var import_common = require("./common");
|