@simplysm/sd-cli 12.13.21 → 12.13.23
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/package.json +12 -12
- package/src/entry/{sd-cli-cordova.ts → SdCliCordova.ts} +2 -2
- package/src/entry/{sd-cli-electron.ts → SdCliElectron.ts} +3 -3
- package/src/entry/{sd-cli-local-update.ts → SdCliLocalUpdate.ts} +6 -4
- package/src/entry/{sd-cli-project.ts → SdCliProject.ts} +55 -71
- package/src/pkg-builders/SdProjectBuildRunner.ts +347 -0
- package/src/pkg-builders/client/{sd-client.build-runner.ts → SdClientBuildRunner.ts} +31 -38
- package/src/pkg-builders/client/{sd-ng.bundler.ts → SdNgBundler.ts} +22 -31
- package/src/pkg-builders/client/{sd-ng.bundler-context.ts → SdNgBundlerContext.ts} +7 -9
- package/src/pkg-builders/client/{sd-ng.plugin-creator.ts → createSdNgPlugin.ts} +11 -94
- package/src/pkg-builders/commons/{scope-path.ts → ScopePathSet.ts} +3 -3
- package/src/pkg-builders/commons/SdBuildRunnerBase.ts +47 -0
- package/src/pkg-builders/lib/{sd-cli-db-context.file-generator.ts → SdCliDbContextFileGenerator.ts} +1 -1
- package/src/pkg-builders/lib/{sd-js-lib.build-runner.ts → SdJsLibBuildRunner.ts} +13 -32
- package/src/pkg-builders/lib/SdTsLibBuildRunner.ts +47 -0
- package/src/pkg-builders/lib/{sd-ts-lib.builder.ts → SdTsLibBuilder.ts} +12 -14
- package/src/pkg-builders/server/{sd-server.build-runner.ts → SdServerBuildRunner.ts} +25 -48
- package/src/pkg-builders/server/{sd-server.bundler.ts → SdServerBundler.ts} +26 -23
- package/src/pkg-builders/server/{sd-server.plugin-creator.ts → createSdServerPlugin.ts} +9 -7
- package/src/sd-cli-entry.ts +6 -12
- package/src/sd-cli.ts +1 -15
- package/src/ts-compiler/{sd-dependency-analyzer.ts → SdDepAnalyzer.ts} +5 -9
- package/src/ts-compiler/{sd-dependency-cache.ts → SdDepCache.ts} +1 -137
- package/src/ts-compiler/{sd-style-bundler.ts → SdStyleBundler.ts} +5 -5
- package/src/ts-compiler/{sd-ts-compiler.ts → SdTsCompiler.ts} +17 -144
- package/src/types/{build.types.ts → build/ISdBuildMessage.ts} +0 -6
- package/src/types/build/ISdBuildResult.ts +9 -0
- package/src/types/build/ISdTsCompilerOptions.ts +15 -0
- package/src/types/build/ISdTsCompilerResult.ts +12 -0
- package/src/types/build/TStylesheetBundlingResult.ts +15 -0
- package/src/types/{common-configs.types.ts → common-config/INpmConfig.ts} +0 -6
- package/src/types/common-config/ITsConfig.ts +5 -0
- package/src/types/{config.types.ts → config/ISdProjectConfig.ts} +0 -1
- package/src/types/plugin/ISdCliNgPluginResultCache.ts +9 -0
- package/src/types/{build-plugin.types.ts → plugin/ISdCliServerPluginResultCache.ts} +0 -7
- package/src/types/worker/ISdBuildRunnerWorkerType.ts +24 -0
- package/src/types/worker/IServerWorkerType.ts +8 -0
- package/src/utils/{sd-cli-convert-message.utils.ts → SdCliConvertMessageUtils.ts} +6 -3
- package/src/{entry/utils → utils}/loadProjConfAsync.ts +10 -6
- package/src/workers/build-runner.worker.ts +30 -29
- package/src/workers/server.worker.ts +7 -7
- package/tests/deps/sd-dependency-analyzer.spec.ts +38 -69
- package/tests/deps/sd-dependency-cache.spec.ts +3 -6
- package/dist/entry/sd-cli-ai-command.d.ts +0 -3
- package/dist/entry/sd-cli-ai-command.js +0 -65
- package/dist/entry/sd-cli-ai-command.js.map +0 -1
- package/dist/entry/sd-cli-cordova.d.ts +0 -16
- package/dist/entry/sd-cli-cordova.js +0 -398
- package/dist/entry/sd-cli-cordova.js.map +0 -1
- package/dist/entry/sd-cli-electron.d.ts +0 -18
- package/dist/entry/sd-cli-electron.js +0 -129
- package/dist/entry/sd-cli-electron.js.map +0 -1
- package/dist/entry/sd-cli-local-update.d.ts +0 -11
- package/dist/entry/sd-cli-local-update.js +0 -84
- package/dist/entry/sd-cli-local-update.js.map +0 -1
- package/dist/entry/sd-cli-postinstall.d.ts +0 -3
- package/dist/entry/sd-cli-postinstall.js +0 -39
- package/dist/entry/sd-cli-postinstall.js.map +0 -1
- package/dist/entry/sd-cli-project.d.ts +0 -22
- package/dist/entry/sd-cli-project.js +0 -325
- package/dist/entry/sd-cli-project.js.map +0 -1
- package/dist/entry/utils/loadProjConfAsync.d.ts +0 -5
- package/dist/entry/utils/loadProjConfAsync.js +0 -8
- package/dist/entry/utils/loadProjConfAsync.js.map +0 -1
- package/dist/fix/convert-extends-sd-modal-base-to-interface.d.ts +0 -1
- package/dist/fix/convert-extends-sd-modal-base-to-interface.js +0 -289
- package/dist/fix/convert-extends-sd-modal-base-to-interface.js.map +0 -1
- package/dist/fix/convert-extends-sd-print-template-base-to-interface.d.ts +0 -1
- package/dist/fix/convert-extends-sd-print-template-base-to-interface.js +0 -179
- package/dist/fix/convert-extends-sd-print-template-base-to-interface.js.map +0 -1
- package/dist/fix/convert-flat-pages-to-flat-menus.d.ts +0 -1
- package/dist/fix/convert-flat-pages-to-flat-menus.js +0 -68
- package/dist/fix/convert-flat-pages-to-flat-menus.js.map +0 -1
- package/dist/fix/convert-get-menus-to-usable-menus.d.ts +0 -1
- package/dist/fix/convert-get-menus-to-usable-menus.js +0 -48
- package/dist/fix/convert-get-menus-to-usable-menus.js.map +0 -1
- package/dist/fix/convert-modal-show-params.d.ts +0 -1
- package/dist/fix/convert-modal-show-params.js +0 -29
- package/dist/fix/convert-modal-show-params.js.map +0 -1
- package/dist/fix/convert-print-params.d.ts +0 -1
- package/dist/fix/convert-print-params.js +0 -37
- package/dist/fix/convert-print-params.js.map +0 -1
- package/dist/fix/convert-private-to-hash.d.ts +0 -1
- package/dist/fix/convert-private-to-hash.js +0 -59
- package/dist/fix/convert-private-to-hash.js.map +0 -1
- package/dist/fix/convert-sd-angular-symbol-names.d.ts +0 -1
- package/dist/fix/convert-sd-angular-symbol-names.js +0 -23
- package/dist/fix/convert-sd-angular-symbol-names.js.map +0 -1
- package/dist/fix/convert-sd-icon-to-fa-icon.d.ts +0 -1
- package/dist/fix/convert-sd-icon-to-fa-icon.js +0 -80
- package/dist/fix/convert-sd-icon-to-fa-icon.js.map +0 -1
- package/dist/fix/convert-sd-sheet-bindings-safety.d.ts +0 -1
- package/dist/fix/convert-sd-sheet-bindings-safety.js +0 -57
- package/dist/fix/convert-sd-sheet-bindings-safety.js.map +0 -1
- package/dist/fix/convert-select-modal-button-to-select-button.d.ts +0 -1
- package/dist/fix/convert-select-modal-button-to-select-button.js +0 -64
- package/dist/fix/convert-select-modal-button-to-select-button.js.map +0 -1
- package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.d.ts +0 -1
- package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.js +0 -38
- package/dist/fix/convert-setup-cumulate-selected-keys-to-object-param.js.map +0 -1
- package/dist/fix/convert-to-use-perms-signal.d.ts +0 -1
- package/dist/fix/convert-to-use-perms-signal.js +0 -99
- package/dist/fix/convert-to-use-perms-signal.js.map +0 -1
- package/dist/fix/core/convert-symbol.d.ts +0 -1
- package/dist/fix/core/convert-symbol.js +0 -93
- package/dist/fix/core/convert-symbol.js.map +0 -1
- package/dist/fix/core/get-ts-morph-source-files.d.ts +0 -1
- package/dist/fix/core/get-ts-morph-source-files.js +0 -8
- package/dist/fix/core/get-ts-morph-source-files.js.map +0 -1
- package/dist/fix/core/remove-named-import.d.ts +0 -1
- package/dist/fix/core/remove-named-import.js +0 -14
- package/dist/fix/core/remove-named-import.js.map +0 -1
- package/dist/fix/core/remove-symbol.d.ts +0 -1
- package/dist/fix/core/remove-symbol.js +0 -76
- package/dist/fix/core/remove-symbol.js.map +0 -1
- package/dist/fix/remove-sd-angular-symbol-names.d.ts +0 -1
- package/dist/fix/remove-sd-angular-symbol-names.js +0 -9
- package/dist/fix/remove-sd-angular-symbol-names.js.map +0 -1
- package/dist/fix/remove-unused-imports.d.ts +0 -1
- package/dist/fix/remove-unused-imports.js +0 -42
- package/dist/fix/remove-unused-imports.js.map +0 -1
- package/dist/fix/remove-unused-injects.d.ts +0 -1
- package/dist/fix/remove-unused-injects.js +0 -38
- package/dist/fix/remove-unused-injects.js.map +0 -1
- package/dist/fix/remove-unused-protected-readonly.d.ts +0 -1
- package/dist/fix/remove-unused-protected-readonly.js +0 -52
- package/dist/fix/remove-unused-protected-readonly.js.map +0 -1
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.d.ts +0 -9
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js +0 -89
- package/dist/pkg-builders/client/sd-cli-ng-routes.file-generator.js.map +0 -1
- package/dist/pkg-builders/client/sd-client.build-runner.d.ts +0 -7
- package/dist/pkg-builders/client/sd-client.build-runner.js +0 -119
- package/dist/pkg-builders/client/sd-client.build-runner.js.map +0 -1
- package/dist/pkg-builders/client/sd-ng.bundler-context.d.ts +0 -22
- package/dist/pkg-builders/client/sd-ng.bundler-context.js +0 -91
- package/dist/pkg-builders/client/sd-ng.bundler-context.js.map +0 -1
- package/dist/pkg-builders/client/sd-ng.bundler.d.ts +0 -27
- package/dist/pkg-builders/client/sd-ng.bundler.js +0 -489
- package/dist/pkg-builders/client/sd-ng.bundler.js.map +0 -1
- package/dist/pkg-builders/client/sd-ng.plugin-creator.d.ts +0 -13
- package/dist/pkg-builders/client/sd-ng.plugin-creator.js +0 -223
- package/dist/pkg-builders/client/sd-ng.plugin-creator.js.map +0 -1
- package/dist/pkg-builders/commons/build-runner.base.d.ts +0 -29
- package/dist/pkg-builders/commons/build-runner.base.js +0 -114
- package/dist/pkg-builders/commons/build-runner.base.js.map +0 -1
- package/dist/pkg-builders/commons/scope-path.d.ts +0 -7
- package/dist/pkg-builders/commons/scope-path.js +0 -14
- package/dist/pkg-builders/commons/scope-path.js.map +0 -1
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.d.ts +0 -9
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.js +0 -134
- package/dist/pkg-builders/lib/sd-cli-db-context.file-generator.js.map +0 -1
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.d.ts +0 -10
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js +0 -61
- package/dist/pkg-builders/lib/sd-cli-index.file-generator.js.map +0 -1
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.d.ts +0 -8
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.js +0 -50
- package/dist/pkg-builders/lib/sd-js-lib.build-runner.js.map +0 -1
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.d.ts +0 -7
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js +0 -41
- package/dist/pkg-builders/lib/sd-ts-lib.build-runner.js.map +0 -1
- package/dist/pkg-builders/lib/sd-ts-lib.builder.d.ts +0 -14
- package/dist/pkg-builders/lib/sd-ts-lib.builder.js +0 -65
- package/dist/pkg-builders/lib/sd-ts-lib.builder.js.map +0 -1
- package/dist/pkg-builders/sd-multi.build-runner.d.ts +0 -14
- package/dist/pkg-builders/sd-multi.build-runner.js +0 -228
- package/dist/pkg-builders/sd-multi.build-runner.js.map +0 -1
- package/dist/pkg-builders/server/sd-server.build-runner.d.ts +0 -7
- package/dist/pkg-builders/server/sd-server.build-runner.js +0 -264
- package/dist/pkg-builders/server/sd-server.build-runner.js.map +0 -1
- package/dist/pkg-builders/server/sd-server.bundler.d.ts +0 -22
- package/dist/pkg-builders/server/sd-server.bundler.js +0 -153
- package/dist/pkg-builders/server/sd-server.bundler.js.map +0 -1
- package/dist/pkg-builders/server/sd-server.plugin-creator.d.ts +0 -13
- package/dist/pkg-builders/server/sd-server.plugin-creator.js +0 -62
- package/dist/pkg-builders/server/sd-server.plugin-creator.js.map +0 -1
- package/dist/sd-cli-entry.d.ts +0 -2
- package/dist/sd-cli-entry.js +0 -263
- package/dist/sd-cli-entry.js.map +0 -1
- package/dist/sd-cli.d.ts +0 -2
- package/dist/sd-cli.js +0 -97
- package/dist/sd-cli.js.map +0 -1
- package/dist/ts-compiler/sd-dependency-analyzer.d.ts +0 -15
- package/dist/ts-compiler/sd-dependency-analyzer.js +0 -302
- package/dist/ts-compiler/sd-dependency-analyzer.js.map +0 -1
- package/dist/ts-compiler/sd-dependency-cache.d.ts +0 -43
- package/dist/ts-compiler/sd-dependency-cache.js +0 -310
- package/dist/ts-compiler/sd-dependency-cache.js.map +0 -1
- package/dist/ts-compiler/sd-style-bundler.d.ts +0 -16
- package/dist/ts-compiler/sd-style-bundler.js +0 -118
- package/dist/ts-compiler/sd-style-bundler.js.map +0 -1
- package/dist/ts-compiler/sd-ts-compiler.d.ts +0 -8
- package/dist/ts-compiler/sd-ts-compiler.js +0 -522
- package/dist/ts-compiler/sd-ts-compiler.js.map +0 -1
- package/dist/types/build-plugin.types.d.ts +0 -14
- package/dist/types/build-plugin.types.js +0 -2
- package/dist/types/build-plugin.types.js.map +0 -1
- package/dist/types/build-runner.types.d.ts +0 -10
- package/dist/types/build-runner.types.js +0 -2
- package/dist/types/build-runner.types.js.map +0 -1
- package/dist/types/build.types.d.ts +0 -15
- package/dist/types/build.types.js +0 -2
- package/dist/types/build.types.js.map +0 -1
- package/dist/types/common-configs.types.d.ts +0 -24
- package/dist/types/common-configs.types.js +0 -2
- package/dist/types/common-configs.types.js.map +0 -1
- package/dist/types/config.types.d.ts +0 -109
- package/dist/types/config.types.js +0 -2
- package/dist/types/config.types.js.map +0 -1
- package/dist/types/ts-compiler.types.d.ts +0 -37
- package/dist/types/ts-compiler.types.js +0 -2
- package/dist/types/ts-compiler.types.js.map +0 -1
- package/dist/types/worker.types.d.ts +0 -67
- package/dist/types/worker.types.js +0 -2
- package/dist/types/worker.types.js.map +0 -1
- package/dist/utils/sd-cli-convert-message.utils.d.ts +0 -21
- package/dist/utils/sd-cli-convert-message.utils.js +0 -137
- package/dist/utils/sd-cli-convert-message.utils.js.map +0 -1
- package/dist/utils/sd-cli-performance-time.d.ts +0 -9
- package/dist/utils/sd-cli-performance-time.js +0 -51
- package/dist/utils/sd-cli-performance-time.js.map +0 -1
- package/dist/workers/build-runner.worker.d.ts +0 -1
- package/dist/workers/build-runner.worker.js +0 -49
- package/dist/workers/build-runner.worker.js.map +0 -1
- package/dist/workers/server.worker.d.ts +0 -1
- package/dist/workers/server.worker.js +0 -50
- package/dist/workers/server.worker.js.map +0 -1
- package/src/pkg-builders/commons/build-runner.base.ts +0 -184
- package/src/pkg-builders/lib/sd-ts-lib.build-runner.ts +0 -57
- package/src/pkg-builders/sd-multi.build-runner.ts +0 -304
- package/src/types/build-runner.types.ts +0 -11
- package/src/types/ts-compiler.types.ts +0 -43
- package/src/types/worker.types.ts +0 -51
- /package/src/entry/{sd-cli-ai-command.ts → SdCliAiCommand.ts} +0 -0
- /package/src/entry/{sd-cli-postinstall.ts → SdCliPostinstall.ts} +0 -0
- /package/src/pkg-builders/client/{sd-cli-ng-routes.file-generator.ts → SdCliNgRoutesFileGenerator.ts} +0 -0
- /package/src/pkg-builders/lib/{sd-cli-index.file-generator.ts → SdCliIndexFileGenerator.ts} +0 -0
- /package/src/utils/{sd-cli-performance-time.ts → SdCliPerformanceTimer.ts} +0 -0
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import { PathUtils } from "@simplysm/sd-core-node";
|
|
3
|
-
import path from "path";
|
|
4
|
-
export class SdDependencyAnalyzer {
|
|
5
|
-
static analyze(program, compilerHost, scopePathSet, cache) {
|
|
6
|
-
const compilerOpts = program.getCompilerOptions();
|
|
7
|
-
const typeChecker = program.getTypeChecker();
|
|
8
|
-
const moduleResolutionCache = ts.createModuleResolutionCache(compilerHost.getCurrentDirectory(), compilerHost.getCanonicalFileName.bind(compilerHost), compilerOpts);
|
|
9
|
-
const resolveModule = (text, base) => {
|
|
10
|
-
const res = ts.resolveModuleName(text, base, compilerOpts, compilerHost, moduleResolutionCache);
|
|
11
|
-
if (res.resolvedModule) {
|
|
12
|
-
return [PathUtils.norm(res.resolvedModule.resolvedFileName)];
|
|
13
|
-
}
|
|
14
|
-
const absPath = path.resolve(path.dirname(base), text);
|
|
15
|
-
if (!scopePathSet.inScope(absPath)) {
|
|
16
|
-
return [];
|
|
17
|
-
}
|
|
18
|
-
else if (
|
|
19
|
-
// 지원되게할 .png등이면 그냥 가져오고 (bundling loader에 들어가는것들과 .ts, .json등)
|
|
20
|
-
// fallback일때는 absPath에 .ts, .d.ts, .js, .json 등 다붙여서 가져와야함
|
|
21
|
-
[
|
|
22
|
-
".ts",
|
|
23
|
-
".d.ts",
|
|
24
|
-
".js",
|
|
25
|
-
".json",
|
|
26
|
-
".html",
|
|
27
|
-
".scss",
|
|
28
|
-
".css",
|
|
29
|
-
".png",
|
|
30
|
-
".jpeg",
|
|
31
|
-
".jpg",
|
|
32
|
-
".jfif",
|
|
33
|
-
".gif",
|
|
34
|
-
".svg",
|
|
35
|
-
".woff",
|
|
36
|
-
".woff2",
|
|
37
|
-
".ttf",
|
|
38
|
-
".ttc",
|
|
39
|
-
".eot",
|
|
40
|
-
".ico",
|
|
41
|
-
".otf",
|
|
42
|
-
".csv",
|
|
43
|
-
".xlsx",
|
|
44
|
-
".xls",
|
|
45
|
-
".pptx",
|
|
46
|
-
".ppt",
|
|
47
|
-
".docx",
|
|
48
|
-
".doc",
|
|
49
|
-
".zip",
|
|
50
|
-
".pfx",
|
|
51
|
-
".pkl",
|
|
52
|
-
".mp3",
|
|
53
|
-
".ogg",
|
|
54
|
-
].some((ext) => absPath.endsWith(ext))) {
|
|
55
|
-
return [PathUtils.norm(absPath)];
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return [
|
|
59
|
-
PathUtils.norm(absPath + ".ts"),
|
|
60
|
-
PathUtils.norm(absPath + ".js"),
|
|
61
|
-
PathUtils.norm(absPath + ".d.ts"),
|
|
62
|
-
PathUtils.norm(absPath + ".json"),
|
|
63
|
-
];
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const isInImportOrExport = (node) => {
|
|
67
|
-
const p = node.parent;
|
|
68
|
-
return (ts.isImportDeclaration(p) ||
|
|
69
|
-
ts.isExportDeclaration(p) ||
|
|
70
|
-
ts.isImportSpecifier(p) ||
|
|
71
|
-
ts.isExportSpecifier(p) ||
|
|
72
|
-
ts.isNamespaceImport(p));
|
|
73
|
-
};
|
|
74
|
-
const isDeclarationIdentifier = (id) => {
|
|
75
|
-
const p = id.parent;
|
|
76
|
-
return ((ts.isParameter(p) && p.name === id) ||
|
|
77
|
-
(ts.isVariableDeclaration(p) && p.name === id) ||
|
|
78
|
-
(ts.isFunctionDeclaration(p) && p.name === id) ||
|
|
79
|
-
(ts.isClassDeclaration(p) && p.name === id) ||
|
|
80
|
-
(ts.isInterfaceDeclaration(p) && p.name === id) ||
|
|
81
|
-
(ts.isTypeAliasDeclaration(p) && p.name === id) ||
|
|
82
|
-
(ts.isEnumDeclaration(p) && p.name === id) ||
|
|
83
|
-
(ts.isPropertySignature(p) && p.name === id) ||
|
|
84
|
-
(ts.isPropertyDeclaration(p) && p.name === id) ||
|
|
85
|
-
(ts.isMethodSignature(p) && p.name === id) ||
|
|
86
|
-
(ts.isMethodDeclaration(p) && p.name === id));
|
|
87
|
-
};
|
|
88
|
-
// const typeCache = new WeakMap<ts.Node, ts.Type | undefined>();
|
|
89
|
-
const getCachedType = (node) => {
|
|
90
|
-
if (cache.type.has(node))
|
|
91
|
-
return cache.type.get(node);
|
|
92
|
-
const type = typeChecker.getTypeAtLocation(node);
|
|
93
|
-
if (!type)
|
|
94
|
-
return undefined;
|
|
95
|
-
const skipMask = ts.TypeFlags.Any |
|
|
96
|
-
ts.TypeFlags.Unknown |
|
|
97
|
-
ts.TypeFlags.Never |
|
|
98
|
-
ts.TypeFlags.Null |
|
|
99
|
-
ts.TypeFlags.Undefined |
|
|
100
|
-
ts.TypeFlags.BooleanLike |
|
|
101
|
-
ts.TypeFlags.NumberLike |
|
|
102
|
-
ts.TypeFlags.StringLike |
|
|
103
|
-
ts.TypeFlags.BigIntLike |
|
|
104
|
-
ts.TypeFlags.ESSymbolLike;
|
|
105
|
-
const result = (type.flags & skipMask) !== 0 ? undefined : type;
|
|
106
|
-
cache.type.set(node, result);
|
|
107
|
-
return result;
|
|
108
|
-
};
|
|
109
|
-
// const propCache = new WeakMap<ts.Type, Map<string, ts.Symbol | undefined>>();
|
|
110
|
-
const getCachedProp = (type, name) => {
|
|
111
|
-
if (!type)
|
|
112
|
-
return undefined;
|
|
113
|
-
let map = cache.prop.get(type);
|
|
114
|
-
if (!map) {
|
|
115
|
-
map = new Map();
|
|
116
|
-
cache.prop.set(type, map);
|
|
117
|
-
}
|
|
118
|
-
if (map.has(name))
|
|
119
|
-
return map.get(name);
|
|
120
|
-
const s = type.getProperty(name);
|
|
121
|
-
map.set(name, s);
|
|
122
|
-
return s;
|
|
123
|
-
};
|
|
124
|
-
// const declFilesCache = new WeakMap<ts.Symbol, TNormPath[]>();
|
|
125
|
-
const getDeclFileNPaths = (sym) => {
|
|
126
|
-
if (!sym)
|
|
127
|
-
return [];
|
|
128
|
-
const c = cache.declFiles.get(sym);
|
|
129
|
-
if (c)
|
|
130
|
-
return c;
|
|
131
|
-
const paths = (sym.getDeclarations() ?? []).map((d) => PathUtils.norm(d.getSourceFile().fileName));
|
|
132
|
-
cache.declFiles.set(sym, paths);
|
|
133
|
-
return paths;
|
|
134
|
-
};
|
|
135
|
-
const collectDeps = (sf) => {
|
|
136
|
-
const sfNPath = PathUtils.norm(sf.fileName);
|
|
137
|
-
if (cache.dep.hasCollected(sfNPath))
|
|
138
|
-
return;
|
|
139
|
-
cache.dep.addCollected(sfNPath);
|
|
140
|
-
if (!scopePathSet.inScope(sfNPath))
|
|
141
|
-
return;
|
|
142
|
-
const visit = (node) => {
|
|
143
|
-
// --- import ... from '...'
|
|
144
|
-
if (ts.isImportDeclaration(node) && ts.isStringLiteral(node.moduleSpecifier)) {
|
|
145
|
-
const resolvedNPaths = resolveModule(node.moduleSpecifier.text, sf.fileName);
|
|
146
|
-
for (const resolvedNPath of resolvedNPaths) {
|
|
147
|
-
if (!scopePathSet.inScope(resolvedNPath))
|
|
148
|
-
continue;
|
|
149
|
-
if (node.importClause &&
|
|
150
|
-
node.importClause.namedBindings &&
|
|
151
|
-
ts.isNamedImports(node.importClause.namedBindings)) {
|
|
152
|
-
// import ... from '...'
|
|
153
|
-
for (const element of node.importClause.namedBindings.elements) {
|
|
154
|
-
cache.dep.addImport(sfNPath, resolvedNPath, element.propertyName?.text ?? element.name.text);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
cache.dep.addImport(sfNPath, resolvedNPath, 0);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
// --- export * from '...'
|
|
164
|
-
else if (ts.isExportDeclaration(node) &&
|
|
165
|
-
!node.exportClause &&
|
|
166
|
-
node.moduleSpecifier &&
|
|
167
|
-
ts.isStringLiteral(node.moduleSpecifier)) {
|
|
168
|
-
const resolvedNPaths = resolveModule(node.moduleSpecifier.text, sf.fileName);
|
|
169
|
-
for (const resolvedNPath of resolvedNPaths) {
|
|
170
|
-
if (!scopePathSet.inScope(resolvedNPath))
|
|
171
|
-
continue;
|
|
172
|
-
cache.dep.addReexport(sfNPath, resolvedNPath, 0);
|
|
173
|
-
}
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
// --- export { A as B } from '...'
|
|
177
|
-
else if (ts.isExportDeclaration(node) &&
|
|
178
|
-
node.exportClause &&
|
|
179
|
-
ts.isNamedExports(node.exportClause) &&
|
|
180
|
-
node.moduleSpecifier &&
|
|
181
|
-
ts.isStringLiteral(node.moduleSpecifier)) {
|
|
182
|
-
const resolvedNPaths = resolveModule(node.moduleSpecifier.text, sf.fileName);
|
|
183
|
-
for (const resolvedNPath of resolvedNPaths) {
|
|
184
|
-
if (!scopePathSet.inScope(resolvedNPath))
|
|
185
|
-
continue;
|
|
186
|
-
for (const element of node.exportClause.elements) {
|
|
187
|
-
const local = element.propertyName?.text ?? element.name.text;
|
|
188
|
-
const exported = element.name.text;
|
|
189
|
-
cache.dep.addReexport(sfNPath, resolvedNPath, {
|
|
190
|
-
importSymbol: local,
|
|
191
|
-
exportSymbol: exported,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
// --- export const A = ...
|
|
198
|
-
else if (ts.isVariableStatement(node) &&
|
|
199
|
-
node.modifiers?.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword)) {
|
|
200
|
-
for (const decl of node.declarationList.declarations) {
|
|
201
|
-
if (ts.isIdentifier(decl.name)) {
|
|
202
|
-
cache.dep.addExport(sfNPath, decl.name.text);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
// --- export function/class/interface A ...
|
|
207
|
-
if ((ts.isFunctionDeclaration(node) ||
|
|
208
|
-
ts.isClassDeclaration(node) ||
|
|
209
|
-
ts.isInterfaceDeclaration(node) ||
|
|
210
|
-
ts.isTypeAliasDeclaration(node) ||
|
|
211
|
-
ts.isEnumDeclaration(node)) &&
|
|
212
|
-
node.modifiers?.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword) &&
|
|
213
|
-
node.name) {
|
|
214
|
-
cache.dep.addExport(sfNPath, node.name.text);
|
|
215
|
-
}
|
|
216
|
-
else if (ts.isIdentifier(node) &&
|
|
217
|
-
isDeclarationIdentifier(node) &&
|
|
218
|
-
!isInImportOrExport(node)) {
|
|
219
|
-
const orgValSymbol = typeChecker.getSymbolAtLocation(node);
|
|
220
|
-
let valSymbol = orgValSymbol;
|
|
221
|
-
if (orgValSymbol && orgValSymbol.flags & ts.SymbolFlags.Alias) {
|
|
222
|
-
// 현 파일 선언으로 확정되면 굳이 치환 불필요
|
|
223
|
-
const declNPaths = getDeclFileNPaths(orgValSymbol);
|
|
224
|
-
const external = declNPaths.some((declNPath) => declNPath !== sfNPath);
|
|
225
|
-
if (external) {
|
|
226
|
-
valSymbol = typeChecker.getAliasedSymbol(orgValSymbol);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
for (const declNPath of getDeclFileNPaths(valSymbol)) {
|
|
230
|
-
if (declNPath !== sfNPath && scopePathSet.inScope(declNPath)) {
|
|
231
|
-
cache.dep.addImport(sfNPath, declNPath, 0);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
else if (ts.isPropertyAccessExpression(node)) {
|
|
236
|
-
const type = getCachedType(node.expression);
|
|
237
|
-
const propSymbol = getCachedProp(type, node.name.text);
|
|
238
|
-
if (propSymbol) {
|
|
239
|
-
for (const declNPath of getDeclFileNPaths(propSymbol)) {
|
|
240
|
-
if (declNPath !== sfNPath && scopePathSet.inScope(declNPath)) {
|
|
241
|
-
cache.dep.addImport(sfNPath, declNPath, 0);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
else if (ts.isElementAccessExpression(node) &&
|
|
247
|
-
ts.isStringLiteral(node.argumentExpression)) {
|
|
248
|
-
const type = getCachedType(node.expression);
|
|
249
|
-
const propSymbol = getCachedProp(type, node.argumentExpression.text);
|
|
250
|
-
if (propSymbol) {
|
|
251
|
-
for (const declNPath of getDeclFileNPaths(propSymbol)) {
|
|
252
|
-
if (declNPath !== sfNPath && scopePathSet.inScope(declNPath)) {
|
|
253
|
-
cache.dep.addImport(sfNPath, declNPath, 0);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
ts.forEachChild(node, visit);
|
|
259
|
-
};
|
|
260
|
-
ts.forEachChild(sf, visit);
|
|
261
|
-
};
|
|
262
|
-
// const ngToOrgCache = new Map<TNormPath, ts.SourceFile>();
|
|
263
|
-
const getOrgSourceFile = (sf) => {
|
|
264
|
-
if (sf.fileName.endsWith(".ngtypecheck.ts")) {
|
|
265
|
-
const sfNPath = PathUtils.norm(sf.fileName);
|
|
266
|
-
let org = cache.ngOrg.get(sfNPath);
|
|
267
|
-
if (!org) {
|
|
268
|
-
const orgPath = sf.fileName.slice(0, -15) + ".ts";
|
|
269
|
-
org = program.getSourceFile(orgPath) ?? sf;
|
|
270
|
-
const realOrg = program.getSourceFile(orgPath);
|
|
271
|
-
if (realOrg)
|
|
272
|
-
cache.ngOrg.set(sfNPath, realOrg);
|
|
273
|
-
}
|
|
274
|
-
return org;
|
|
275
|
-
}
|
|
276
|
-
return sf;
|
|
277
|
-
};
|
|
278
|
-
const sourceFileSet = new Set(program
|
|
279
|
-
.getSourceFiles()
|
|
280
|
-
.filter((sf) => scopePathSet.inScope(sf.fileName))
|
|
281
|
-
.map((sf) => getOrgSourceFile(sf))
|
|
282
|
-
.filterExists());
|
|
283
|
-
for (const sf of sourceFileSet) {
|
|
284
|
-
collectDeps(sf);
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
static analyzeAngularResources(ngProgram, scopePathSet, depCache) {
|
|
288
|
-
for (const sf of ngProgram.getTsProgram().getSourceFiles()) {
|
|
289
|
-
const fileNPath = PathUtils.norm(sf.fileName);
|
|
290
|
-
if (!scopePathSet.inScope(fileNPath))
|
|
291
|
-
continue;
|
|
292
|
-
const dependencies = ngProgram.compiler.getResourceDependencies(sf);
|
|
293
|
-
for (const dep of dependencies) {
|
|
294
|
-
const depNPath = PathUtils.norm(dep);
|
|
295
|
-
if (!scopePathSet.inScope(depNPath))
|
|
296
|
-
continue;
|
|
297
|
-
depCache.addImport(fileNPath, depNPath, 0);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
//# sourceMappingURL=sd-dependency-analyzer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sd-dependency-analyzer.js","sourceRoot":"","sources":["../../src/ts-compiler/sd-dependency-analyzer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAa,MAAM,wBAAwB,CAAC;AAC9D,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,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 반환
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* 분석이 완료된 파일로 표시
|
|
9
|
-
*/
|
|
10
|
-
addCollected(fileNPath: TNormPath): void;
|
|
11
|
-
hasCollected(fileNPath: TNormPath): boolean;
|
|
12
|
-
/**
|
|
13
|
-
* export한 심볼 등록
|
|
14
|
-
* 예: export const A → "A"
|
|
15
|
-
*/
|
|
16
|
-
addExport(fileNPath: TNormPath, exportSymbol: string): void;
|
|
17
|
-
/**
|
|
18
|
-
* import 구문 등록
|
|
19
|
-
* - import * from ... → symbol = 0
|
|
20
|
-
* - import { A } from ... → symbol = "A"
|
|
21
|
-
*/
|
|
22
|
-
addImport(fileNPath: TNormPath, targetNPath: TNormPath, targetSymbol: string | 0): void;
|
|
23
|
-
/**
|
|
24
|
-
* export * or export { A as B } from ... 구문 등록
|
|
25
|
-
* ※ export/import에 자동 등록되지 않으므로 외부에서 명시적으로 따로 입력해야 함
|
|
26
|
-
*/
|
|
27
|
-
addReexport(fileNPath: TNormPath, targetNPath: TNormPath, targetSymbolInfo: {
|
|
28
|
-
importSymbol: string;
|
|
29
|
-
exportSymbol: string;
|
|
30
|
-
} | 0): void;
|
|
31
|
-
/**
|
|
32
|
-
* 변경된 파일 경로 집합으로부터 영향을 받는 전체 파일 집합을 계산
|
|
33
|
-
*/
|
|
34
|
-
getAffectedFileMap(modifiedNPathSet: Set<TNormPath>): Map<TNormPath, Set<TNormPath>>;
|
|
35
|
-
/**
|
|
36
|
-
* 주어진 파일들 및 그 영향 범위에 해당하는 모든 캐시를 무효화
|
|
37
|
-
*/
|
|
38
|
-
invalidates(fileNPathSet: Set<TNormPath>): void;
|
|
39
|
-
}
|
|
40
|
-
export interface ISdAffectedFileTreeNode {
|
|
41
|
-
fileNPath: TNormPath;
|
|
42
|
-
children: ISdAffectedFileTreeNode[];
|
|
43
|
-
}
|
|
@@ -1,310 +0,0 @@
|
|
|
1
|
-
export class SdDependencyCache {
|
|
2
|
-
/**
|
|
3
|
-
* 각 파일이 export한 심볼 집합 (예: export const A → "A")
|
|
4
|
-
*/
|
|
5
|
-
#exportCache = new Map();
|
|
6
|
-
/**
|
|
7
|
-
* import한 타겟과 그 심볼 정보
|
|
8
|
-
* - 값이 0이면 전체 import(import * 또는 리소스 import)
|
|
9
|
-
* - 값이 Set이면 선택적 심볼 import (예: import { A } ...)
|
|
10
|
-
*/
|
|
11
|
-
#importCache = new Map();
|
|
12
|
-
/**
|
|
13
|
-
* re-export한 타겟과 그 심볼 정보
|
|
14
|
-
* - export * from ...
|
|
15
|
-
* - export { A as B } from ...
|
|
16
|
-
* - 값이 0이면 전체 reexport(export * from ...)
|
|
17
|
-
*/
|
|
18
|
-
#reexportCache = new Map();
|
|
19
|
-
/**
|
|
20
|
-
* 역의존 정보 (revDep)
|
|
21
|
-
* - 특정 파일이 어떤 파일에게 의존(참조)되는지
|
|
22
|
-
* - symbol 기반 추적
|
|
23
|
-
*/
|
|
24
|
-
#revDepCache = new Map();
|
|
25
|
-
/**
|
|
26
|
-
* 분석이 완료된 파일 경로
|
|
27
|
-
*/
|
|
28
|
-
#collectedCache = new Set();
|
|
29
|
-
#exportSymbolCache = new Map();
|
|
30
|
-
/**
|
|
31
|
-
* .d.ts 또는 .js가 입력되었을 때 쌍으로 존재하는 파일 경로를 반환
|
|
32
|
-
* 예: "/a.d.ts" → ["/a.d.ts", "/a.js"]
|
|
33
|
-
*/
|
|
34
|
-
#getRelatedNPaths(nPath) {
|
|
35
|
-
if (nPath.endsWith(".d.ts")) {
|
|
36
|
-
return [nPath, nPath.replace(/\.d\.ts$/, ".js")];
|
|
37
|
-
}
|
|
38
|
-
if (nPath.endsWith(".js")) {
|
|
39
|
-
return [nPath, nPath.replace(/\.js$/, ".d.ts")];
|
|
40
|
-
}
|
|
41
|
-
return [nPath];
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* 전체 추적된 파일 경로를 반환
|
|
45
|
-
*/
|
|
46
|
-
// getFiles(): Set<TNormPath> {
|
|
47
|
-
// return new Set<TNormPath>([...this.#collectedCache.keys(), ...this.revDepCache.keys()]);
|
|
48
|
-
// }
|
|
49
|
-
/**
|
|
50
|
-
* 분석이 완료된 파일로 표시
|
|
51
|
-
*/
|
|
52
|
-
addCollected(fileNPath) {
|
|
53
|
-
for (const path of this.#getRelatedNPaths(fileNPath)) {
|
|
54
|
-
this.#collectedCache.add(path);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
hasCollected(fileNPath) {
|
|
58
|
-
return this.#collectedCache.has(fileNPath);
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* export한 심볼 등록
|
|
62
|
-
* 예: export const A → "A"
|
|
63
|
-
*/
|
|
64
|
-
addExport(fileNPath, exportSymbol) {
|
|
65
|
-
for (const path of this.#getRelatedNPaths(fileNPath)) {
|
|
66
|
-
const exportSymbolSet = this.#exportCache.getOrCreate(path, new Set());
|
|
67
|
-
exportSymbolSet.add(exportSymbol);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* import 구문 등록
|
|
72
|
-
* - import * from ... → symbol = 0
|
|
73
|
-
* - import { A } from ... → symbol = "A"
|
|
74
|
-
*/
|
|
75
|
-
addImport(fileNPath, targetNPath, targetSymbol) {
|
|
76
|
-
for (const filePath of this.#getRelatedNPaths(fileNPath)) {
|
|
77
|
-
const importTargetMap = this.#importCache.getOrCreate(filePath, new Map());
|
|
78
|
-
for (const targetPath of this.#getRelatedNPaths(targetNPath)) {
|
|
79
|
-
if (typeof targetSymbol === "string") {
|
|
80
|
-
const importTargetSymbolSet = importTargetMap.getOrCreate(targetPath, new Set());
|
|
81
|
-
if (!(importTargetSymbolSet instanceof Set))
|
|
82
|
-
continue;
|
|
83
|
-
importTargetSymbolSet.add(targetSymbol);
|
|
84
|
-
this.#addRevDep(targetPath, filePath, targetSymbol);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
importTargetMap.set(targetPath, targetSymbol);
|
|
88
|
-
this.#addRevDep(targetPath, filePath, targetSymbol);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* export * or export { A as B } from ... 구문 등록
|
|
95
|
-
* ※ export/import에 자동 등록되지 않으므로 외부에서 명시적으로 따로 입력해야 함
|
|
96
|
-
*/
|
|
97
|
-
addReexport(fileNPath, targetNPath, targetSymbolInfo) {
|
|
98
|
-
for (const filePath of this.#getRelatedNPaths(fileNPath)) {
|
|
99
|
-
const reexportTargetMap = this.#reexportCache.getOrCreate(filePath, new Map());
|
|
100
|
-
for (const targetPath of this.#getRelatedNPaths(targetNPath)) {
|
|
101
|
-
if (targetSymbolInfo === 0) {
|
|
102
|
-
reexportTargetMap.set(targetPath, 0);
|
|
103
|
-
this.#addRevDep(targetPath, filePath, 0);
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
const reexportTargetSymbolInfos = reexportTargetMap.getOrCreate(targetPath, []);
|
|
107
|
-
if (reexportTargetSymbolInfos === 0)
|
|
108
|
-
return;
|
|
109
|
-
if (!reexportTargetSymbolInfos.some((item) => item.importSymbol === targetSymbolInfo.importSymbol &&
|
|
110
|
-
item.exportSymbol === targetSymbolInfo.exportSymbol)) {
|
|
111
|
-
reexportTargetSymbolInfos.push(targetSymbolInfo);
|
|
112
|
-
this.#addRevDep(targetPath, filePath, targetSymbolInfo.importSymbol);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* 역의존 관계 등록 (revDep)
|
|
120
|
-
*/
|
|
121
|
-
#addRevDep(targetNPath, fileNPath, exportSymbol) {
|
|
122
|
-
for (const targetPath of this.#getRelatedNPaths(targetNPath)) {
|
|
123
|
-
const revDepInfoMap = this.#revDepCache.getOrCreate(targetPath, new Map());
|
|
124
|
-
for (const filePath of this.#getRelatedNPaths(fileNPath)) {
|
|
125
|
-
if (typeof exportSymbol === "string") {
|
|
126
|
-
const exportSymbolSet = revDepInfoMap.getOrCreate(filePath, new Set());
|
|
127
|
-
if (!(exportSymbolSet instanceof Set))
|
|
128
|
-
continue;
|
|
129
|
-
exportSymbolSet.add(exportSymbol);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
revDepInfoMap.set(filePath, exportSymbol);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* 변경된 파일 경로 집합으로부터 영향을 받는 전체 파일 집합을 계산
|
|
139
|
-
*/
|
|
140
|
-
/*getAffectedFileSet(modifiedNPathSet: Set<TNormPath>): Set<TNormPath> {
|
|
141
|
-
const visited = new Set<string>();
|
|
142
|
-
const result = new Set<TNormPath>();
|
|
143
|
-
|
|
144
|
-
const queue: { fileNPath: TNormPath; exportSymbol: string | undefined }[] = [];
|
|
145
|
-
|
|
146
|
-
const enqueue = (fileNPath: TNormPath, exportSymbol: string | undefined) => {
|
|
147
|
-
const key = `${fileNPath}#${exportSymbol}`;
|
|
148
|
-
if (!visited.has(key)) {
|
|
149
|
-
visited.add(key);
|
|
150
|
-
queue.push({ fileNPath, exportSymbol });
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
for (const modifiedNPath of modifiedNPathSet) {
|
|
155
|
-
for (const path of this.#getRelatedNPaths(modifiedNPath)) {
|
|
156
|
-
result.add(path);
|
|
157
|
-
const exportSymbols = this.#getExportSymbols(path);
|
|
158
|
-
if (exportSymbols.size === 0) {
|
|
159
|
-
enqueue(path, undefined);
|
|
160
|
-
} else {
|
|
161
|
-
for (const symbol of exportSymbols) {
|
|
162
|
-
enqueue(path, symbol);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
while (queue.length > 0) {
|
|
169
|
-
const curr = queue.shift()!;
|
|
170
|
-
const revDepInfoMap = this._revDepCache.get(curr.fileNPath);
|
|
171
|
-
if (!revDepInfoMap) continue;
|
|
172
|
-
|
|
173
|
-
for (const [revDepFileNPath, revDepInfo] of revDepInfoMap) {
|
|
174
|
-
if (curr.exportSymbol != null) {
|
|
175
|
-
const hasImportSymbol = revDepInfo === 0 || revDepInfo.has(curr.exportSymbol);
|
|
176
|
-
if (hasImportSymbol) {
|
|
177
|
-
result.add(revDepFileNPath);
|
|
178
|
-
const exportSymbol = this.#convertImportSymbolToExportSymbol(
|
|
179
|
-
revDepFileNPath,
|
|
180
|
-
curr.fileNPath,
|
|
181
|
-
curr.exportSymbol,
|
|
182
|
-
);
|
|
183
|
-
enqueue(revDepFileNPath, exportSymbol);
|
|
184
|
-
}
|
|
185
|
-
} else {
|
|
186
|
-
result.add(revDepFileNPath);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return result;
|
|
192
|
-
}*/
|
|
193
|
-
getAffectedFileMap(modifiedNPathSet) {
|
|
194
|
-
const resultMap = new Map();
|
|
195
|
-
for (const modifiedNPath of modifiedNPathSet) {
|
|
196
|
-
const visited = new Set();
|
|
197
|
-
const result = new Set();
|
|
198
|
-
const queue = [];
|
|
199
|
-
const enqueue = (fileNPath, exportSymbol) => {
|
|
200
|
-
const key = `${fileNPath}#${exportSymbol}`;
|
|
201
|
-
if (!visited.has(key)) {
|
|
202
|
-
visited.add(key);
|
|
203
|
-
queue.push({ fileNPath, exportSymbol });
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
for (const path of this.#getRelatedNPaths(modifiedNPath)) {
|
|
207
|
-
result.add(path);
|
|
208
|
-
const exportSymbols = this.#getExportSymbols(path);
|
|
209
|
-
if (exportSymbols.size === 0) {
|
|
210
|
-
enqueue(path, undefined);
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
for (const symbol of exportSymbols) {
|
|
214
|
-
enqueue(path, symbol);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
while (queue.length > 0) {
|
|
219
|
-
const curr = queue.shift();
|
|
220
|
-
const revDepInfoMap = this.#revDepCache.get(curr.fileNPath);
|
|
221
|
-
if (!revDepInfoMap)
|
|
222
|
-
continue;
|
|
223
|
-
for (const [revDepFileNPath, revDepInfo] of revDepInfoMap) {
|
|
224
|
-
if (curr.exportSymbol != null) {
|
|
225
|
-
const hasImportSymbol = revDepInfo === 0 || revDepInfo.has(curr.exportSymbol);
|
|
226
|
-
if (hasImportSymbol) {
|
|
227
|
-
result.add(revDepFileNPath);
|
|
228
|
-
const exportSymbol = this.#convertImportSymbolToExportSymbol(revDepFileNPath, curr.fileNPath, curr.exportSymbol);
|
|
229
|
-
enqueue(revDepFileNPath, exportSymbol);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
result.add(revDepFileNPath);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
resultMap.set(modifiedNPath, result);
|
|
238
|
-
}
|
|
239
|
-
return resultMap;
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* 주어진 파일들 및 그 영향 범위에 해당하는 모든 캐시를 무효화
|
|
243
|
-
*/
|
|
244
|
-
invalidates(fileNPathSet) {
|
|
245
|
-
// const affectedFileMap = this.getAffectedFileMap(fileNPathSet);
|
|
246
|
-
const revDepCacheChanged = new Set();
|
|
247
|
-
for (const fileNPath of fileNPathSet) {
|
|
248
|
-
this.#exportCache.delete(fileNPath);
|
|
249
|
-
this.#importCache.delete(fileNPath);
|
|
250
|
-
this.#reexportCache.delete(fileNPath);
|
|
251
|
-
this.#exportSymbolCache.delete(fileNPath);
|
|
252
|
-
this.#collectedCache.delete(fileNPath);
|
|
253
|
-
if (this.#revDepCache.has(fileNPath)) {
|
|
254
|
-
this.#revDepCache.delete(fileNPath); // 자신이 key인 경우
|
|
255
|
-
revDepCacheChanged.add(fileNPath);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
for (const [targetNPath, infoMap] of this.#revDepCache) {
|
|
259
|
-
for (const fileNPath of fileNPathSet) {
|
|
260
|
-
if (infoMap.has(fileNPath)) {
|
|
261
|
-
infoMap.delete(fileNPath);
|
|
262
|
-
revDepCacheChanged.add(targetNPath);
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
if (infoMap.size === 0) {
|
|
266
|
-
this.#revDepCache.delete(targetNPath);
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* reexport된 경우 importSymbol → exportSymbol로 변환
|
|
272
|
-
*/
|
|
273
|
-
#convertImportSymbolToExportSymbol(fileNPath, targetNPath, importSymbol) {
|
|
274
|
-
const symbolInfos = this.#reexportCache.get(fileNPath)?.get(targetNPath);
|
|
275
|
-
if (symbolInfos != null && symbolInfos !== 0 && symbolInfos.length > 0) {
|
|
276
|
-
const symbolInfo = symbolInfos.single((item) => item.importSymbol === importSymbol);
|
|
277
|
-
if (symbolInfo)
|
|
278
|
-
return symbolInfo.exportSymbol;
|
|
279
|
-
}
|
|
280
|
-
return importSymbol;
|
|
281
|
-
}
|
|
282
|
-
/**
|
|
283
|
-
* 해당 파일에서 export된 모든 심볼 (직접 + 재export 포함)
|
|
284
|
-
*/
|
|
285
|
-
#getExportSymbols(fileNPath) {
|
|
286
|
-
if (this.#exportSymbolCache.has(fileNPath)) {
|
|
287
|
-
return this.#exportSymbolCache.get(fileNPath);
|
|
288
|
-
}
|
|
289
|
-
const result = new Set();
|
|
290
|
-
for (const path of this.#getRelatedNPaths(fileNPath)) {
|
|
291
|
-
const set = this.#exportCache.get(path);
|
|
292
|
-
if (set)
|
|
293
|
-
result.adds(...set);
|
|
294
|
-
const map = this.#reexportCache.get(path);
|
|
295
|
-
if (map) {
|
|
296
|
-
for (const [key, val] of map) {
|
|
297
|
-
if (val === 0) {
|
|
298
|
-
result.adds(...this.#getExportSymbols(key));
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
result.adds(...val.map((item) => item.exportSymbol));
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
this.#exportSymbolCache.set(fileNPath, result);
|
|
307
|
-
return result;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
//# sourceMappingURL=sd-dependency-cache.js.map
|