@simplysm/sd-cli 14.0.42 → 14.0.44
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 +41 -37
- package/dist/angular/ngtsc-build-core.d.ts.map +1 -1
- package/dist/angular/ngtsc-build-core.js +155 -52
- 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.d.ts.map +1 -1
- package/dist/commands/publish/version-upgrade.js +16 -13
- 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-resolve.d.ts.map +1 -1
- package/dist/deps/replace-deps/replace-deps-resolve.js +6 -7
- package/dist/deps/replace-deps/replace-deps-resolve.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 +175 -66
- 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-postcss-plugin.d.ts.map +1 -1
- package/dist/esbuild/esbuild-postcss-plugin.js +9 -6
- package/dist/esbuild/esbuild-postcss-plugin.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 +115 -110
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/incremental-mtime-tracker.d.ts +13 -0
- package/dist/workers/incremental-mtime-tracker.d.ts.map +1 -0
- package/dist/workers/incremental-mtime-tracker.js +65 -0
- package/dist/workers/incremental-mtime-tracker.js.map +1 -0
- 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 +169 -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 +5 -4
- package/src/angular/angular-compiler.ts +0 -502
- package/src/angular/hmr-candidates.ts +295 -0
- package/src/angular/ngtsc-build-core.ts +192 -91
- 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 +44 -35
- 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-resolve.ts +12 -7
- package/src/deps/replace-deps/replace-deps.ts +191 -69
- 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-postcss-plugin.ts +9 -6
- 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 +141 -126
- package/src/workers/incremental-mtime-tracker.ts +68 -0
- package/src/workers/library-build.worker.ts +214 -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/ngtsc-build-core.acc.spec.ts +210 -0
- package/tests/angular/ngtsc-build-core.spec.ts +52 -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/commands/version-upgrade.acc.spec.ts +210 -0
- package/tests/commands/version-upgrade.spec.ts +148 -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-perf.verify.md +15 -0
- package/tests/deps/replace-deps/replace-deps-resolve.acc.spec.ts +124 -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-postcss-plugin-chunking.verify.md +17 -0
- package/tests/esbuild/esbuild-postcss-plugin.acc.spec.ts +152 -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/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 +136 -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-mtime-incremental.verify.md +10 -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/incremental-mtime-tracker.acc.spec.ts +144 -0
- package/tests/workers/incremental-mtime-tracker.spec.ts +102 -0
- package/tests/workers/library-build-lint.spec.ts +40 -45
- package/tests/workers/library-build-worker.spec.ts +298 -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,707 +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
|
-
// AngularCompiler — Unit Tests (pre-initialize)
|
|
104
|
-
// =============================================================================
|
|
105
|
-
|
|
106
|
-
describe("AngularCompiler — Unit Tests", () => {
|
|
107
|
-
it("initialize() 전 getTsProgram()은 에러를 던진다", () => {
|
|
108
|
-
const compiler = new AngularCompiler({
|
|
109
|
-
rootNames: ["src/main.ts"],
|
|
110
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
expect(() => compiler.getTsProgram()).toThrow("initialize()");
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("initialize() 전 compiler getter는 에러를 던진다", () => {
|
|
117
|
-
const compiler = new AngularCompiler({
|
|
118
|
-
rootNames: ["src/main.ts"],
|
|
119
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
expect(() => compiler.compiler).toThrow("initialize()");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("initialize() 전 ngtscProgram은 undefined이다", () => {
|
|
126
|
-
const compiler = new AngularCompiler({
|
|
127
|
-
rootNames: ["src/main.ts"],
|
|
128
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
expect(compiler.ngtscProgram).toBeUndefined();
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("host.readResource가 파일 내용을 반환한다", async () => {
|
|
135
|
-
const compiler = new AngularCompiler({
|
|
136
|
-
rootNames: realProgram.rootNames,
|
|
137
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
await compiler.initialize();
|
|
141
|
-
|
|
142
|
-
const hostArg = ngtscConstructorSpy.mock.calls[0][2] as Record<string, Function>;
|
|
143
|
-
expect(typeof hostArg["readResource"]).toBe("function");
|
|
144
|
-
const content = (hostArg["readResource"])(realProgram.rootNames[0]);
|
|
145
|
-
expect(content).toContain("export const x = 1");
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it("host.transformResource — style이 아닌 type은 null을 반환한다", async () => {
|
|
149
|
-
const transformStylesheet = vi.fn().mockResolvedValue("css");
|
|
150
|
-
const compiler = new AngularCompiler({
|
|
151
|
-
rootNames: realProgram.rootNames,
|
|
152
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
153
|
-
transformStylesheet,
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
await compiler.initialize();
|
|
157
|
-
|
|
158
|
-
const hostArg = ngtscConstructorSpy.mock.calls[0][2] as Record<string, Function>;
|
|
159
|
-
const result = await (hostArg["transformResource"])("data", {
|
|
160
|
-
type: "template",
|
|
161
|
-
containingFile: "/app/comp.ts",
|
|
162
|
-
resourceFile: null,
|
|
163
|
-
});
|
|
164
|
-
expect(result).toBeNull();
|
|
165
|
-
expect(transformStylesheet).not.toHaveBeenCalled();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it("host.transformResource — 빈 스타일은 빈 content를 반환한다", async () => {
|
|
169
|
-
const transformStylesheet = vi.fn().mockResolvedValue("css");
|
|
170
|
-
const compiler = new AngularCompiler({
|
|
171
|
-
rootNames: realProgram.rootNames,
|
|
172
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
173
|
-
transformStylesheet,
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
await compiler.initialize();
|
|
177
|
-
|
|
178
|
-
const hostArg = ngtscConstructorSpy.mock.calls[0][2] as Record<string, Function>;
|
|
179
|
-
const result = await (hostArg["transformResource"])(" ", {
|
|
180
|
-
type: "style",
|
|
181
|
-
containingFile: "/app/comp.ts",
|
|
182
|
-
resourceFile: null,
|
|
183
|
-
});
|
|
184
|
-
expect(result).toEqual({ content: "" });
|
|
185
|
-
expect(transformStylesheet).not.toHaveBeenCalled();
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
it("host.getModifiedResourceFiles는 sourceFileCache.modifiedFiles를 반환한다", async () => {
|
|
189
|
-
const cache = new AngularSourceFileCache();
|
|
190
|
-
cache.modifiedFiles.add("src/styles.scss");
|
|
191
|
-
|
|
192
|
-
const compiler = new AngularCompiler({
|
|
193
|
-
rootNames: realProgram.rootNames,
|
|
194
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
195
|
-
sourceFileCache: cache,
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
await compiler.initialize();
|
|
199
|
-
|
|
200
|
-
const hostArg = ngtscConstructorSpy.mock.calls[0][2] as Record<string, Function>;
|
|
201
|
-
expect(typeof hostArg["getModifiedResourceFiles"]).toBe("function");
|
|
202
|
-
const modifiedFiles = (hostArg["getModifiedResourceFiles"])();
|
|
203
|
-
expect(modifiedFiles.has("src/styles.scss")).toBe(true);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it("resourceNameToFileName — 존재하지 않는 파일은 null 반환", async () => {
|
|
207
|
-
const compiler = new AngularCompiler({
|
|
208
|
-
rootNames: realProgram.rootNames,
|
|
209
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
await compiler.initialize();
|
|
213
|
-
|
|
214
|
-
const hostArg = ngtscConstructorSpy.mock.calls[0][2] as Record<string, Function>;
|
|
215
|
-
const result = (hostArg["resourceNameToFileName"])(
|
|
216
|
-
"./nonexistent.html",
|
|
217
|
-
realProgram.rootNames[0],
|
|
218
|
-
);
|
|
219
|
-
expect(result).toBeNull();
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it("resourceNameToFileName — 존재하는 템플릿 파일은 resolvedPath 반환", async () => {
|
|
223
|
-
const htmlPath = path.join(realProgram.dir, "comp.html");
|
|
224
|
-
fs.writeFileSync(htmlPath, "<div></div>", "utf-8");
|
|
225
|
-
|
|
226
|
-
const compiler = new AngularCompiler({
|
|
227
|
-
rootNames: realProgram.rootNames,
|
|
228
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
await compiler.initialize();
|
|
232
|
-
|
|
233
|
-
const hostArg = ngtscConstructorSpy.mock.calls[0][2] as Record<string, Function>;
|
|
234
|
-
const result = (hostArg["resourceNameToFileName"])(
|
|
235
|
-
"./comp.html",
|
|
236
|
-
realProgram.rootNames[0],
|
|
237
|
-
);
|
|
238
|
-
expect(result).toBe(htmlPath);
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it("resourceNameToFileName — externalStylesheets와 stylesheet일 때 SHA256 ID 반환", async () => {
|
|
242
|
-
const scssPath = path.join(realProgram.dir, "comp.scss");
|
|
243
|
-
fs.writeFileSync(scssPath, ".x{}", "utf-8");
|
|
244
|
-
|
|
245
|
-
const externalStylesheets = new Map<string, string>();
|
|
246
|
-
const compiler = new AngularCompiler({
|
|
247
|
-
rootNames: realProgram.rootNames,
|
|
248
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
249
|
-
externalStylesheets,
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
await compiler.initialize();
|
|
253
|
-
|
|
254
|
-
const hostArg = ngtscConstructorSpy.mock.calls[0][2] as Record<string, Function>;
|
|
255
|
-
const result = (hostArg["resourceNameToFileName"])(
|
|
256
|
-
"./comp.scss",
|
|
257
|
-
realProgram.rootNames[0],
|
|
258
|
-
);
|
|
259
|
-
expect(result).toMatch(/^[a-f0-9]{64}\.css$/);
|
|
260
|
-
expect(externalStylesheets.has(scssPath)).toBe(true);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it("angularCompilerOptions가 compilerOptions에 병합된다", async () => {
|
|
264
|
-
const compiler = new AngularCompiler({
|
|
265
|
-
rootNames: realProgram.rootNames,
|
|
266
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
267
|
-
angularCompilerOptions: { strictTemplates: true },
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
await compiler.initialize();
|
|
271
|
-
|
|
272
|
-
const passedOptions = ngtscConstructorSpy.mock.calls[0][1] as Record<string, unknown>;
|
|
273
|
-
expect(passedOptions["strictTemplates"]).toBe(true);
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
it("collectDiagnostics() — initialize() 전 호출 시 에러", () => {
|
|
277
|
-
const compiler = new AngularCompiler({
|
|
278
|
-
rootNames: ["src/main.ts"],
|
|
279
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
expect(() => [...compiler.collectDiagnostics()]).toThrow("initialize()");
|
|
283
|
-
});
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
// =============================================================================
|
|
287
|
-
// AngularCompiler — updateRootNames
|
|
288
|
-
// =============================================================================
|
|
289
|
-
|
|
290
|
-
describe("AngularCompiler — updateRootNames", () => {
|
|
291
|
-
// Acceptance: Scenario "updateRootNames 호출 시 compiler까지 전파"
|
|
292
|
-
it("updateRootNames() 후 initialize()에서 새 rootNames가 NgtscProgram에 전달된다", async () => {
|
|
293
|
-
const compiler = new AngularCompiler({
|
|
294
|
-
rootNames: ["src/main.ts"],
|
|
295
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
await compiler.initialize();
|
|
299
|
-
expect(ngtscConstructorSpy.mock.calls[0][0]).toEqual(["src/main.ts"]);
|
|
300
|
-
|
|
301
|
-
compiler.updateRootNames(["src/main.ts", "src/new.ts"]);
|
|
302
|
-
await compiler.initialize();
|
|
303
|
-
|
|
304
|
-
expect(ngtscConstructorSpy.mock.calls[1][0]).toEqual(["src/main.ts", "src/new.ts"]);
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
it("updateRootNames()로 빈 배열 설정 후 initialize()에서 빈 rootNames가 전달된다", async () => {
|
|
308
|
-
const compiler = new AngularCompiler({
|
|
309
|
-
rootNames: ["src/main.ts"],
|
|
310
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
await compiler.initialize();
|
|
314
|
-
compiler.updateRootNames([]);
|
|
315
|
-
await compiler.initialize();
|
|
316
|
-
|
|
317
|
-
expect(ngtscConstructorSpy.mock.calls[1][0]).toEqual([]);
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
// =============================================================================
|
|
322
|
-
// AngularCompiler — 초기화
|
|
323
|
-
// =============================================================================
|
|
324
|
-
|
|
325
|
-
describe("AngularCompiler — 초기화", () => {
|
|
326
|
-
it("initialize()로 호스트, NgtscProgram, BuilderProgram이 생성되고 analyzeAsync가 호출된다", async () => {
|
|
327
|
-
const compiler = new AngularCompiler({
|
|
328
|
-
rootNames: ["src/main.ts"],
|
|
329
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
330
|
-
});
|
|
331
|
-
|
|
332
|
-
const result = await compiler.initialize();
|
|
333
|
-
|
|
334
|
-
expect(ngtscConstructorSpy.mock.calls[0][3]).toBeUndefined();
|
|
335
|
-
expect(result.affectedFiles).toBeInstanceOf(Set);
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
it("두번째 initialize()에서 이전 NgtscProgram이 oldProgram으로 전달된다", async () => {
|
|
339
|
-
const compiler = new AngularCompiler({
|
|
340
|
-
rootNames: ["src/main.ts"],
|
|
341
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
await compiler.initialize();
|
|
345
|
-
const firstProgram = compiler.ngtscProgram;
|
|
346
|
-
|
|
347
|
-
await compiler.initialize();
|
|
348
|
-
|
|
349
|
-
expect(ngtscConstructorSpy.mock.calls[1][3]).toBe(firstProgram);
|
|
350
|
-
});
|
|
351
|
-
|
|
352
|
-
it("transformStylesheet 콜백이 host.transformResource를 통해 호출된다", async () => {
|
|
353
|
-
const transformStylesheet = vi.fn().mockResolvedValue("body { color: red; }");
|
|
354
|
-
|
|
355
|
-
const compiler = new AngularCompiler({
|
|
356
|
-
rootNames: ["src/main.ts"],
|
|
357
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
358
|
-
transformStylesheet,
|
|
359
|
-
});
|
|
360
|
-
|
|
361
|
-
await compiler.initialize();
|
|
362
|
-
|
|
363
|
-
const hostArg = ngtscConstructorSpy.mock.calls[0][2] as Record<string, unknown>;
|
|
364
|
-
expect(typeof hostArg["transformResource"]).toBe("function");
|
|
365
|
-
|
|
366
|
-
const result = await (hostArg["transformResource"] as Function)(
|
|
367
|
-
".button { color: blue; }",
|
|
368
|
-
{ type: "style", containingFile: "/app/comp.ts", resourceFile: "/app/comp.scss" },
|
|
369
|
-
);
|
|
370
|
-
expect(transformStylesheet).toHaveBeenCalledWith(
|
|
371
|
-
".button { color: blue; }",
|
|
372
|
-
"/app/comp.ts",
|
|
373
|
-
"/app/comp.scss",
|
|
374
|
-
);
|
|
375
|
-
expect(result).toEqual({ content: "body { color: red; }" });
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
it("compilerOptionsTransformer가 NgtscProgram 생성에 사용된다", async () => {
|
|
379
|
-
const transformer = vi.fn((opts: ts.CompilerOptions) => ({
|
|
380
|
-
...opts,
|
|
381
|
-
noEmit: false,
|
|
382
|
-
declaration: false,
|
|
383
|
-
}));
|
|
384
|
-
|
|
385
|
-
const compiler = new AngularCompiler({
|
|
386
|
-
rootNames: ["src/main.ts"],
|
|
387
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext, noEmit: true },
|
|
388
|
-
compilerOptionsTransformer: transformer,
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
await compiler.initialize();
|
|
392
|
-
|
|
393
|
-
expect(transformer).toHaveBeenCalledTimes(1);
|
|
394
|
-
const passedOptions = ngtscConstructorSpy.mock.calls[0][1] as ts.CompilerOptions;
|
|
395
|
-
expect(passedOptions.noEmit).toBe(false);
|
|
396
|
-
expect(passedOptions.declaration).toBe(false);
|
|
397
|
-
});
|
|
398
|
-
|
|
399
|
-
it("host.resourceNameToFileName이 절대 경로를 반환한다", async () => {
|
|
400
|
-
const compiler = new AngularCompiler({
|
|
401
|
-
rootNames: ["src/main.ts"],
|
|
402
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
await compiler.initialize();
|
|
406
|
-
|
|
407
|
-
const hostArg = ngtscConstructorSpy.mock.calls[0][2] as Record<string, Function>;
|
|
408
|
-
expect(typeof hostArg["resourceNameToFileName"]).toBe("function");
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
it("compilerOptionsTransformer로 declaration: true 설정", async () => {
|
|
412
|
-
const compiler = new AngularCompiler({
|
|
413
|
-
rootNames: ["src/main.ts"],
|
|
414
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
415
|
-
compilerOptionsTransformer: (opts) => ({
|
|
416
|
-
...opts,
|
|
417
|
-
declaration: true,
|
|
418
|
-
declarationMap: true,
|
|
419
|
-
}),
|
|
420
|
-
});
|
|
421
|
-
|
|
422
|
-
await compiler.initialize();
|
|
423
|
-
|
|
424
|
-
const passedOptions = ngtscConstructorSpy.mock.calls[0][1] as ts.CompilerOptions;
|
|
425
|
-
expect(passedOptions.declaration).toBe(true);
|
|
426
|
-
expect(passedOptions.declarationMap).toBe(true);
|
|
427
|
-
});
|
|
428
|
-
|
|
429
|
-
it("compilerOptionsTransformer로 declaration: false 설정", async () => {
|
|
430
|
-
const compiler = new AngularCompiler({
|
|
431
|
-
rootNames: ["src/main.ts"],
|
|
432
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
433
|
-
compilerOptionsTransformer: (opts) => ({
|
|
434
|
-
...opts,
|
|
435
|
-
declaration: false,
|
|
436
|
-
}),
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
await compiler.initialize();
|
|
440
|
-
|
|
441
|
-
const passedOptions = ngtscConstructorSpy.mock.calls[0][1] as ts.CompilerOptions;
|
|
442
|
-
expect(passedOptions.declaration).toBe(false);
|
|
443
|
-
});
|
|
444
|
-
|
|
445
|
-
it("getTsProgram()으로 ts.Program을 반환한다", async () => {
|
|
446
|
-
const compiler = new AngularCompiler({
|
|
447
|
-
rootNames: ["src/main.ts"],
|
|
448
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
await compiler.initialize();
|
|
452
|
-
|
|
453
|
-
const program = compiler.getTsProgram();
|
|
454
|
-
expect(program).toBe(realProgram.program);
|
|
455
|
-
});
|
|
456
|
-
|
|
457
|
-
it("getTsProgram()의 결과가 ESLint parserOptions.programs에 주입 가능한 형태이다", async () => {
|
|
458
|
-
const compiler = new AngularCompiler({
|
|
459
|
-
rootNames: ["src/main.ts"],
|
|
460
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
461
|
-
});
|
|
462
|
-
|
|
463
|
-
await compiler.initialize();
|
|
464
|
-
|
|
465
|
-
const program = compiler.getTsProgram();
|
|
466
|
-
const parserOptions = { programs: [program], project: null };
|
|
467
|
-
expect(parserOptions.programs).toHaveLength(1);
|
|
468
|
-
expect(parserOptions.programs[0]).toBe(realProgram.program);
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
it("sourceFileCache 제공 시 augmentHostWithCaching이 적용된다", async () => {
|
|
472
|
-
const cache = new AngularSourceFileCache();
|
|
473
|
-
|
|
474
|
-
const compiler = new AngularCompiler({
|
|
475
|
-
rootNames: ["src/main.ts"],
|
|
476
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
477
|
-
sourceFileCache: cache,
|
|
478
|
-
});
|
|
479
|
-
|
|
480
|
-
const result = await compiler.initialize();
|
|
481
|
-
|
|
482
|
-
expect(result.affectedFiles).toBeInstanceOf(Set);
|
|
483
|
-
});
|
|
484
|
-
|
|
485
|
-
it("modifiedFiles에 node_modules 파일이 있으면 packageJsonCache가 clear된다", async () => {
|
|
486
|
-
const cache = new AngularSourceFileCache();
|
|
487
|
-
|
|
488
|
-
const compiler = new AngularCompiler({
|
|
489
|
-
rootNames: ["src/main.ts"],
|
|
490
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
491
|
-
sourceFileCache: cache,
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
await compiler.initialize();
|
|
495
|
-
|
|
496
|
-
cache.modifiedFiles.add("node_modules/some-pkg/index.js");
|
|
497
|
-
|
|
498
|
-
const result = await compiler.initialize();
|
|
499
|
-
|
|
500
|
-
expect(result.affectedFiles).toBeInstanceOf(Set);
|
|
501
|
-
});
|
|
502
|
-
|
|
503
|
-
it("modifiedFiles에 node_modules 파일이 없으면 packageJsonCache가 재사용된다", async () => {
|
|
504
|
-
const cache = new AngularSourceFileCache();
|
|
505
|
-
|
|
506
|
-
const compiler = new AngularCompiler({
|
|
507
|
-
rootNames: ["src/main.ts"],
|
|
508
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
509
|
-
sourceFileCache: cache,
|
|
510
|
-
});
|
|
511
|
-
|
|
512
|
-
await compiler.initialize();
|
|
513
|
-
|
|
514
|
-
cache.modifiedFiles.add("src/app/component.ts");
|
|
515
|
-
|
|
516
|
-
const result = await compiler.initialize();
|
|
517
|
-
|
|
518
|
-
expect(result.affectedFiles).toBeInstanceOf(Set);
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
// =============================================================================
|
|
523
|
-
// AngularCompiler — affected 파일
|
|
524
|
-
// =============================================================================
|
|
525
|
-
|
|
526
|
-
describe("AngularCompiler — affected 파일", () => {
|
|
527
|
-
it("initialize()가 BuilderProgram 기반으로 affected 파일을 반환한다", async () => {
|
|
528
|
-
const compiler = new AngularCompiler({
|
|
529
|
-
rootNames: realProgram.rootNames,
|
|
530
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
531
|
-
});
|
|
532
|
-
|
|
533
|
-
const result = await compiler.initialize();
|
|
534
|
-
expect(result.affectedFiles).toBeInstanceOf(Set);
|
|
535
|
-
});
|
|
536
|
-
|
|
537
|
-
it("리소스 변경 시 해당 .ts 파일이 affected에 추가된다", async () => {
|
|
538
|
-
const sourceFiles = realProgram.program.getSourceFiles();
|
|
539
|
-
const indexFile = sourceFiles.find((sf) => sf.fileName.includes("index.ts"));
|
|
540
|
-
const scssPath = path.join(realProgram.dir, "component.scss");
|
|
541
|
-
fs.writeFileSync(scssPath, ".x { }", "utf-8");
|
|
542
|
-
|
|
543
|
-
mockGetResourceDependencies.mockImplementation((sf: ts.SourceFile) => {
|
|
544
|
-
if (sf === indexFile) {
|
|
545
|
-
return [scssPath];
|
|
546
|
-
}
|
|
547
|
-
return [];
|
|
548
|
-
});
|
|
549
|
-
|
|
550
|
-
const cache = new AngularSourceFileCache();
|
|
551
|
-
cache.modifiedFiles.add(scssPath);
|
|
552
|
-
|
|
553
|
-
const compiler = new AngularCompiler({
|
|
554
|
-
rootNames: realProgram.rootNames,
|
|
555
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
556
|
-
sourceFileCache: cache,
|
|
557
|
-
});
|
|
558
|
-
|
|
559
|
-
const result = await compiler.initialize();
|
|
560
|
-
const affectedFileNames = [...result.affectedFiles].map((sf) => sf.fileName);
|
|
561
|
-
expect(affectedFileNames.some((f) => f.includes("index.ts"))).toBe(true);
|
|
562
|
-
});
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
// =============================================================================
|
|
566
|
-
// AngularCompiler — collectDiagnostics
|
|
567
|
-
// =============================================================================
|
|
568
|
-
|
|
569
|
-
describe("AngularCompiler — collectDiagnostics", () => {
|
|
570
|
-
it("collectDiagnostics가 Option, Syntactic, Semantic, Angular 진단을 수집한다", async () => {
|
|
571
|
-
const compiler = new AngularCompiler({
|
|
572
|
-
rootNames: realProgram.rootNames,
|
|
573
|
-
compilerOptions: {
|
|
574
|
-
target: ts.ScriptTarget.ESNext,
|
|
575
|
-
module: ts.ModuleKind.ESNext,
|
|
576
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
577
|
-
skipLibCheck: true,
|
|
578
|
-
types: [],
|
|
579
|
-
},
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
await compiler.initialize();
|
|
583
|
-
|
|
584
|
-
const diagnostics = [...compiler.collectDiagnostics()];
|
|
585
|
-
expect(Array.isArray(diagnostics)).toBe(true);
|
|
586
|
-
});
|
|
587
|
-
|
|
588
|
-
it("affected 파일의 Angular 진단은 getDiagnosticsForFile로 재계산된다", async () => {
|
|
589
|
-
const indexFile = realProgram.program.getSourceFiles()
|
|
590
|
-
.find((sf) => sf.fileName.includes("index.ts"));
|
|
591
|
-
const scssPath = path.join(realProgram.dir, "component.scss");
|
|
592
|
-
fs.writeFileSync(scssPath, ".x { }", "utf-8");
|
|
593
|
-
|
|
594
|
-
const mockDiag = {
|
|
595
|
-
category: ts.DiagnosticCategory.Error,
|
|
596
|
-
code: 1000,
|
|
597
|
-
messageText: "test error",
|
|
598
|
-
file: indexFile,
|
|
599
|
-
start: 0,
|
|
600
|
-
length: 5,
|
|
601
|
-
} as ts.Diagnostic;
|
|
602
|
-
mockGetDiagnosticsForFile.mockReturnValue([mockDiag]);
|
|
603
|
-
mockGetResourceDependencies.mockImplementation((sf: ts.SourceFile) => {
|
|
604
|
-
if (sf.fileName.includes("index.ts")) {
|
|
605
|
-
return [scssPath];
|
|
606
|
-
}
|
|
607
|
-
return [];
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
const cache = new AngularSourceFileCache();
|
|
611
|
-
cache.modifiedFiles.add(scssPath);
|
|
612
|
-
|
|
613
|
-
const compiler = new AngularCompiler({
|
|
614
|
-
rootNames: realProgram.rootNames,
|
|
615
|
-
compilerOptions: {
|
|
616
|
-
target: ts.ScriptTarget.ESNext,
|
|
617
|
-
module: ts.ModuleKind.ESNext,
|
|
618
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
619
|
-
skipLibCheck: true,
|
|
620
|
-
types: [],
|
|
621
|
-
},
|
|
622
|
-
sourceFileCache: cache,
|
|
623
|
-
});
|
|
624
|
-
|
|
625
|
-
await compiler.initialize();
|
|
626
|
-
|
|
627
|
-
const diagnostics = [...compiler.collectDiagnostics()];
|
|
628
|
-
expect(mockGetDiagnosticsForFile).toHaveBeenCalled();
|
|
629
|
-
expect(diagnostics.some((d) => d.code === 1000)).toBe(true);
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
it("non-affected 파일의 Angular 진단은 캐시에서 반환된다", async () => {
|
|
633
|
-
const mockDiag = {
|
|
634
|
-
category: ts.DiagnosticCategory.Warning,
|
|
635
|
-
code: 2000,
|
|
636
|
-
messageText: "cached warning",
|
|
637
|
-
} as ts.Diagnostic;
|
|
638
|
-
mockGetDiagnosticsForFile.mockReturnValue([mockDiag]);
|
|
639
|
-
|
|
640
|
-
const compiler = new AngularCompiler({
|
|
641
|
-
rootNames: realProgram.rootNames,
|
|
642
|
-
compilerOptions: {
|
|
643
|
-
target: ts.ScriptTarget.ESNext,
|
|
644
|
-
module: ts.ModuleKind.ESNext,
|
|
645
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
646
|
-
skipLibCheck: true,
|
|
647
|
-
types: [],
|
|
648
|
-
},
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
await compiler.initialize();
|
|
652
|
-
|
|
653
|
-
const diags1 = [...compiler.collectDiagnostics()];
|
|
654
|
-
const callCount1 = mockGetDiagnosticsForFile.mock.calls.length;
|
|
655
|
-
expect(callCount1).toBeGreaterThan(0);
|
|
656
|
-
expect(diags1.some((d) => d.code === 2000)).toBe(true);
|
|
657
|
-
|
|
658
|
-
mockGetDiagnosticsForFile.mockClear();
|
|
659
|
-
await compiler.initialize();
|
|
660
|
-
const diags2 = [...compiler.collectDiagnostics()];
|
|
661
|
-
expect(Array.isArray(diags2)).toBe(true);
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
it("리소스 변경 시 해당 .ts 파일의 diagnosticCache가 무효화된다", async () => {
|
|
665
|
-
const scssPath = path.join(realProgram.dir, "styles.scss");
|
|
666
|
-
fs.writeFileSync(scssPath, ".y { }", "utf-8");
|
|
667
|
-
|
|
668
|
-
const mockDiag = {
|
|
669
|
-
category: ts.DiagnosticCategory.Error,
|
|
670
|
-
code: 3000,
|
|
671
|
-
messageText: "resource error",
|
|
672
|
-
} as ts.Diagnostic;
|
|
673
|
-
mockGetDiagnosticsForFile.mockReturnValue([mockDiag]);
|
|
674
|
-
mockGetResourceDependencies.mockImplementation((sf: ts.SourceFile) => {
|
|
675
|
-
if (sf.fileName.includes("index.ts")) {
|
|
676
|
-
return [scssPath];
|
|
677
|
-
}
|
|
678
|
-
return [];
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
const cache = new AngularSourceFileCache();
|
|
682
|
-
|
|
683
|
-
const compiler = new AngularCompiler({
|
|
684
|
-
rootNames: realProgram.rootNames,
|
|
685
|
-
compilerOptions: {
|
|
686
|
-
target: ts.ScriptTarget.ESNext,
|
|
687
|
-
module: ts.ModuleKind.ESNext,
|
|
688
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
689
|
-
skipLibCheck: true,
|
|
690
|
-
types: [],
|
|
691
|
-
},
|
|
692
|
-
sourceFileCache: cache,
|
|
693
|
-
});
|
|
694
|
-
|
|
695
|
-
await compiler.initialize();
|
|
696
|
-
void [...compiler.collectDiagnostics()];
|
|
697
|
-
expect(mockGetDiagnosticsForFile).toHaveBeenCalled();
|
|
698
|
-
|
|
699
|
-
mockGetDiagnosticsForFile.mockClear();
|
|
700
|
-
cache.modifiedFiles.add(scssPath);
|
|
701
|
-
|
|
702
|
-
await compiler.initialize();
|
|
703
|
-
void [...compiler.collectDiagnostics()];
|
|
704
|
-
|
|
705
|
-
expect(mockGetDiagnosticsForFile).toHaveBeenCalled();
|
|
706
|
-
});
|
|
707
|
-
});
|