@simplysm/sd-cli 14.0.41 → 14.0.43
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/angular/angular-compiler.d.ts +0 -35
- package/dist/angular/angular-compiler.d.ts.map +1 -1
- package/dist/angular/angular-compiler.js +0 -374
- package/dist/angular/angular-compiler.js.map +1 -1
- package/dist/angular/hmr-candidates.d.ts +13 -0
- package/dist/angular/hmr-candidates.d.ts.map +1 -0
- package/dist/angular/hmr-candidates.js +230 -0
- package/dist/angular/hmr-candidates.js.map +1 -0
- package/dist/angular/ngtsc-build-core.d.ts +29 -34
- package/dist/angular/ngtsc-build-core.d.ts.map +1 -1
- package/dist/angular/ngtsc-build-core.js +90 -51
- package/dist/angular/ngtsc-build-core.js.map +1 -1
- package/dist/angular/vite-angular-plugin.d.ts +1 -1
- package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
- package/dist/angular/vite-angular-plugin.js +63 -56
- package/dist/angular/vite-angular-plugin.js.map +1 -1
- package/dist/angular/web-worker-transformer.d.ts +9 -0
- package/dist/angular/web-worker-transformer.d.ts.map +1 -0
- package/dist/angular/web-worker-transformer.js +73 -0
- package/dist/angular/web-worker-transformer.js.map +1 -0
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +6 -4
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/check.d.ts +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +15 -65
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/publish/deployment-phase.d.ts.map +1 -1
- package/dist/commands/publish/deployment-phase.js +13 -5
- package/dist/commands/publish/deployment-phase.js.map +1 -1
- package/dist/commands/publish/npm-publisher.js +1 -1
- package/dist/commands/publish/npm-publisher.js.map +1 -1
- package/dist/commands/publish/publish-command.js +1 -1
- package/dist/commands/publish/publish-command.js.map +1 -1
- package/dist/commands/publish/version-upgrade.js +1 -1
- package/dist/commands/publish/version-upgrade.js.map +1 -1
- package/dist/commands/replace-deps.d.ts.map +1 -1
- package/dist/commands/replace-deps.js +2 -1
- package/dist/commands/replace-deps.js.map +1 -1
- package/dist/deps/replace-deps/collect-deps.d.ts.map +1 -1
- package/dist/deps/replace-deps/collect-deps.js +5 -2
- package/dist/deps/replace-deps/collect-deps.js.map +1 -1
- package/dist/deps/replace-deps/replace-deps.d.ts +21 -3
- package/dist/deps/replace-deps/replace-deps.d.ts.map +1 -1
- package/dist/deps/replace-deps/replace-deps.js +107 -62
- package/dist/deps/replace-deps/replace-deps.js.map +1 -1
- package/dist/electron/electron.js +7 -7
- package/dist/electron/electron.js.map +1 -1
- package/dist/engines/BaseEngine.d.ts.map +1 -1
- package/dist/engines/BaseEngine.js +2 -5
- package/dist/engines/BaseEngine.js.map +1 -1
- package/dist/engines/EsbuildClientEngine.d.ts.map +1 -1
- package/dist/engines/EsbuildClientEngine.js +16 -9
- package/dist/engines/EsbuildClientEngine.js.map +1 -1
- package/dist/engines/NgtscEngine.d.ts +4 -4
- package/dist/engines/NgtscEngine.d.ts.map +1 -1
- package/dist/engines/NgtscEngine.js +5 -5
- package/dist/engines/NgtscEngine.js.map +1 -1
- package/dist/engines/TscEngine.d.ts.map +1 -1
- package/dist/engines/TscEngine.js +0 -2
- package/dist/engines/TscEngine.js.map +1 -1
- package/dist/engines/types.d.ts +2 -0
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/esbuild/esbuild-angular-compiler-plugin.d.ts +36 -0
- package/dist/esbuild/esbuild-angular-compiler-plugin.d.ts.map +1 -0
- package/dist/esbuild/esbuild-angular-compiler-plugin.js +464 -0
- package/dist/esbuild/esbuild-angular-compiler-plugin.js.map +1 -0
- package/dist/esbuild/esbuild-client-config.d.ts +8 -2
- package/dist/esbuild/esbuild-client-config.d.ts.map +1 -1
- package/dist/esbuild/esbuild-client-config.js +48 -33
- package/dist/esbuild/esbuild-client-config.js.map +1 -1
- package/dist/esbuild/esbuild-tsc-plugin.d.ts +4 -1
- package/dist/esbuild/esbuild-tsc-plugin.d.ts.map +1 -1
- package/dist/esbuild/esbuild-tsc-plugin.js +27 -23
- package/dist/esbuild/esbuild-tsc-plugin.js.map +1 -1
- package/dist/esbuild/file-reference-tracker.d.ts +24 -0
- package/dist/esbuild/file-reference-tracker.d.ts.map +1 -0
- package/dist/esbuild/file-reference-tracker.js +57 -0
- package/dist/esbuild/file-reference-tracker.js.map +1 -0
- package/dist/esbuild/lmdb-cache-store.d.ts +18 -0
- package/dist/esbuild/lmdb-cache-store.d.ts.map +1 -0
- package/dist/esbuild/lmdb-cache-store.js +41 -0
- package/dist/esbuild/lmdb-cache-store.js.map +1 -0
- package/dist/esbuild/load-result-cache.d.ts +17 -0
- package/dist/esbuild/load-result-cache.d.ts.map +1 -0
- package/dist/esbuild/load-result-cache.js +61 -0
- package/dist/esbuild/load-result-cache.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lint/lint-core.js +7 -7
- package/dist/lint/lint-core.js.map +1 -1
- package/dist/orchestrators/BaseOrchestrator.js +2 -2
- package/dist/orchestrators/BaseOrchestrator.js.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +5 -19
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.js +5 -5
- package/dist/orchestrators/DevOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.js +6 -6
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
- package/dist/runtime/ResultCollector.d.ts +1 -0
- package/dist/runtime/ResultCollector.d.ts.map +1 -1
- package/dist/runtime/ResultCollector.js.map +1 -1
- package/dist/runtime/engine-watch-events.d.ts.map +1 -1
- package/dist/runtime/engine-watch-events.js +3 -0
- package/dist/runtime/engine-watch-events.js.map +1 -1
- package/dist/runtime/rebuild-manager.js +1 -1
- package/dist/runtime/rebuild-manager.js.map +1 -1
- package/dist/runtime/worker-utils.js +1 -1
- package/dist/runtime/worker-utils.js.map +1 -1
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +4 -3
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.js +3 -3
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-compiler/SdTsCompiler.d.ts +39 -0
- package/dist/ts-compiler/SdTsCompiler.d.ts.map +1 -0
- package/dist/ts-compiler/SdTsCompiler.js +593 -0
- package/dist/ts-compiler/SdTsCompiler.js.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-options.d.ts +40 -0
- package/dist/ts-compiler/sd-ts-compiler-options.d.ts.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-options.js +2 -0
- package/dist/ts-compiler/sd-ts-compiler-options.js.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-result.d.ts +34 -0
- package/dist/ts-compiler/sd-ts-compiler-result.d.ts.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-result.js +2 -0
- package/dist/ts-compiler/sd-ts-compiler-result.js.map +1 -0
- package/dist/utils/copy-public.d.ts +6 -4
- package/dist/utils/copy-public.d.ts.map +1 -1
- package/dist/utils/copy-public.js +9 -7
- package/dist/utils/copy-public.js.map +1 -1
- package/dist/utils/diagnostic-utils.d.ts +2 -3
- package/dist/utils/diagnostic-utils.d.ts.map +1 -1
- package/dist/utils/diagnostic-utils.js +8 -9
- package/dist/utils/diagnostic-utils.js.map +1 -1
- package/dist/utils/output-utils.d.ts +8 -2
- package/dist/utils/output-utils.d.ts.map +1 -1
- package/dist/utils/output-utils.js +32 -8
- package/dist/utils/output-utils.js.map +1 -1
- package/dist/workers/client.worker.d.ts +1 -1
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +136 -110
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/library-build.worker.d.ts +0 -2
- package/dist/workers/library-build.worker.d.ts.map +1 -1
- package/dist/workers/library-build.worker.js +147 -70
- package/dist/workers/library-build.worker.js.map +1 -1
- package/dist/workers/server-build.worker.d.ts.map +1 -1
- package/dist/workers/server-build.worker.js +30 -57
- package/dist/workers/server-build.worker.js.map +1 -1
- package/dist/workers/server-esbuild-context.d.ts +7 -0
- package/dist/workers/server-esbuild-context.d.ts.map +1 -1
- package/dist/workers/server-esbuild-context.js +11 -2
- package/dist/workers/server-esbuild-context.js.map +1 -1
- package/package.json +7 -6
- package/src/angular/angular-compiler.ts +0 -502
- package/src/angular/hmr-candidates.ts +295 -0
- package/src/angular/ngtsc-build-core.ts +125 -92
- package/src/angular/vite-angular-plugin.ts +71 -65
- package/src/angular/web-worker-transformer.ts +117 -0
- package/src/capacitor/capacitor.ts +6 -4
- package/src/commands/check.ts +17 -76
- package/src/commands/publish/deployment-phase.ts +11 -7
- package/src/commands/publish/npm-publisher.ts +1 -1
- package/src/commands/publish/publish-command.ts +1 -1
- package/src/commands/publish/version-upgrade.ts +1 -1
- package/src/commands/replace-deps.ts +3 -1
- package/src/deps/replace-deps/collect-deps.ts +4 -2
- package/src/deps/replace-deps/replace-deps.ts +114 -66
- package/src/electron/electron.ts +7 -7
- package/src/engines/BaseEngine.ts +2 -6
- package/src/engines/EsbuildClientEngine.ts +16 -10
- package/src/engines/NgtscEngine.ts +7 -7
- package/src/engines/TscEngine.ts +0 -2
- package/src/engines/types.ts +2 -0
- package/src/esbuild/esbuild-angular-compiler-plugin.ts +647 -0
- package/src/esbuild/esbuild-client-config.ts +57 -41
- package/src/esbuild/esbuild-tsc-plugin.ts +33 -23
- package/src/esbuild/file-reference-tracker.ts +61 -0
- package/src/esbuild/lmdb-cache-store.ts +46 -0
- package/src/esbuild/load-result-cache.ts +85 -0
- package/src/index.ts +5 -0
- package/src/lint/lint-core.ts +7 -7
- package/src/orchestrators/BaseOrchestrator.ts +2 -2
- package/src/orchestrators/BuildOrchestrator.ts +5 -24
- package/src/orchestrators/DevOrchestrator.ts +5 -5
- package/src/orchestrators/WatchOrchestrator.ts +6 -6
- package/src/runtime/ResultCollector.ts +1 -0
- package/src/runtime/engine-watch-events.ts +3 -0
- package/src/runtime/rebuild-manager.ts +1 -1
- package/src/runtime/worker-utils.ts +1 -1
- package/src/sd-cli-entry.ts +5 -3
- package/src/sd-cli.ts +4 -4
- package/src/ts-compiler/SdTsCompiler.ts +815 -0
- package/src/ts-compiler/sd-ts-compiler-options.ts +46 -0
- package/src/ts-compiler/sd-ts-compiler-result.ts +34 -0
- package/src/utils/copy-public.ts +9 -6
- package/src/utils/diagnostic-utils.ts +8 -9
- package/src/utils/output-utils.ts +38 -8
- package/src/workers/client.worker.ts +160 -126
- package/src/workers/library-build.worker.ts +187 -75
- package/src/workers/server-build.worker.ts +31 -61
- package/src/workers/server-esbuild-context.ts +14 -2
- package/tests/angular/fixtures/packages/basic-app/dist/styles.css +3 -0
- package/tests/angular/fixtures/packages/basic-app/scss/styles.scss +5 -0
- package/tests/angular/vite-angular-plugin-sdtscompiler.verify.md +13 -0
- package/tests/angular/web-worker-transformer.spec.ts +154 -0
- package/tests/capacitor/capacitor-build.spec.ts +1 -1
- package/tests/capacitor/capacitor-icon.spec.ts +1 -1
- package/tests/capacitor/capacitor-init.spec.ts +1 -1
- package/tests/commands/check.spec.ts +90 -104
- package/tests/commands/publish.spec.ts +12 -4
- package/tests/commands/slice3-severity-cleanup.verify.md +12 -0
- package/tests/deps/replace-deps/collect-deps.acc.spec.ts +62 -0
- package/tests/deps/replace-deps/collect-deps.spec.ts +49 -0
- package/tests/deps/replace-deps/replace-deps-filter.spec.ts +103 -0
- package/tests/deps/replace-deps/replace-deps-setup.acc.spec.ts +156 -0
- package/tests/electron/electron.spec.ts +4 -1
- package/tests/engines/engine-adapter-isolation.spec.ts +5 -6
- package/tests/engines/engine-duplicate-output-removal.verify.md +10 -0
- package/tests/engines/esbuild-client-engine.acc.spec.ts +79 -0
- package/tests/engines/esbuild-client-engine.spec.ts +73 -3
- package/tests/esbuild/esbuild-angular-compiler-plugin-hmr.verify.md +23 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-onload.verify.md +21 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-onstart-extraction.verify.md +16 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-sdtscompiler.verify.md +15 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-stylesheet.verify.md +31 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-worker.verify.md +31 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin.spec.ts +397 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin.verify.md +21 -0
- package/tests/esbuild/esbuild-tsc-plugin-imports.verify.md +13 -0
- package/tests/esbuild/esbuild-tsc-plugin.acc.spec.ts +56 -111
- package/tests/esbuild/esbuild-tsc-plugin.spec.ts +116 -52
- package/tests/esbuild/file-reference-tracker.spec.ts +99 -0
- package/tests/esbuild/lmdb-cache-store.spec.ts +58 -0
- package/tests/esbuild/load-result-cache.acc.spec.ts +55 -0
- package/tests/esbuild/load-result-cache.spec.ts +133 -0
- package/tests/orchestrators/build-orchestrator.spec.ts +4 -3
- package/tests/orchestrators/dev-orchestrator.spec.ts +5 -5
- package/tests/orchestrators/slice1-stdout-to-consola.verify.md +10 -0
- package/tests/orchestrators/typecheck-orchestrator.spec.ts +1 -1
- package/tests/orchestrators/watch-orchestrator.spec.ts +7 -7
- package/tests/runtime/result-collector.spec.ts +64 -0
- package/tests/sd-cli-entry.spec.ts +3 -4
- package/tests/sd-cli-log-tag.verify.md +11 -0
- package/tests/ts-compiler/SdTsCompiler-affected-files.verify.md +8 -0
- package/tests/ts-compiler/SdTsCompiler-diagnostics.verify.md +12 -0
- package/tests/ts-compiler/SdTsCompiler-emit.verify.md +9 -0
- package/tests/ts-compiler/SdTsCompiler.acc.spec.ts +603 -0
- package/tests/ts-compiler/SdTsCompiler.spec.ts +265 -0
- package/tests/ts-compiler/SdTsCompiler.verify.md +41 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck-browser.tsbuildinfo +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck-node.tsbuildinfo +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck.tsbuildinfo +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.d.ts +2 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.d.ts.map +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.js +4 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.js.map +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.d.ts +2 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.d.ts.map +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.js +4 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.js.map +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/src/index.ts +3 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/src/util.ts +3 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/tests/sample.test-file.ts +3 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/tsconfig.json +12 -0
- package/tests/ts-compiler/scss-lint-integration.verify.md +14 -0
- package/tests/utils/angular-build.spec.ts +1 -1
- package/tests/utils/copy-public-outdir.verify.md +8 -0
- package/tests/utils/copy-public.acc.spec.ts +52 -0
- package/tests/utils/copy-public.spec.ts +56 -0
- package/tests/utils/diagnostic-utils.spec.ts +24 -15
- package/tests/utils/engine-watch-events.acc.spec.ts +59 -0
- package/tests/utils/engine-watch-events.spec.ts +58 -0
- package/tests/utils/esbuild-client-config-integration.verify.md +9 -0
- package/tests/utils/esbuild-client-config.acc.spec.ts +45 -61
- package/tests/utils/esbuild-client-config.spec.ts +70 -52
- package/tests/utils/ngtsc-build-core-write-emit.spec.ts +12 -12
- package/tests/utils/ngtsc-build-core.spec.ts +1 -44
- package/tests/utils/output-utils.spec.ts +133 -13
- package/tests/utils/replace-deps-watch.acc.spec.ts +7 -1
- package/tests/utils/replace-deps-watch.spec.ts +57 -1
- package/tests/utils/worker-utils.spec.ts +8 -2
- package/tests/workers/client-worker-initial-build-error.verify.md +2 -3
- package/tests/workers/client-worker-initial-build-warnings.verify.md +7 -0
- package/tests/workers/client-worker-refactor.verify.md +22 -0
- package/tests/workers/client-worker-ts-cache-invalidation.verify.md +12 -0
- package/tests/workers/client-worker.acc.spec.ts +6 -3
- package/tests/workers/library-build-lint.spec.ts +40 -45
- package/tests/workers/library-build-worker.spec.ts +294 -40
- package/tests/workers/server-build-lint.spec.ts +59 -45
- package/tests/workers/server-build-worker.spec.ts +63 -24
- package/tests/workers/server-esbuild-context.acc.spec.ts +2 -0
- package/tests/workers/server-esbuild-context.spec.ts +2 -0
- package/tests/workers/server-runtime-worker.spec.ts +1 -1
- package/tests/workers/shared-worker-lifecycle.acc.spec.ts +1 -1
- package/dist/angular/angular-build-pipeline.d.ts +0 -97
- package/dist/angular/angular-build-pipeline.d.ts.map +0 -1
- package/dist/angular/angular-build-pipeline.js +0 -285
- package/dist/angular/angular-build-pipeline.js.map +0 -1
- package/dist/utils/tsc-build.d.ts +0 -51
- package/dist/utils/tsc-build.d.ts.map +0 -1
- package/dist/utils/tsc-build.js +0 -156
- package/dist/utils/tsc-build.js.map +0 -1
- package/dist/workers/ngtsc-build.worker.d.ts +0 -23
- package/dist/workers/ngtsc-build.worker.d.ts.map +0 -1
- package/dist/workers/ngtsc-build.worker.js +0 -267
- package/dist/workers/ngtsc-build.worker.js.map +0 -1
- package/src/angular/angular-build-pipeline.ts +0 -406
- package/src/utils/tsc-build.ts +0 -226
- package/src/workers/ngtsc-build.worker.ts +0 -351
- package/tests/angular/angular-build-pipeline.spec.ts +0 -247
- package/tests/angular/angular-compiler-aot.acc.spec.ts +0 -68
- package/tests/angular/angular-compiler-aot.spec.ts +0 -80
- package/tests/utils/angular-compiler-emit.spec.ts +0 -666
- package/tests/utils/angular-compiler.spec.ts +0 -707
- package/tests/utils/tsc-build.spec.ts +0 -527
- package/tests/workers/ngtsc-build-lint.spec.ts +0 -141
- package/tests/workers/ngtsc-build-worker.spec.ts +0 -199
|
@@ -1,666 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
import ts from "typescript";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
import os from "os";
|
|
6
|
-
|
|
7
|
-
// --- Mock Setup ---
|
|
8
|
-
|
|
9
|
-
const mockAnalyzeAsync = vi.fn().mockResolvedValue(undefined);
|
|
10
|
-
const mockGetDiagnosticsForFile = vi.fn().mockReturnValue([]);
|
|
11
|
-
const mockGetOptionDiagnostics = vi.fn().mockReturnValue([]);
|
|
12
|
-
const mockGetResourceDependencies = vi.fn().mockReturnValue([]);
|
|
13
|
-
const mockIgnoreForDiagnostics = new Set<ts.SourceFile>();
|
|
14
|
-
const mockIgnoreForEmit = new Set<ts.SourceFile>();
|
|
15
|
-
const mockSafeToSkipEmit = vi.fn().mockReturnValue(false);
|
|
16
|
-
const mockRecordSuccessfulEmit = vi.fn();
|
|
17
|
-
const mockPrepareEmit = vi.fn().mockReturnValue({
|
|
18
|
-
transformers: { before: [], after: [] },
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const ngtscConstructorSpy = vi.fn();
|
|
22
|
-
|
|
23
|
-
function createRealTsProgram(
|
|
24
|
-
files: Record<string, string> = { "index.ts": "export const x = 1;" },
|
|
25
|
-
extraOptions: ts.CompilerOptions = {},
|
|
26
|
-
): { program: ts.Program; dir: string; rootNames: string[] } {
|
|
27
|
-
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "angular-compiler-test-"));
|
|
28
|
-
const rootNames: string[] = [];
|
|
29
|
-
for (const [name, content] of Object.entries(files)) {
|
|
30
|
-
const filePath = path.join(dir, name);
|
|
31
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
32
|
-
fs.writeFileSync(filePath, content, "utf-8");
|
|
33
|
-
rootNames.push(filePath);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const options: ts.CompilerOptions = {
|
|
37
|
-
target: ts.ScriptTarget.ESNext,
|
|
38
|
-
module: ts.ModuleKind.ESNext,
|
|
39
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
40
|
-
strict: false,
|
|
41
|
-
skipLibCheck: true,
|
|
42
|
-
types: [],
|
|
43
|
-
outDir: path.join(dir, "out"),
|
|
44
|
-
...extraOptions,
|
|
45
|
-
};
|
|
46
|
-
const host = ts.createCompilerHost(options);
|
|
47
|
-
const program = ts.createProgram(rootNames, options, host);
|
|
48
|
-
return { program, dir, rootNames };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
let realProgram: { program: ts.Program; dir: string; rootNames: string[] };
|
|
52
|
-
|
|
53
|
-
vi.mock("../../src/angular/angular-build", () => {
|
|
54
|
-
class NgtscProgram {
|
|
55
|
-
compiler = {
|
|
56
|
-
analyzeAsync: mockAnalyzeAsync,
|
|
57
|
-
getDiagnosticsForFile: mockGetDiagnosticsForFile,
|
|
58
|
-
getOptionDiagnostics: mockGetOptionDiagnostics,
|
|
59
|
-
getResourceDependencies: mockGetResourceDependencies,
|
|
60
|
-
ignoreForDiagnostics: mockIgnoreForDiagnostics,
|
|
61
|
-
ignoreForEmit: mockIgnoreForEmit,
|
|
62
|
-
incrementalCompilation: {
|
|
63
|
-
safeToSkipEmit: mockSafeToSkipEmit,
|
|
64
|
-
recordSuccessfulEmit: mockRecordSuccessfulEmit,
|
|
65
|
-
},
|
|
66
|
-
prepareEmit: mockPrepareEmit,
|
|
67
|
-
};
|
|
68
|
-
constructor(...args: unknown[]) {
|
|
69
|
-
ngtscConstructorSpy(...args);
|
|
70
|
-
}
|
|
71
|
-
getTsProgram() {
|
|
72
|
-
return realProgram.program;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return {
|
|
76
|
-
NgtscProgram,
|
|
77
|
-
OptimizeFor: { WholeProgram: 0, SingleFile: 1 },
|
|
78
|
-
};
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
const { AngularCompiler, AngularSourceFileCache } = await import(
|
|
82
|
-
"../../src/angular/angular-compiler"
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// --- Common beforeEach ---
|
|
86
|
-
|
|
87
|
-
beforeEach(() => {
|
|
88
|
-
vi.clearAllMocks();
|
|
89
|
-
mockIgnoreForDiagnostics.clear();
|
|
90
|
-
mockIgnoreForEmit.clear();
|
|
91
|
-
mockGetResourceDependencies.mockReturnValue([]);
|
|
92
|
-
mockGetDiagnosticsForFile.mockReturnValue([]);
|
|
93
|
-
mockSafeToSkipEmit.mockReturnValue(false);
|
|
94
|
-
mockRecordSuccessfulEmit.mockReset();
|
|
95
|
-
mockPrepareEmit.mockReturnValue({
|
|
96
|
-
transformers: { before: [], after: [] },
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
realProgram = createRealTsProgram();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// =============================================================================
|
|
103
|
-
// emitAffectedFiles — Unit Tests
|
|
104
|
-
// =============================================================================
|
|
105
|
-
|
|
106
|
-
describe("emitAffectedFiles — Unit Tests", () => {
|
|
107
|
-
it("initialize() 전 호출 시 에러를 던진다", () => {
|
|
108
|
-
const compiler = new AngularCompiler({
|
|
109
|
-
rootNames: ["src/main.ts"],
|
|
110
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
expect(() => [...compiler.emitAffectedFiles()]).toThrow("initialize()");
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("noEmit=true이면 빈 Iterator를 반환한다", async () => {
|
|
117
|
-
realProgram = createRealTsProgram({ "index.ts": "export const x = 1;" }, { noEmit: true });
|
|
118
|
-
|
|
119
|
-
const compiler = new AngularCompiler({
|
|
120
|
-
rootNames: realProgram.rootNames,
|
|
121
|
-
compilerOptions: {
|
|
122
|
-
target: ts.ScriptTarget.ESNext,
|
|
123
|
-
module: ts.ModuleKind.ESNext,
|
|
124
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
125
|
-
skipLibCheck: true,
|
|
126
|
-
types: [],
|
|
127
|
-
noEmit: true,
|
|
128
|
-
},
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
await compiler.initialize();
|
|
132
|
-
|
|
133
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
134
|
-
expect(results).toHaveLength(0);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("ignoreForEmit에 포함된 파일은 emit되지 않는다", async () => {
|
|
138
|
-
const compiler = new AngularCompiler({
|
|
139
|
-
rootNames: realProgram.rootNames,
|
|
140
|
-
compilerOptions: {
|
|
141
|
-
target: ts.ScriptTarget.ESNext,
|
|
142
|
-
module: ts.ModuleKind.ESNext,
|
|
143
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
144
|
-
skipLibCheck: true,
|
|
145
|
-
types: [],
|
|
146
|
-
},
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
await compiler.initialize();
|
|
150
|
-
|
|
151
|
-
const tsProgram = compiler.getTsProgram();
|
|
152
|
-
for (const sf of tsProgram.getSourceFiles()) {
|
|
153
|
-
mockIgnoreForEmit.add(sf);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
157
|
-
expect(results).toHaveLength(0);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it("declaration file은 2차 루프에서 skip된다", async () => {
|
|
161
|
-
const compiler = new AngularCompiler({
|
|
162
|
-
rootNames: realProgram.rootNames,
|
|
163
|
-
compilerOptions: {
|
|
164
|
-
target: ts.ScriptTarget.ESNext,
|
|
165
|
-
module: ts.ModuleKind.ESNext,
|
|
166
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
167
|
-
skipLibCheck: true,
|
|
168
|
-
types: [],
|
|
169
|
-
},
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
await compiler.initialize();
|
|
173
|
-
|
|
174
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
175
|
-
const hasNodeModules = results.some((r) => r.filename.includes("node_modules"));
|
|
176
|
-
expect(hasNodeModules).toBe(false);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("sourceFilter가 적용되면 필터를 통과하지 못한 파일은 결과에 포함되지 않는다", async () => {
|
|
180
|
-
realProgram = createRealTsProgram({
|
|
181
|
-
"a.ts": "export const a = 1;",
|
|
182
|
-
"b.ts": "export const b = 2;",
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
const compiler = new AngularCompiler({
|
|
186
|
-
rootNames: realProgram.rootNames,
|
|
187
|
-
compilerOptions: {
|
|
188
|
-
target: ts.ScriptTarget.ESNext,
|
|
189
|
-
module: ts.ModuleKind.ESNext,
|
|
190
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
191
|
-
skipLibCheck: true,
|
|
192
|
-
types: [],
|
|
193
|
-
},
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
await compiler.initialize();
|
|
197
|
-
|
|
198
|
-
const results = [
|
|
199
|
-
...compiler.emitAffectedFiles({
|
|
200
|
-
sourceFilter: (fileName: string) => fileName.includes("a.ts"),
|
|
201
|
-
}),
|
|
202
|
-
];
|
|
203
|
-
|
|
204
|
-
expect(results.length).toBeGreaterThan(0);
|
|
205
|
-
for (const r of results) {
|
|
206
|
-
expect(r.sourceFileName).toContain("a.ts");
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it("EmitResult는 filename과 contents를 포함한다", async () => {
|
|
211
|
-
const compiler = new AngularCompiler({
|
|
212
|
-
rootNames: realProgram.rootNames,
|
|
213
|
-
compilerOptions: {
|
|
214
|
-
target: ts.ScriptTarget.ESNext,
|
|
215
|
-
module: ts.ModuleKind.ESNext,
|
|
216
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
217
|
-
skipLibCheck: true,
|
|
218
|
-
types: [],
|
|
219
|
-
},
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
await compiler.initialize();
|
|
223
|
-
|
|
224
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
225
|
-
expect(results.length).toBeGreaterThan(0);
|
|
226
|
-
for (const r of results) {
|
|
227
|
-
expect(typeof r.filename).toBe("string");
|
|
228
|
-
expect(typeof r.contents).toBe("string");
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
// =============================================================================
|
|
234
|
-
// emitAffectedFiles
|
|
235
|
-
// =============================================================================
|
|
236
|
-
|
|
237
|
-
describe("emitAffectedFiles", () => {
|
|
238
|
-
it("변경된 파일만 emit하고 변경되지 않은 파일은 emit하지 않는다", async () => {
|
|
239
|
-
const compiler = new AngularCompiler({
|
|
240
|
-
rootNames: realProgram.rootNames,
|
|
241
|
-
compilerOptions: {
|
|
242
|
-
target: ts.ScriptTarget.ESNext,
|
|
243
|
-
module: ts.ModuleKind.ESNext,
|
|
244
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
245
|
-
skipLibCheck: true,
|
|
246
|
-
types: [],
|
|
247
|
-
},
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
await compiler.initialize();
|
|
251
|
-
|
|
252
|
-
// 첫 빌드: 모든 파일 emit
|
|
253
|
-
const firstResults = [...compiler.emitAffectedFiles()];
|
|
254
|
-
expect(firstResults.length).toBeGreaterThan(0);
|
|
255
|
-
|
|
256
|
-
// 두번째 빌드: safeToSkipEmit=true이면 emit 안됨
|
|
257
|
-
mockSafeToSkipEmit.mockReturnValue(true);
|
|
258
|
-
await compiler.initialize();
|
|
259
|
-
|
|
260
|
-
const secondResults = [...compiler.emitAffectedFiles()];
|
|
261
|
-
expect(secondResults).toHaveLength(0);
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("첫 빌드에서 모든 소스 파일이 emit된다", async () => {
|
|
265
|
-
realProgram = createRealTsProgram({
|
|
266
|
-
"a.ts": "export const a = 1;",
|
|
267
|
-
"b.ts": "export const b = 2;",
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
const compiler = new AngularCompiler({
|
|
271
|
-
rootNames: realProgram.rootNames,
|
|
272
|
-
compilerOptions: {
|
|
273
|
-
target: ts.ScriptTarget.ESNext,
|
|
274
|
-
module: ts.ModuleKind.ESNext,
|
|
275
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
276
|
-
skipLibCheck: true,
|
|
277
|
-
types: [],
|
|
278
|
-
},
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
await compiler.initialize();
|
|
282
|
-
|
|
283
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
284
|
-
expect(results.length).toBeGreaterThanOrEqual(2);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it("safeToSkipEmit이 false인 파일이 emit된다", async () => {
|
|
288
|
-
const compiler = new AngularCompiler({
|
|
289
|
-
rootNames: realProgram.rootNames,
|
|
290
|
-
compilerOptions: {
|
|
291
|
-
target: ts.ScriptTarget.ESNext,
|
|
292
|
-
module: ts.ModuleKind.ESNext,
|
|
293
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
294
|
-
skipLibCheck: true,
|
|
295
|
-
types: [],
|
|
296
|
-
},
|
|
297
|
-
});
|
|
298
|
-
|
|
299
|
-
mockSafeToSkipEmit.mockReturnValue(false);
|
|
300
|
-
|
|
301
|
-
await compiler.initialize();
|
|
302
|
-
|
|
303
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
304
|
-
expect(results.length).toBeGreaterThan(0);
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it("safeToSkipEmit이 true이고 affectedFiles에 없으면 emit하지 않는다", async () => {
|
|
308
|
-
const compiler = new AngularCompiler({
|
|
309
|
-
rootNames: realProgram.rootNames,
|
|
310
|
-
compilerOptions: {
|
|
311
|
-
target: ts.ScriptTarget.ESNext,
|
|
312
|
-
module: ts.ModuleKind.ESNext,
|
|
313
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
314
|
-
skipLibCheck: true,
|
|
315
|
-
types: [],
|
|
316
|
-
},
|
|
317
|
-
});
|
|
318
|
-
|
|
319
|
-
// 첫 빌드 수행
|
|
320
|
-
await compiler.initialize();
|
|
321
|
-
void [...compiler.emitAffectedFiles()];
|
|
322
|
-
|
|
323
|
-
// 두번째 빌드: safeToSkipEmit=true
|
|
324
|
-
mockSafeToSkipEmit.mockReturnValue(true);
|
|
325
|
-
await compiler.initialize();
|
|
326
|
-
|
|
327
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
328
|
-
expect(results).toHaveLength(0);
|
|
329
|
-
});
|
|
330
|
-
|
|
331
|
-
it("emit 성공 시 recordSuccessfulEmit이 호출된다", async () => {
|
|
332
|
-
const compiler = new AngularCompiler({
|
|
333
|
-
rootNames: realProgram.rootNames,
|
|
334
|
-
compilerOptions: {
|
|
335
|
-
target: ts.ScriptTarget.ESNext,
|
|
336
|
-
module: ts.ModuleKind.ESNext,
|
|
337
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
338
|
-
skipLibCheck: true,
|
|
339
|
-
types: [],
|
|
340
|
-
},
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
await compiler.initialize();
|
|
344
|
-
|
|
345
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
346
|
-
expect(results.length).toBeGreaterThan(0);
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
it("prepareEmit()의 transformers가 emit에 적용된다", async () => {
|
|
350
|
-
const mockTransformer = vi.fn(
|
|
351
|
-
(_context: ts.TransformationContext) => (sf: ts.SourceFile) => sf,
|
|
352
|
-
);
|
|
353
|
-
mockPrepareEmit.mockReturnValue({
|
|
354
|
-
transformers: { before: [mockTransformer], after: [] },
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
const compiler = new AngularCompiler({
|
|
358
|
-
rootNames: realProgram.rootNames,
|
|
359
|
-
compilerOptions: {
|
|
360
|
-
target: ts.ScriptTarget.ESNext,
|
|
361
|
-
module: ts.ModuleKind.ESNext,
|
|
362
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
363
|
-
skipLibCheck: true,
|
|
364
|
-
types: [],
|
|
365
|
-
},
|
|
366
|
-
});
|
|
367
|
-
|
|
368
|
-
await compiler.initialize();
|
|
369
|
-
|
|
370
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
371
|
-
expect(results.length).toBeGreaterThan(0);
|
|
372
|
-
});
|
|
373
|
-
|
|
374
|
-
it("additionalTransformers가 emit 시 적용된다", async () => {
|
|
375
|
-
const additionalBefore = vi.fn(
|
|
376
|
-
(_context: ts.TransformationContext) => (sf: ts.SourceFile) => sf,
|
|
377
|
-
);
|
|
378
|
-
|
|
379
|
-
const compiler = new AngularCompiler({
|
|
380
|
-
rootNames: realProgram.rootNames,
|
|
381
|
-
compilerOptions: {
|
|
382
|
-
target: ts.ScriptTarget.ESNext,
|
|
383
|
-
module: ts.ModuleKind.ESNext,
|
|
384
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
385
|
-
skipLibCheck: true,
|
|
386
|
-
types: [],
|
|
387
|
-
},
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
await compiler.initialize();
|
|
391
|
-
|
|
392
|
-
const results = [
|
|
393
|
-
...compiler.emitAffectedFiles({
|
|
394
|
-
additionalTransformers: { before: [additionalBefore] },
|
|
395
|
-
}),
|
|
396
|
-
];
|
|
397
|
-
expect(results.length).toBeGreaterThan(0);
|
|
398
|
-
});
|
|
399
|
-
|
|
400
|
-
it("declaration=true, noEmit=false일 때 .js와 .d.ts 모두 emit된다", async () => {
|
|
401
|
-
realProgram = createRealTsProgram(
|
|
402
|
-
{ "index.ts": "export const x = 1;" },
|
|
403
|
-
{ declaration: true },
|
|
404
|
-
);
|
|
405
|
-
|
|
406
|
-
const compiler = new AngularCompiler({
|
|
407
|
-
rootNames: realProgram.rootNames,
|
|
408
|
-
compilerOptions: {
|
|
409
|
-
target: ts.ScriptTarget.ESNext,
|
|
410
|
-
module: ts.ModuleKind.ESNext,
|
|
411
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
412
|
-
skipLibCheck: true,
|
|
413
|
-
types: [],
|
|
414
|
-
declaration: true,
|
|
415
|
-
},
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
await compiler.initialize();
|
|
419
|
-
|
|
420
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
421
|
-
const filenames = results.map((r) => r.filename);
|
|
422
|
-
const hasJs = filenames.some((f) => f.endsWith(".js"));
|
|
423
|
-
const hasDts = filenames.some((f) => f.endsWith(".d.ts"));
|
|
424
|
-
expect(hasJs).toBe(true);
|
|
425
|
-
expect(hasDts).toBe(true);
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
it("declaration=false일 때 .js만 emit되고 .d.ts는 생성되지 않는다", async () => {
|
|
429
|
-
realProgram = createRealTsProgram(
|
|
430
|
-
{ "index.ts": "export const x = 1;" },
|
|
431
|
-
{ declaration: false },
|
|
432
|
-
);
|
|
433
|
-
|
|
434
|
-
const compiler = new AngularCompiler({
|
|
435
|
-
rootNames: realProgram.rootNames,
|
|
436
|
-
compilerOptions: {
|
|
437
|
-
target: ts.ScriptTarget.ESNext,
|
|
438
|
-
module: ts.ModuleKind.ESNext,
|
|
439
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
440
|
-
skipLibCheck: true,
|
|
441
|
-
types: [],
|
|
442
|
-
declaration: false,
|
|
443
|
-
},
|
|
444
|
-
});
|
|
445
|
-
|
|
446
|
-
await compiler.initialize();
|
|
447
|
-
|
|
448
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
449
|
-
const filenames = results.map((r) => r.filename);
|
|
450
|
-
const hasJs = filenames.some((f) => f.endsWith(".js"));
|
|
451
|
-
const hasDts = filenames.some((f) => f.endsWith(".d.ts"));
|
|
452
|
-
expect(hasJs).toBe(true);
|
|
453
|
-
expect(hasDts).toBe(false);
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
it("emitDeclarationOnly=true일 때 .d.ts만 emit되고 .js는 생성되지 않는다", async () => {
|
|
457
|
-
realProgram = createRealTsProgram(
|
|
458
|
-
{ "index.ts": "export const x = 1;" },
|
|
459
|
-
{ declaration: true, emitDeclarationOnly: true },
|
|
460
|
-
);
|
|
461
|
-
|
|
462
|
-
const compiler = new AngularCompiler({
|
|
463
|
-
rootNames: realProgram.rootNames,
|
|
464
|
-
compilerOptions: {
|
|
465
|
-
target: ts.ScriptTarget.ESNext,
|
|
466
|
-
module: ts.ModuleKind.ESNext,
|
|
467
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
468
|
-
skipLibCheck: true,
|
|
469
|
-
types: [],
|
|
470
|
-
declaration: true,
|
|
471
|
-
emitDeclarationOnly: true,
|
|
472
|
-
},
|
|
473
|
-
});
|
|
474
|
-
|
|
475
|
-
await compiler.initialize();
|
|
476
|
-
|
|
477
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
478
|
-
const filenames = results.map((r) => r.filename);
|
|
479
|
-
const hasJs = filenames.some((f) => f.endsWith(".js"));
|
|
480
|
-
const hasDts = filenames.some((f) => f.endsWith(".d.ts"));
|
|
481
|
-
expect(hasJs).toBe(false);
|
|
482
|
-
expect(hasDts).toBe(true);
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
it("noEmit=true일 때 어떤 파일도 emit되지 않는다", async () => {
|
|
486
|
-
realProgram = createRealTsProgram({ "index.ts": "export const x = 1;" }, { noEmit: true });
|
|
487
|
-
|
|
488
|
-
const compiler = new AngularCompiler({
|
|
489
|
-
rootNames: realProgram.rootNames,
|
|
490
|
-
compilerOptions: {
|
|
491
|
-
target: ts.ScriptTarget.ESNext,
|
|
492
|
-
module: ts.ModuleKind.ESNext,
|
|
493
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
494
|
-
skipLibCheck: true,
|
|
495
|
-
types: [],
|
|
496
|
-
noEmit: true,
|
|
497
|
-
},
|
|
498
|
-
});
|
|
499
|
-
|
|
500
|
-
await compiler.initialize();
|
|
501
|
-
|
|
502
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
503
|
-
expect(results).toHaveLength(0);
|
|
504
|
-
});
|
|
505
|
-
});
|
|
506
|
-
|
|
507
|
-
// =============================================================================
|
|
508
|
-
// update — Unit Tests
|
|
509
|
-
// =============================================================================
|
|
510
|
-
|
|
511
|
-
describe("update — Unit Tests", () => {
|
|
512
|
-
it("sourceFileCache가 없으면 에러를 던진다", async () => {
|
|
513
|
-
const compiler = new AngularCompiler({
|
|
514
|
-
rootNames: realProgram.rootNames,
|
|
515
|
-
compilerOptions: {
|
|
516
|
-
target: ts.ScriptTarget.ESNext,
|
|
517
|
-
module: ts.ModuleKind.ESNext,
|
|
518
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
519
|
-
skipLibCheck: true,
|
|
520
|
-
types: [],
|
|
521
|
-
},
|
|
522
|
-
});
|
|
523
|
-
|
|
524
|
-
await compiler.initialize();
|
|
525
|
-
|
|
526
|
-
await expect(compiler.update([realProgram.rootNames[0]])).rejects.toThrow("sourceFileCache");
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
it("update() 후 affectedFiles가 반환된다", async () => {
|
|
530
|
-
const cache = new AngularSourceFileCache();
|
|
531
|
-
|
|
532
|
-
const compiler = new AngularCompiler({
|
|
533
|
-
rootNames: realProgram.rootNames,
|
|
534
|
-
compilerOptions: {
|
|
535
|
-
target: ts.ScriptTarget.ESNext,
|
|
536
|
-
module: ts.ModuleKind.ESNext,
|
|
537
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
538
|
-
skipLibCheck: true,
|
|
539
|
-
types: [],
|
|
540
|
-
},
|
|
541
|
-
sourceFileCache: cache,
|
|
542
|
-
});
|
|
543
|
-
|
|
544
|
-
await compiler.initialize();
|
|
545
|
-
|
|
546
|
-
const result = await compiler.update([realProgram.rootNames[0]]);
|
|
547
|
-
expect(result.affectedFiles).toBeInstanceOf(Set);
|
|
548
|
-
});
|
|
549
|
-
});
|
|
550
|
-
|
|
551
|
-
// =============================================================================
|
|
552
|
-
// update
|
|
553
|
-
// =============================================================================
|
|
554
|
-
|
|
555
|
-
describe("update", () => {
|
|
556
|
-
it("파일 변경 후 incremental rebuild", async () => {
|
|
557
|
-
const cache = new AngularSourceFileCache();
|
|
558
|
-
|
|
559
|
-
const compiler = new AngularCompiler({
|
|
560
|
-
rootNames: realProgram.rootNames,
|
|
561
|
-
compilerOptions: {
|
|
562
|
-
target: ts.ScriptTarget.ESNext,
|
|
563
|
-
module: ts.ModuleKind.ESNext,
|
|
564
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
565
|
-
skipLibCheck: true,
|
|
566
|
-
types: [],
|
|
567
|
-
},
|
|
568
|
-
sourceFileCache: cache,
|
|
569
|
-
});
|
|
570
|
-
|
|
571
|
-
await compiler.initialize();
|
|
572
|
-
const initCallCount = ngtscConstructorSpy.mock.calls.length;
|
|
573
|
-
|
|
574
|
-
await compiler.update([realProgram.rootNames[0]]);
|
|
575
|
-
expect(ngtscConstructorSpy).toHaveBeenCalledTimes(initCallCount + 1);
|
|
576
|
-
});
|
|
577
|
-
|
|
578
|
-
it("node_modules 파일 변경 시 packageJsonCache clear", async () => {
|
|
579
|
-
const cache = new AngularSourceFileCache();
|
|
580
|
-
|
|
581
|
-
const compiler = new AngularCompiler({
|
|
582
|
-
rootNames: realProgram.rootNames,
|
|
583
|
-
compilerOptions: {
|
|
584
|
-
target: ts.ScriptTarget.ESNext,
|
|
585
|
-
module: ts.ModuleKind.ESNext,
|
|
586
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
587
|
-
skipLibCheck: true,
|
|
588
|
-
types: [],
|
|
589
|
-
},
|
|
590
|
-
sourceFileCache: cache,
|
|
591
|
-
});
|
|
592
|
-
|
|
593
|
-
await compiler.initialize();
|
|
594
|
-
|
|
595
|
-
// node_modules 파일을 변경 파일로 전달
|
|
596
|
-
await compiler.update(["node_modules/some-package/index.js"]);
|
|
597
|
-
|
|
598
|
-
// packageJsonCache clear가 실행되더라도 에러 없이 완료되어야 함
|
|
599
|
-
expect(ngtscConstructorSpy.mock.calls.length).toBeGreaterThanOrEqual(2);
|
|
600
|
-
});
|
|
601
|
-
|
|
602
|
-
it("SCSS 파일 변경 시 관련 컴포넌트가 affected에 포함", async () => {
|
|
603
|
-
const scssPath = path.join(realProgram.dir, "component.scss");
|
|
604
|
-
fs.writeFileSync(scssPath, ".x { color: red; }", "utf-8");
|
|
605
|
-
|
|
606
|
-
const indexFile = realProgram.program
|
|
607
|
-
.getSourceFiles()
|
|
608
|
-
.find((sf) => sf.fileName.includes("index.ts"));
|
|
609
|
-
|
|
610
|
-
mockGetResourceDependencies.mockImplementation((sf: ts.SourceFile) => {
|
|
611
|
-
if (sf === indexFile) {
|
|
612
|
-
return [scssPath];
|
|
613
|
-
}
|
|
614
|
-
return [];
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
const cache = new AngularSourceFileCache();
|
|
618
|
-
|
|
619
|
-
const compiler = new AngularCompiler({
|
|
620
|
-
rootNames: realProgram.rootNames,
|
|
621
|
-
compilerOptions: {
|
|
622
|
-
target: ts.ScriptTarget.ESNext,
|
|
623
|
-
module: ts.ModuleKind.ESNext,
|
|
624
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
625
|
-
skipLibCheck: true,
|
|
626
|
-
types: [],
|
|
627
|
-
},
|
|
628
|
-
sourceFileCache: cache,
|
|
629
|
-
});
|
|
630
|
-
|
|
631
|
-
await compiler.initialize();
|
|
632
|
-
|
|
633
|
-
const result = await compiler.update([scssPath]);
|
|
634
|
-
const affectedFileNames = [...result.affectedFiles].map((sf) => sf.fileName);
|
|
635
|
-
expect(affectedFileNames.some((f) => f.includes("index.ts"))).toBe(true);
|
|
636
|
-
});
|
|
637
|
-
|
|
638
|
-
it("리소스 변경 없으면 diagnosticCache 재사용", async () => {
|
|
639
|
-
const cache = new AngularSourceFileCache();
|
|
640
|
-
|
|
641
|
-
const compiler = new AngularCompiler({
|
|
642
|
-
rootNames: realProgram.rootNames,
|
|
643
|
-
compilerOptions: {
|
|
644
|
-
target: ts.ScriptTarget.ESNext,
|
|
645
|
-
module: ts.ModuleKind.ESNext,
|
|
646
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
647
|
-
skipLibCheck: true,
|
|
648
|
-
types: [],
|
|
649
|
-
},
|
|
650
|
-
sourceFileCache: cache,
|
|
651
|
-
});
|
|
652
|
-
|
|
653
|
-
await compiler.initialize();
|
|
654
|
-
|
|
655
|
-
// 첫 번째 진단 수집
|
|
656
|
-
const diags1 = [...compiler.collectDiagnostics()];
|
|
657
|
-
expect(Array.isArray(diags1)).toBe(true);
|
|
658
|
-
|
|
659
|
-
// 빈 set으로 update (리소스 변경 없음)
|
|
660
|
-
await compiler.update([]);
|
|
661
|
-
|
|
662
|
-
// diagnosticCache가 재사용되므로 진단 수집이 배열로 반환됨
|
|
663
|
-
const diags2 = [...compiler.collectDiagnostics()];
|
|
664
|
-
expect(Array.isArray(diags2)).toBe(true);
|
|
665
|
-
});
|
|
666
|
-
});
|