@simplysm/sd-cli 12.8.22 → 12.9.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.
- package/dist/entry/sd-cli-ai-command.js +2 -1
- package/dist/entry/sd-cli-ai-command.js.map +1 -1
- package/dist/entry/sd-cli-cordova.d.ts +1 -1
- package/dist/entry/sd-cli-cordova.js +1 -1
- package/dist/entry/sd-cli-cordova.js.map +1 -1
- package/dist/entry/sd-cli-electron.d.ts +6 -6
- package/dist/entry/sd-cli-electron.js +15 -9
- package/dist/entry/sd-cli-electron.js.map +1 -1
- package/dist/entry/sd-cli-local-update.d.ts +5 -5
- package/dist/entry/sd-cli-local-update.js +8 -12
- package/dist/entry/sd-cli-local-update.js.map +1 -1
- package/dist/entry/sd-cli-project.d.ts +11 -11
- package/dist/entry/sd-cli-project.js +11 -14
- package/dist/entry/sd-cli-project.js.map +1 -1
- package/dist/entry/utils/loadProjConfAsync.d.ts +5 -0
- package/dist/entry/utils/loadProjConfAsync.js +8 -0
- package/dist/entry/utils/loadProjConfAsync.js.map +1 -0
- package/dist/pkg-builders/client/sd-client.build-runner.js +1 -1
- package/dist/pkg-builders/client/sd-client.build-runner.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.bundler-context.d.ts +6 -5
- package/dist/pkg-builders/client/sd-ng.bundler-context.js +6 -6
- package/dist/pkg-builders/client/sd-ng.bundler-context.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.bundler.d.ts +14 -13
- package/dist/pkg-builders/client/sd-ng.bundler.js +4 -1
- package/dist/pkg-builders/client/sd-ng.bundler.js.map +1 -1
- package/dist/pkg-builders/client/sd-ng.plugin-creator.js +4 -88
- package/dist/pkg-builders/client/sd-ng.plugin-creator.js.map +1 -1
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.js.map +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.d.ts +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +1 -1
- package/dist/pkg-builders/lib/sd-ts-lib.builder.js.map +1 -1
- package/dist/pkg-builders/sd-multi.build-runner.d.ts +4 -0
- package/dist/pkg-builders/sd-multi.build-runner.js +33 -25
- package/dist/pkg-builders/sd-multi.build-runner.js.map +1 -1
- package/dist/pkg-builders/server/sd-server.build-runner.js.map +1 -1
- package/dist/pkg-builders/server/sd-server.bundler.d.ts +6 -2
- package/dist/pkg-builders/server/sd-server.bundler.js +18 -19
- package/dist/pkg-builders/server/sd-server.bundler.js.map +1 -1
- package/dist/sd-cli/vitest.config.d.ts +2 -0
- package/dist/sd-cli/vitest.config.js +15 -0
- package/dist/sd-cli/vitest.config.js.map +1 -0
- package/dist/sd-cli.js +7 -36
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-compiler/sd-dependency-analyzer.d.ts +8 -0
- package/dist/ts-compiler/sd-dependency-analyzer.js +244 -0
- package/dist/ts-compiler/sd-dependency-analyzer.js.map +1 -0
- package/dist/ts-compiler/sd-dependency-cache.d.ts +27 -0
- package/dist/ts-compiler/sd-dependency-cache.js +232 -0
- package/dist/ts-compiler/sd-dependency-cache.js.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler.d.ts +8 -10
- package/dist/ts-compiler/sd-ts-compiler.js +106 -229
- package/dist/ts-compiler/sd-ts-compiler.js.map +1 -1
- package/dist/types/worker.types.d.ts +19 -0
- package/dist/utils/sd-cli-performance-time.d.ts +2 -1
- package/dist/utils/sd-cli-performance-time.js +9 -9
- package/dist/utils/sd-cli-performance-time.js.map +1 -1
- package/dist/workers/style-bundler.worker.d.ts +1 -0
- package/dist/workers/style-bundler.worker.js +56 -0
- package/dist/workers/style-bundler.worker.js.map +1 -0
- package/package.json +10 -10
- package/src/entry/sd-cli-ai-command.ts +2 -1
- package/src/entry/sd-cli-cordova.ts +5 -5
- package/src/entry/sd-cli-electron.ts +54 -23
- package/src/entry/sd-cli-local-update.ts +14 -29
- package/src/entry/sd-cli-project.ts +24 -41
- package/src/entry/utils/loadProjConfAsync.ts +12 -0
- package/src/pkg-builders/client/sd-client.build-runner.ts +7 -7
- package/src/pkg-builders/client/sd-ng.bundler-context.ts +15 -12
- package/src/pkg-builders/client/sd-ng.bundler.ts +21 -17
- package/src/pkg-builders/client/sd-ng.plugin-creator.ts +4 -93
- package/src/pkg-builders/lib/sd-js-lib.build-runner.ts +6 -6
- package/src/pkg-builders/lib/sd-ts-lib.build-runner.ts +7 -7
- package/src/pkg-builders/lib/sd-ts-lib.builder.ts +1 -1
- package/src/pkg-builders/sd-multi.build-runner.ts +54 -39
- package/src/pkg-builders/server/sd-server.build-runner.ts +6 -6
- package/src/pkg-builders/server/sd-server.bundler.ts +26 -28
- package/src/sd-cli.ts +7 -36
- package/src/ts-compiler/sd-dependency-analyzer.ts +312 -0
- package/src/ts-compiler/sd-dependency-cache.ts +328 -0
- package/src/ts-compiler/sd-ts-compiler.ts +165 -303
- package/src/types/worker.types.ts +17 -0
- package/src/utils/sd-cli-performance-time.ts +9 -9
- package/src/workers/style-bundler.worker.ts +70 -0
- package/tests/deps/sd-dependency-analyzer.spec.ts +272 -0
- package/tests/deps/sd-dependency-cache.spec.ts +144 -0
- package/tsconfig.json +1 -1
- package/tsconfig.test.json +8 -0
- package/vitest.config.ts +15 -0
- package/dist/index.d.ts +0 -34
- package/dist/index.js +0 -35
- package/dist/index.js.map +0 -1
- package/dist/ts-compiler/sd-ts-dependency-analyzer.d.ts +0 -6
- package/dist/ts-compiler/sd-ts-dependency-analyzer.js +0 -141
- package/dist/ts-compiler/sd-ts-dependency-analyzer.js.map +0 -1
- package/src/index.ts +0 -34
- package/src/ts-compiler/sd-ts-dependency-analyzer.ts +0 -185
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import * as ts from "typescript";
|
|
2
|
-
import { PathUtils } from "@simplysm/sd-core-node";
|
|
3
|
-
import * as module from "node:module";
|
|
4
|
-
import path from "path";
|
|
5
|
-
export class SdTsDependencyAnalyzer {
|
|
6
|
-
static analyze(program, compilerHost, scopePaths, allDepCacheMap) {
|
|
7
|
-
const compilerOpts = program.getCompilerOptions();
|
|
8
|
-
const visited = new Set();
|
|
9
|
-
const messages = [];
|
|
10
|
-
const getOrgSourceFile = (sf) => {
|
|
11
|
-
if (sf.fileName.endsWith(".ngtypecheck.ts")) {
|
|
12
|
-
const orgFileName = sf.fileName.slice(0, -15) + ".ts";
|
|
13
|
-
return program.getSourceFile(orgFileName);
|
|
14
|
-
}
|
|
15
|
-
return sf;
|
|
16
|
-
};
|
|
17
|
-
const inScope = (filePath) => {
|
|
18
|
-
return scopePaths.some((scope) => PathUtils.isChildPath(filePath, scope));
|
|
19
|
-
};
|
|
20
|
-
const resolveModule = (text, base) => {
|
|
21
|
-
/*const moduleResolutionHost: ts.ModuleResolutionHost = {
|
|
22
|
-
...compilerHost,
|
|
23
|
-
realpath: fs.realpathSync, // 필요 시
|
|
24
|
-
directoryExists: fs.existsSync,
|
|
25
|
-
getCurrentDirectory: () => process.cwd(),
|
|
26
|
-
};*/
|
|
27
|
-
const res = ts.resolveModuleName(text, base, compilerOpts, compilerHost);
|
|
28
|
-
if (res.resolvedModule) {
|
|
29
|
-
return { resolvedFileName: res.resolvedModule.resolvedFileName, isFallback: false };
|
|
30
|
-
}
|
|
31
|
-
const absPath = path.resolve(path.dirname(base), text);
|
|
32
|
-
if (compilerHost.fileExists(absPath)) {
|
|
33
|
-
return { resolvedFileName: absPath, isFallback: true };
|
|
34
|
-
}
|
|
35
|
-
return undefined;
|
|
36
|
-
};
|
|
37
|
-
const error = (sf, node, msg) => {
|
|
38
|
-
try {
|
|
39
|
-
const pos = ts.getLineAndCharacterOfPosition(sf, node.getStart());
|
|
40
|
-
messages.push({
|
|
41
|
-
filePath: PathUtils.norm(sf.fileName),
|
|
42
|
-
line: pos.line,
|
|
43
|
-
char: pos.character,
|
|
44
|
-
code: undefined,
|
|
45
|
-
severity: "error",
|
|
46
|
-
message: msg,
|
|
47
|
-
type: "deps",
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
catch {
|
|
51
|
-
messages.push({
|
|
52
|
-
filePath: PathUtils.norm(sf.fileName),
|
|
53
|
-
line: 0,
|
|
54
|
-
char: 0,
|
|
55
|
-
code: undefined,
|
|
56
|
-
severity: "error",
|
|
57
|
-
message: `${msg} (pos unknown)`,
|
|
58
|
-
type: "deps",
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const collectDeps = (sf) => {
|
|
63
|
-
const sfNPath = PathUtils.norm(sf.fileName);
|
|
64
|
-
if (allDepCacheMap.has(sfNPath))
|
|
65
|
-
return;
|
|
66
|
-
const deps = new Set();
|
|
67
|
-
const pushDep = (raw, node) => {
|
|
68
|
-
if (module.builtinModules.includes(raw.replace(/^node:/, "")))
|
|
69
|
-
return;
|
|
70
|
-
const resolved = resolveModule(raw, sf.fileName);
|
|
71
|
-
if (!resolved) {
|
|
72
|
-
error(sf, node, `파일 "${sf.fileName}"에서 "${raw}" 모듈을 해석할 수 없습니다.`);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (!inScope(resolved.resolvedFileName))
|
|
76
|
-
return;
|
|
77
|
-
const resolvedNPath = PathUtils.norm(resolved.resolvedFileName);
|
|
78
|
-
deps.add(resolvedNPath);
|
|
79
|
-
if (!visited.has(resolvedNPath) && !resolved.isFallback) {
|
|
80
|
-
visited.add(resolvedNPath);
|
|
81
|
-
const resolvedSf = program.getSourceFile(resolvedNPath);
|
|
82
|
-
if (!resolvedSf) {
|
|
83
|
-
error(sf, node, `모듈 "${raw}"은(는) "${resolved}" 파일로 해석되었으나, 해당 파일의 ts.SourceFile이 없습니다.`);
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
collectDeps(resolvedSf);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const visit = (node) => {
|
|
90
|
-
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
91
|
-
const spec = node.moduleSpecifier;
|
|
92
|
-
if (spec && ts.isStringLiteral(spec))
|
|
93
|
-
pushDep(spec.text, node);
|
|
94
|
-
}
|
|
95
|
-
else if (ts.isCallExpression(node) &&
|
|
96
|
-
node.expression.kind === ts.SyntaxKind.ImportKeyword &&
|
|
97
|
-
ts.isStringLiteral(node.arguments[0])) {
|
|
98
|
-
pushDep(node.arguments[0].text, node);
|
|
99
|
-
}
|
|
100
|
-
else if (ts.isCallExpression(node) &&
|
|
101
|
-
ts.isIdentifier(node.expression) &&
|
|
102
|
-
node.expression.text === "require" &&
|
|
103
|
-
node.arguments.length === 1 &&
|
|
104
|
-
ts.isStringLiteral(node.arguments[0])) {
|
|
105
|
-
pushDep(node.arguments[0].text, node);
|
|
106
|
-
}
|
|
107
|
-
else if (ts.isCallExpression(node) &&
|
|
108
|
-
ts.isPropertyAccessExpression(node.expression) &&
|
|
109
|
-
ts.isIdentifier(node.expression.expression) &&
|
|
110
|
-
node.expression.expression.text === "require" &&
|
|
111
|
-
node.expression.name.text === "resolve" &&
|
|
112
|
-
node.arguments.length === 1 &&
|
|
113
|
-
ts.isStringLiteral(node.arguments[0])) {
|
|
114
|
-
pushDep(node.arguments[0].text, node);
|
|
115
|
-
}
|
|
116
|
-
else if (ts.isCallExpression(node) &&
|
|
117
|
-
ts.isPropertyAccessExpression(node.expression) &&
|
|
118
|
-
ts.isMetaProperty(node.expression.expression) &&
|
|
119
|
-
node.expression.expression.keywordToken === ts.SyntaxKind.ImportKeyword &&
|
|
120
|
-
node.expression.name.text === "meta" &&
|
|
121
|
-
node.arguments.length === 1 &&
|
|
122
|
-
ts.isStringLiteral(node.arguments[0])) {
|
|
123
|
-
pushDep(node.arguments[0].text, node);
|
|
124
|
-
}
|
|
125
|
-
ts.forEachChild(node, visit);
|
|
126
|
-
};
|
|
127
|
-
ts.forEachChild(sf, visit);
|
|
128
|
-
allDepCacheMap.set(sfNPath, deps);
|
|
129
|
-
};
|
|
130
|
-
const sourceFileSet = new Set(program.getSourceFiles()
|
|
131
|
-
.map((sf) => getOrgSourceFile(sf))
|
|
132
|
-
.filterExists());
|
|
133
|
-
for (const sf of sourceFileSet) {
|
|
134
|
-
if (!inScope(sf.fileName))
|
|
135
|
-
continue;
|
|
136
|
-
collectDeps(sf);
|
|
137
|
-
}
|
|
138
|
-
return messages;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
//# sourceMappingURL=sd-ts-dependency-analyzer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sd-ts-dependency-analyzer.js","sourceRoot":"","sources":["../../src/ts-compiler/sd-ts-dependency-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,SAAS,EAAa,MAAM,wBAAwB,CAAC;AAE9D,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,OAAO,sBAAsB;IACjC,MAAM,CAAC,OAAO,CACZ,OAAmB,EACnB,YAA6B,EAC7B,UAAuB,EACvB,cAA8C;QAE9C,MAAM,YAAY,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;QAClD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAa,CAAC;QACrC,MAAM,QAAQ,GAAsB,EAAE,CAAC;QAEvC,MAAM,gBAAgB,GAAG,CAAC,EAAiB,EAAE,EAAE;YAC7C,IAAI,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;gBAC5C,MAAM,WAAW,GAAG,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC;gBACtD,OAAO,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAC5C,CAAC;YAED,OAAO,EAAE,CAAC;QACZ,CAAC,CAAC;QAEF,MAAM,OAAO,GAAG,CAAC,QAAgB,EAAW,EAAE;YAC5C,OAAO,UAAU,CAAC,IAAI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AAC;oBACD,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACxC,CAAC;gBACD,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC/B,CAAC,CAAC;YAEF,EAAE,CAAC,YAAY,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;YAC3B,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACpC,CAAC,CAAC;QAEF,MAAM,aAAa,GAAG,IAAI,GAAG,CAC3B,OAAO,CAAC,cAAc,EAAE;aACrB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;aACjC,YAAY,EAAE,CAClB,CAAC;QAEF,KAAK,MAAM,EAAE,IAAI,aAAa,EAAE,CAAC;YAC/B,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,QAAQ,CAAC;gBAAE,SAAS;YACpC,WAAW,CAAC,EAAE,CAAC,CAAC;QAClB,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
package/src/index.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export * from "./entry/sd-cli-ai-command";
|
|
2
|
-
export * from "./entry/sd-cli-cordova";
|
|
3
|
-
export * from "./entry/sd-cli-electron";
|
|
4
|
-
export * from "./entry/sd-cli-local-update";
|
|
5
|
-
export * from "./entry/sd-cli-postinstall";
|
|
6
|
-
export * from "./entry/sd-cli-project";
|
|
7
|
-
export * from "./pkg-builders/client/sd-cli-ng-routes.file-generator";
|
|
8
|
-
export * from "./pkg-builders/client/sd-client.build-runner";
|
|
9
|
-
export * from "./pkg-builders/client/sd-ng.bundler-context";
|
|
10
|
-
export * from "./pkg-builders/client/sd-ng.bundler";
|
|
11
|
-
export * from "./pkg-builders/client/sd-ng.plugin-creator";
|
|
12
|
-
export * from "./pkg-builders/lib/sd-cli-db-context.file-generator";
|
|
13
|
-
export * from "./pkg-builders/lib/sd-cli-index.file-generator";
|
|
14
|
-
export * from "./pkg-builders/lib/sd-js-lib.build-runner";
|
|
15
|
-
export * from "./pkg-builders/lib/sd-ts-lib.build-runner";
|
|
16
|
-
export * from "./pkg-builders/lib/sd-ts-lib.builder";
|
|
17
|
-
export * from "./pkg-builders/sd-multi.build-runner";
|
|
18
|
-
export * from "./pkg-builders/server/sd-server.build-runner";
|
|
19
|
-
export * from "./pkg-builders/server/sd-server.bundler";
|
|
20
|
-
export * from "./pkg-builders/server/sd-server.plugin-creator";
|
|
21
|
-
import "./sd-cli";
|
|
22
|
-
export * from "./ts-compiler/sd-ts-compiler";
|
|
23
|
-
export * from "./ts-compiler/sd-ts-dependency-analyzer";
|
|
24
|
-
export * from "./types/build-plugin.types";
|
|
25
|
-
export * from "./types/build-runner.types";
|
|
26
|
-
export * from "./types/build.types";
|
|
27
|
-
export * from "./types/common-configs.types";
|
|
28
|
-
export * from "./types/config.types";
|
|
29
|
-
export * from "./types/ts-compiler.types";
|
|
30
|
-
export * from "./types/worker.types";
|
|
31
|
-
export * from "./utils/sd-cli-convert-message.utils";
|
|
32
|
-
export * from "./utils/sd-cli-performance-time";
|
|
33
|
-
import "./workers/build-runner.worker";
|
|
34
|
-
import "./workers/server.worker";
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import * as ts from "typescript";
|
|
2
|
-
import { PathUtils, TNormPath } from "@simplysm/sd-core-node";
|
|
3
|
-
import { ISdBuildMessage } from "../types/build.types";
|
|
4
|
-
import * as module from "node:module";
|
|
5
|
-
import path from "path";
|
|
6
|
-
|
|
7
|
-
export class SdTsDependencyAnalyzer {
|
|
8
|
-
static analyze(
|
|
9
|
-
program: ts.Program,
|
|
10
|
-
compilerHost: ts.CompilerHost,
|
|
11
|
-
scopePaths: TNormPath[],
|
|
12
|
-
allDepCacheMap: Map<TNormPath, Set<TNormPath>>,
|
|
13
|
-
) {
|
|
14
|
-
const compilerOpts = program.getCompilerOptions();
|
|
15
|
-
const visited = new Set<TNormPath>();
|
|
16
|
-
const messages: ISdBuildMessage[] = [];
|
|
17
|
-
|
|
18
|
-
const getOrgSourceFile = (sf: ts.SourceFile) => {
|
|
19
|
-
if (sf.fileName.endsWith(".ngtypecheck.ts")) {
|
|
20
|
-
const orgFileName = sf.fileName.slice(0, -15) + ".ts";
|
|
21
|
-
return program.getSourceFile(orgFileName);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return sf;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const inScope = (filePath: string): boolean => {
|
|
28
|
-
return scopePaths.some((scope) => PathUtils.isChildPath(filePath, scope));
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const resolveModule = (text: string, base: string): {
|
|
32
|
-
resolvedFileName: string,
|
|
33
|
-
isFallback: boolean
|
|
34
|
-
} | undefined => {
|
|
35
|
-
/*const moduleResolutionHost: ts.ModuleResolutionHost = {
|
|
36
|
-
...compilerHost,
|
|
37
|
-
realpath: fs.realpathSync, // 필요 시
|
|
38
|
-
directoryExists: fs.existsSync,
|
|
39
|
-
getCurrentDirectory: () => process.cwd(),
|
|
40
|
-
};*/
|
|
41
|
-
const res = ts.resolveModuleName(
|
|
42
|
-
text,
|
|
43
|
-
base,
|
|
44
|
-
compilerOpts,
|
|
45
|
-
compilerHost,
|
|
46
|
-
/*moduleResolutionHost*/
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
if (res.resolvedModule) {
|
|
50
|
-
return { resolvedFileName: res.resolvedModule.resolvedFileName, isFallback: false };
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const absPath = path.resolve(path.dirname(base), text);
|
|
54
|
-
if (compilerHost.fileExists(absPath)) {
|
|
55
|
-
return { resolvedFileName: absPath, isFallback: true };
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return undefined;
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const error = (sf: ts.SourceFile, node: ts.Node, msg: string) => {
|
|
62
|
-
try {
|
|
63
|
-
const pos = ts.getLineAndCharacterOfPosition(sf, node.getStart());
|
|
64
|
-
messages.push({
|
|
65
|
-
filePath: PathUtils.norm(sf.fileName),
|
|
66
|
-
line: pos.line,
|
|
67
|
-
char: pos.character,
|
|
68
|
-
code: undefined,
|
|
69
|
-
severity: "error",
|
|
70
|
-
message: msg,
|
|
71
|
-
type: "deps",
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
messages.push({
|
|
76
|
-
filePath: PathUtils.norm(sf.fileName),
|
|
77
|
-
line: 0,
|
|
78
|
-
char: 0,
|
|
79
|
-
code: undefined,
|
|
80
|
-
severity: "error",
|
|
81
|
-
message: `${msg} (pos unknown)`,
|
|
82
|
-
type: "deps",
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const collectDeps = (sf: ts.SourceFile) => {
|
|
88
|
-
const sfNPath = PathUtils.norm(sf.fileName);
|
|
89
|
-
if (allDepCacheMap.has(sfNPath)) return;
|
|
90
|
-
const deps = new Set<TNormPath>();
|
|
91
|
-
|
|
92
|
-
const pushDep = (raw: string, node: ts.Node) => {
|
|
93
|
-
if (module.builtinModules.includes(raw.replace(/^node:/, ""))) return;
|
|
94
|
-
|
|
95
|
-
const resolved = resolveModule(raw, sf.fileName);
|
|
96
|
-
if (!resolved) {
|
|
97
|
-
error(sf, node, `파일 "${sf.fileName}"에서 "${raw}" 모듈을 해석할 수 없습니다.`);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (!inScope(resolved.resolvedFileName)) return;
|
|
102
|
-
|
|
103
|
-
const resolvedNPath = PathUtils.norm(resolved.resolvedFileName);
|
|
104
|
-
deps.add(resolvedNPath);
|
|
105
|
-
|
|
106
|
-
if (!visited.has(resolvedNPath) && !resolved.isFallback) {
|
|
107
|
-
visited.add(resolvedNPath);
|
|
108
|
-
const resolvedSf = program.getSourceFile(resolvedNPath);
|
|
109
|
-
if (!resolvedSf) {
|
|
110
|
-
error(
|
|
111
|
-
sf,
|
|
112
|
-
node,
|
|
113
|
-
`모듈 "${raw}"은(는) "${resolved}" 파일로 해석되었으나, 해당 파일의 ts.SourceFile이 없습니다.`,
|
|
114
|
-
);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
collectDeps(resolvedSf);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const visit = (node: ts.Node) => {
|
|
123
|
-
if (ts.isImportDeclaration(node) || ts.isExportDeclaration(node)) {
|
|
124
|
-
const spec = node.moduleSpecifier;
|
|
125
|
-
if (spec && ts.isStringLiteral(spec)) pushDep(spec.text, node);
|
|
126
|
-
}
|
|
127
|
-
else if (
|
|
128
|
-
ts.isCallExpression(node) &&
|
|
129
|
-
node.expression.kind === ts.SyntaxKind.ImportKeyword &&
|
|
130
|
-
ts.isStringLiteral(node.arguments[0])
|
|
131
|
-
) {
|
|
132
|
-
pushDep(node.arguments[0].text, node);
|
|
133
|
-
}
|
|
134
|
-
else if (
|
|
135
|
-
ts.isCallExpression(node) &&
|
|
136
|
-
ts.isIdentifier(node.expression) &&
|
|
137
|
-
node.expression.text === "require" &&
|
|
138
|
-
node.arguments.length === 1 &&
|
|
139
|
-
ts.isStringLiteral(node.arguments[0])
|
|
140
|
-
) {
|
|
141
|
-
pushDep(node.arguments[0].text, node);
|
|
142
|
-
}
|
|
143
|
-
else if (
|
|
144
|
-
ts.isCallExpression(node) &&
|
|
145
|
-
ts.isPropertyAccessExpression(node.expression) &&
|
|
146
|
-
ts.isIdentifier(node.expression.expression) &&
|
|
147
|
-
node.expression.expression.text === "require" &&
|
|
148
|
-
node.expression.name.text === "resolve" &&
|
|
149
|
-
node.arguments.length === 1 &&
|
|
150
|
-
ts.isStringLiteral(node.arguments[0])
|
|
151
|
-
) {
|
|
152
|
-
pushDep(node.arguments[0].text, node);
|
|
153
|
-
}
|
|
154
|
-
else if (
|
|
155
|
-
ts.isCallExpression(node) &&
|
|
156
|
-
ts.isPropertyAccessExpression(node.expression) &&
|
|
157
|
-
ts.isMetaProperty(node.expression.expression) &&
|
|
158
|
-
node.expression.expression.keywordToken === ts.SyntaxKind.ImportKeyword &&
|
|
159
|
-
node.expression.name.text === "meta" &&
|
|
160
|
-
node.arguments.length === 1 &&
|
|
161
|
-
ts.isStringLiteral(node.arguments[0])
|
|
162
|
-
) {
|
|
163
|
-
pushDep(node.arguments[0].text, node);
|
|
164
|
-
}
|
|
165
|
-
ts.forEachChild(node, visit);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
ts.forEachChild(sf, visit);
|
|
169
|
-
allDepCacheMap.set(sfNPath, deps);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const sourceFileSet = new Set(
|
|
173
|
-
program.getSourceFiles()
|
|
174
|
-
.map((sf) => getOrgSourceFile(sf))
|
|
175
|
-
.filterExists(),
|
|
176
|
-
);
|
|
177
|
-
|
|
178
|
-
for (const sf of sourceFileSet) {
|
|
179
|
-
if (!inScope(sf.fileName)) continue;
|
|
180
|
-
collectDeps(sf);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return messages;
|
|
184
|
-
}
|
|
185
|
-
}
|