@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,351 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { createWorker, FsWatcher, pathx } from "@simplysm/core-node";
|
|
3
|
-
import { err as errNs } from "@simplysm/core-common";
|
|
4
|
-
import { setupWorkerLifecycle } from "./shared-worker-lifecycle";
|
|
5
|
-
import { buildWatchPaths } from "./build-watch-paths";
|
|
6
|
-
import { hasFileAddOrRemove, shouldSkipRebuild } from "./build-change-filter";
|
|
7
|
-
import {
|
|
8
|
-
buildCompilerOptions,
|
|
9
|
-
buildScssLoadPaths,
|
|
10
|
-
compileSideEffectScss,
|
|
11
|
-
compileGlobalScss,
|
|
12
|
-
type NgtscBuildInfo,
|
|
13
|
-
type NgtscBuildResult,
|
|
14
|
-
type NgtscCombinedBuildEvent,
|
|
15
|
-
type SideEffectScssEntry,
|
|
16
|
-
} from "../angular/ngtsc-build-core";
|
|
17
|
-
import { serializeDiagnostic } from "../typecheck/typecheck-serialization";
|
|
18
|
-
import { LintWithProgramRunner, type LintWithProgramResult } from "../lint/lint-with-program";
|
|
19
|
-
import {
|
|
20
|
-
parseTsconfig,
|
|
21
|
-
getPackageSourceFiles,
|
|
22
|
-
getPackageFiles,
|
|
23
|
-
getCompilerOptionsForEnv,
|
|
24
|
-
} from "../utils/tsconfig";
|
|
25
|
-
import { AngularBuildPipeline } from "../angular/angular-build-pipeline";
|
|
26
|
-
import { AngularSourceFileCache } from "../angular/angular-compiler";
|
|
27
|
-
|
|
28
|
-
//#region 타입 (워커 인터페이스용 re-export)
|
|
29
|
-
|
|
30
|
-
export type { NgtscBuildInfo, NgtscBuildResult, NgtscCombinedBuildEvent };
|
|
31
|
-
|
|
32
|
-
export interface NgtscBuildWorkerEvents extends Record<string, unknown> {
|
|
33
|
-
buildStart: Record<string, never>;
|
|
34
|
-
build: NgtscCombinedBuildEvent;
|
|
35
|
-
error: { message: string };
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
//#endregion
|
|
39
|
-
|
|
40
|
-
//#region Resource Management
|
|
41
|
-
|
|
42
|
-
let fsWatcher: FsWatcher | undefined;
|
|
43
|
-
|
|
44
|
-
async function cleanup(): Promise<void> {
|
|
45
|
-
const watcherToClose = fsWatcher;
|
|
46
|
-
fsWatcher = undefined;
|
|
47
|
-
_watchPipeline = undefined;
|
|
48
|
-
lastSourceFilePaths = undefined;
|
|
49
|
-
|
|
50
|
-
if (watcherToClose != null) {
|
|
51
|
-
await watcherToClose.close();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const { logger, guardStartWatch } = setupWorkerLifecycle("ngtsc-build", cleanup);
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
|
-
|
|
59
|
-
//#region build (one-time build)
|
|
60
|
-
|
|
61
|
-
async function build(info: NgtscBuildInfo): Promise<NgtscBuildResult> {
|
|
62
|
-
logger.debug(`[${info.name}] ngtsc worker build 시작 (pkgDir: ${info.pkgDir})`);
|
|
63
|
-
|
|
64
|
-
try {
|
|
65
|
-
const buildInfo = { ...info, env: info.output.env };
|
|
66
|
-
const parsedConfig = parseTsconfig(buildInfo.pkgDir);
|
|
67
|
-
const sourceFiles = buildInfo.output.includeTests === true
|
|
68
|
-
? getPackageFiles(buildInfo.pkgDir, parsedConfig)
|
|
69
|
-
: getPackageSourceFiles(buildInfo.pkgDir, parsedConfig);
|
|
70
|
-
const baseOptions =
|
|
71
|
-
buildInfo.env != null
|
|
72
|
-
? getCompilerOptionsForEnv(parsedConfig.options, buildInfo.env, buildInfo.pkgDir)
|
|
73
|
-
: parsedConfig.options;
|
|
74
|
-
const compilerOptions = buildCompilerOptions(baseOptions, buildInfo.pkgDir, buildInfo.output);
|
|
75
|
-
const angularOptions = (parsedConfig.raw?.angularCompilerOptions ?? {}) as Record<string, unknown>;
|
|
76
|
-
|
|
77
|
-
const pipeline = new AngularBuildPipeline({
|
|
78
|
-
mode: "library",
|
|
79
|
-
pkgDir: buildInfo.pkgDir,
|
|
80
|
-
cwd: buildInfo.cwd,
|
|
81
|
-
rootNames: sourceFiles,
|
|
82
|
-
compilerOptions,
|
|
83
|
-
angularCompilerOptions: angularOptions,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const pipelineResult = await pipeline.initialize();
|
|
87
|
-
|
|
88
|
-
// emit → 디스크 쓰기 (src/ 하위만)
|
|
89
|
-
const normalizedSrcDir = pathx.posix(path.join(buildInfo.pkgDir, "src"));
|
|
90
|
-
pipeline.writeEmitResults({
|
|
91
|
-
pkgDir: buildInfo.pkgDir,
|
|
92
|
-
sourceFilter: (fileName) => pathx.posix(fileName).startsWith(normalizedSrcDir + "/"),
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// global SCSS
|
|
96
|
-
const globalScssErrors = compileGlobalScss(buildInfo.pkgDir, buildScssLoadPaths(buildInfo));
|
|
97
|
-
|
|
98
|
-
// diagnostics 직렬화
|
|
99
|
-
const rawDiags = pipeline.collectRawDiagnostics();
|
|
100
|
-
const serialized = rawDiags.map(serializeDiagnostic);
|
|
101
|
-
const errors = pipelineResult.diagnostics.errors.map((e) => e.message);
|
|
102
|
-
const allErrors = [...errors, ...pipelineResult.scssErrors, ...globalScssErrors];
|
|
103
|
-
|
|
104
|
-
const result: NgtscBuildResult = {
|
|
105
|
-
build: {
|
|
106
|
-
success: pipelineResult.diagnostics.errors.length === 0
|
|
107
|
-
&& pipelineResult.scssErrors.length === 0
|
|
108
|
-
&& globalScssErrors.length === 0,
|
|
109
|
-
errors: allErrors.length > 0 ? allErrors : undefined,
|
|
110
|
-
diagnostics: serialized,
|
|
111
|
-
},
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
// lint
|
|
115
|
-
if (info.output.lint === true) {
|
|
116
|
-
logger.debug(`[${info.name}] lint 시작`);
|
|
117
|
-
const lintRunner = new LintWithProgramRunner({
|
|
118
|
-
cwd: info.cwd,
|
|
119
|
-
pkgName: info.name,
|
|
120
|
-
});
|
|
121
|
-
result.lint = await lintRunner.lint({ program: pipeline.getTsProgram() });
|
|
122
|
-
logger.debug(`[${info.name}] lint 완료`);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
logger.debug(`[${info.name}] ngtsc worker build 완료 (build.success: ${result.build.success})`);
|
|
126
|
-
return result;
|
|
127
|
-
} catch (err) {
|
|
128
|
-
const message = errNs.message(err);
|
|
129
|
-
logger.debug(`[${info.name}] ngtsc worker build 예외 발생: ${message}`);
|
|
130
|
-
return {
|
|
131
|
-
build: { success: false, errors: [message], diagnostics: [] },
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
//#endregion
|
|
137
|
-
|
|
138
|
-
//#region startWatch (watch mode)
|
|
139
|
-
|
|
140
|
-
let watchInfo: NgtscBuildInfo | undefined;
|
|
141
|
-
let _watchPipeline: AngularBuildPipeline | undefined;
|
|
142
|
-
let watchLintRunner: LintWithProgramRunner | undefined;
|
|
143
|
-
let lastSourceFilePaths: Set<string> | undefined;
|
|
144
|
-
const sideEffectScssRegistry = new Map<string, SideEffectScssEntry>();
|
|
145
|
-
|
|
146
|
-
function extractSourceFilePaths(program: { getSourceFiles(): readonly { fileName: string }[] }): Set<string> {
|
|
147
|
-
const paths = new Set<string>();
|
|
148
|
-
for (const sf of program.getSourceFiles()) {
|
|
149
|
-
paths.add(pathx.posix(sf.fileName));
|
|
150
|
-
}
|
|
151
|
-
return paths;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Pipeline 빌드 결과 + side-effect/global SCSS를 통합하여 NgtscCombinedBuildEvent를 생성한다.
|
|
156
|
-
*/
|
|
157
|
-
async function buildWatchEvent(
|
|
158
|
-
info: NgtscBuildInfo,
|
|
159
|
-
pipeline: AngularBuildPipeline,
|
|
160
|
-
loadPaths: string[],
|
|
161
|
-
hasScssChanges: boolean,
|
|
162
|
-
affectedFileNames?: ReadonlySet<string>,
|
|
163
|
-
): Promise<NgtscCombinedBuildEvent> {
|
|
164
|
-
logger.debug(`[${info.name}] buildWatchEvent 시작`);
|
|
165
|
-
const normalizedSrcDir = pathx.posix(path.join(info.pkgDir, "src"));
|
|
166
|
-
|
|
167
|
-
// Pipeline의 SCSS 의존성 맵을 공유하여 역방향 탐색 통합
|
|
168
|
-
const scssDepsMap = pipeline.getScssDependencies();
|
|
169
|
-
const sideEffectScssErrors: string[] = [];
|
|
170
|
-
|
|
171
|
-
// emit → 디스크 쓰기 (src/ 하위만)
|
|
172
|
-
pipeline.writeEmitResults({
|
|
173
|
-
pkgDir: info.pkgDir,
|
|
174
|
-
sourceFilter: (fileName) => pathx.posix(fileName).startsWith(normalizedSrcDir + "/"),
|
|
175
|
-
scss: {
|
|
176
|
-
loadPaths,
|
|
177
|
-
scssErrors: sideEffectScssErrors,
|
|
178
|
-
scssDependencies: scssDepsMap,
|
|
179
|
-
registry: sideEffectScssRegistry,
|
|
180
|
-
},
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
// side-effect SCSS 컴파일 (.scss/.css 변경 시에만)
|
|
184
|
-
if (hasScssChanges) {
|
|
185
|
-
compileSideEffectScss(sideEffectScssRegistry, loadPaths, sideEffectScssErrors, scssDepsMap);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// global SCSS 컴파일
|
|
189
|
-
const globalScssErrors = compileGlobalScss(info.pkgDir, loadPaths);
|
|
190
|
-
|
|
191
|
-
const diagnostics = pipeline.getDiagnostics();
|
|
192
|
-
const pipelineScssErrors = pipeline.getScssErrors();
|
|
193
|
-
const errors = diagnostics.errors.map((e) => e.message);
|
|
194
|
-
const allErrors = [...errors, ...pipelineScssErrors, ...sideEffectScssErrors, ...globalScssErrors];
|
|
195
|
-
|
|
196
|
-
// lint 실행 (활성화 시)
|
|
197
|
-
let lint: LintWithProgramResult | undefined;
|
|
198
|
-
if (info.output.lint === true) {
|
|
199
|
-
logger.debug(`[${info.name}] lint 시작`);
|
|
200
|
-
if (watchLintRunner == null) {
|
|
201
|
-
watchLintRunner = new LintWithProgramRunner({
|
|
202
|
-
cwd: info.cwd,
|
|
203
|
-
pkgName: info.name,
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
lint = await watchLintRunner.lint({
|
|
207
|
-
program: pipeline.getTsProgram(),
|
|
208
|
-
affectedFiles: affectedFileNames,
|
|
209
|
-
});
|
|
210
|
-
logger.debug(`[${info.name}] lint 완료`);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
logger.debug(`[${info.name}] buildWatchEvent 완료`);
|
|
214
|
-
return {
|
|
215
|
-
build: {
|
|
216
|
-
success: diagnostics.errors.length === 0
|
|
217
|
-
&& pipelineScssErrors.length === 0
|
|
218
|
-
&& sideEffectScssErrors.length === 0
|
|
219
|
-
&& globalScssErrors.length === 0,
|
|
220
|
-
errors: allErrors.length > 0 ? allErrors : undefined,
|
|
221
|
-
},
|
|
222
|
-
lint,
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
async function startWatch(info: NgtscBuildInfo): Promise<void> {
|
|
227
|
-
guardStartWatch();
|
|
228
|
-
watchInfo = { ...info, env: info.output.env };
|
|
229
|
-
|
|
230
|
-
try {
|
|
231
|
-
// tsconfig 파싱 및 컴파일러 옵션 준비
|
|
232
|
-
const parsedConfig = parseTsconfig(watchInfo.pkgDir);
|
|
233
|
-
const sourceFiles = watchInfo.output.includeTests === true
|
|
234
|
-
? getPackageFiles(watchInfo.pkgDir, parsedConfig)
|
|
235
|
-
: getPackageSourceFiles(watchInfo.pkgDir, parsedConfig);
|
|
236
|
-
const baseOptions =
|
|
237
|
-
watchInfo.env != null
|
|
238
|
-
? getCompilerOptionsForEnv(parsedConfig.options, watchInfo.env, watchInfo.pkgDir)
|
|
239
|
-
: parsedConfig.options;
|
|
240
|
-
const compilerOptions = buildCompilerOptions(baseOptions, watchInfo.pkgDir, watchInfo.output);
|
|
241
|
-
const angularOptions = (parsedConfig.raw?.angularCompilerOptions ?? {}) as Record<string, unknown>;
|
|
242
|
-
const loadPaths = buildScssLoadPaths(watchInfo);
|
|
243
|
-
|
|
244
|
-
// Pipeline 생성 + 초기 빌드
|
|
245
|
-
const sourceFileCache = new AngularSourceFileCache();
|
|
246
|
-
const pipeline = new AngularBuildPipeline({
|
|
247
|
-
mode: "library",
|
|
248
|
-
pkgDir: watchInfo.pkgDir,
|
|
249
|
-
cwd: watchInfo.cwd,
|
|
250
|
-
rootNames: sourceFiles,
|
|
251
|
-
compilerOptions,
|
|
252
|
-
angularCompilerOptions: angularOptions,
|
|
253
|
-
sourceFileCache,
|
|
254
|
-
});
|
|
255
|
-
_watchPipeline = pipeline;
|
|
256
|
-
|
|
257
|
-
await pipeline.initialize();
|
|
258
|
-
lastSourceFilePaths = extractSourceFilePaths(pipeline.getTsProgram());
|
|
259
|
-
const initialResult = await buildWatchEvent(watchInfo, pipeline, loadPaths, true);
|
|
260
|
-
sender.send("build", initialResult);
|
|
261
|
-
|
|
262
|
-
// workspace 의존성 경로 + replaceDeps 수집
|
|
263
|
-
const { watchPaths } = buildWatchPaths({
|
|
264
|
-
pkgDir: watchInfo.pkgDir,
|
|
265
|
-
cwd: watchInfo.cwd,
|
|
266
|
-
srcGlobs: ["*.{ts,scss,css}"],
|
|
267
|
-
extraDirs: [{ dir: "scss", globs: ["*.{scss,css}"] }],
|
|
268
|
-
replaceDeps: watchInfo.replaceDeps,
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
// FsWatcher 시작
|
|
272
|
-
logger.debug(`[${watchInfo.name}] FsWatcher 시작`);
|
|
273
|
-
fsWatcher = await FsWatcher.watch(watchPaths);
|
|
274
|
-
|
|
275
|
-
fsWatcher.onChange({ delay: 300 }, async (changedFiles) => {
|
|
276
|
-
try {
|
|
277
|
-
const addOrRemove = hasFileAddOrRemove(changedFiles);
|
|
278
|
-
|
|
279
|
-
// 변경된 파일 수집 (전체 변경 + SCSS 의존성 역방향 탐색)
|
|
280
|
-
const modifiedFiles = new Set<string>();
|
|
281
|
-
for (const f of changedFiles) {
|
|
282
|
-
modifiedFiles.add(f.path);
|
|
283
|
-
|
|
284
|
-
// Pipeline의 SCSS 역방향 탐색
|
|
285
|
-
if (f.path.endsWith(".scss") || f.path.endsWith(".css")) {
|
|
286
|
-
for (const affected of pipeline.findAffectedByScss(f.path)) {
|
|
287
|
-
modifiedFiles.add(affected);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// 의존성 필터: 관련 변경이 없으면 리빌드 건너뜀
|
|
293
|
-
if (shouldSkipRebuild(modifiedFiles, addOrRemove, lastSourceFilePaths, logger)) {
|
|
294
|
-
return;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
sender.send("buildStart", {});
|
|
298
|
-
|
|
299
|
-
// 파일 추가/삭제 시 rootNames 재스캔
|
|
300
|
-
if (addOrRemove) {
|
|
301
|
-
const newParsedConfig = parseTsconfig(watchInfo!.pkgDir);
|
|
302
|
-
const newSourceFiles = watchInfo!.output.includeTests === true
|
|
303
|
-
? getPackageFiles(watchInfo!.pkgDir, newParsedConfig)
|
|
304
|
-
: getPackageSourceFiles(watchInfo!.pkgDir, newParsedConfig);
|
|
305
|
-
pipeline.updateRootNames(newSourceFiles);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Pipeline 증분 업데이트 (SCSS 의존성 초기화 포함)
|
|
309
|
-
pipeline.clearScssDependencies();
|
|
310
|
-
const updateResult = await pipeline.update(modifiedFiles);
|
|
311
|
-
|
|
312
|
-
// 리빌드 후 소스 파일 경로 업데이트
|
|
313
|
-
lastSourceFilePaths = extractSourceFilePaths(pipeline.getTsProgram());
|
|
314
|
-
|
|
315
|
-
// 증분 lint를 위해 영향받은 ts.SourceFile 집합을 파일명 문자열로 변환
|
|
316
|
-
const affectedFileNames = new Set<string>();
|
|
317
|
-
for (const sf of updateResult.affectedFiles) {
|
|
318
|
-
affectedFileNames.add(pathx.posix(sf.fileName));
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
const hasScssChanges = changedFiles.some(
|
|
322
|
-
(f) => f.path.endsWith(".scss") || f.path.endsWith(".css"),
|
|
323
|
-
);
|
|
324
|
-
|
|
325
|
-
const result = await buildWatchEvent(watchInfo!, pipeline, loadPaths, hasScssChanges, affectedFileNames);
|
|
326
|
-
sender.send("build", result);
|
|
327
|
-
} catch (err) {
|
|
328
|
-
sender.send("error", { message: errNs.message(err) });
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
} catch (err) {
|
|
332
|
-
sender.send("error", { message: errNs.message(err) });
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
async function stopWatch(): Promise<void> {
|
|
337
|
-
await cleanup();
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
//#endregion
|
|
341
|
-
|
|
342
|
-
const sender = createWorker<
|
|
343
|
-
{ build: typeof build; startWatch: typeof startWatch; stopWatch: typeof stopWatch },
|
|
344
|
-
NgtscBuildWorkerEvents
|
|
345
|
-
>({
|
|
346
|
-
build,
|
|
347
|
-
startWatch,
|
|
348
|
-
stopWatch,
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
export default sender;
|
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import fs from "node:fs";
|
|
4
|
-
import ts from "typescript";
|
|
5
|
-
import { AngularBuildPipeline } from "../../src/angular/angular-build-pipeline.js";
|
|
6
|
-
import { AngularSourceFileCache } from "../../src/angular/angular-compiler.js";
|
|
7
|
-
import { getPackageSourceFiles } from "../../src/utils/tsconfig.js";
|
|
8
|
-
|
|
9
|
-
const FIXTURE_DIR = path.resolve(import.meta.dirname, "fixtures/packages/basic-app");
|
|
10
|
-
const TSCONFIG_PATH = path.join(FIXTURE_DIR, "tsconfig.json");
|
|
11
|
-
|
|
12
|
-
function parseFixtureConfig() {
|
|
13
|
-
const configFile = ts.readConfigFile(TSCONFIG_PATH, ts.sys.readFile);
|
|
14
|
-
return ts.parseJsonConfigFileContent(configFile.config, ts.sys, FIXTURE_DIR);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function createPipelineOptions(
|
|
18
|
-
mode: "client" | "library",
|
|
19
|
-
overrides?: Partial<ConstructorParameters<typeof AngularBuildPipeline>[0]>,
|
|
20
|
-
) {
|
|
21
|
-
const parsed = parseFixtureConfig();
|
|
22
|
-
const rootNames = getPackageSourceFiles(FIXTURE_DIR, parsed);
|
|
23
|
-
return {
|
|
24
|
-
mode,
|
|
25
|
-
pkgDir: FIXTURE_DIR,
|
|
26
|
-
cwd: FIXTURE_DIR,
|
|
27
|
-
rootNames,
|
|
28
|
-
compilerOptions: {
|
|
29
|
-
...parsed.options,
|
|
30
|
-
noEmit: false,
|
|
31
|
-
declaration: false,
|
|
32
|
-
declarationMap: false,
|
|
33
|
-
},
|
|
34
|
-
angularCompilerOptions: parsed.raw?.angularCompilerOptions as
|
|
35
|
-
| Record<string, unknown>
|
|
36
|
-
| undefined,
|
|
37
|
-
...overrides,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
describe("AngularBuildPipeline", () => {
|
|
42
|
-
// --- client mode ---
|
|
43
|
-
|
|
44
|
-
it("client mode: initializes, emits compiled JS, tracks SCSS deps, and collects diagnostics", async () => {
|
|
45
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("client"));
|
|
46
|
-
const result = await pipeline.initialize();
|
|
47
|
-
|
|
48
|
-
// emitted file for known component
|
|
49
|
-
const appComponentPath = path
|
|
50
|
-
.join(FIXTURE_DIR, "src/app.component.ts")
|
|
51
|
-
.replace(/\\/g, "/");
|
|
52
|
-
const emitted = pipeline.getEmittedFile(appComponentPath);
|
|
53
|
-
expect(emitted).toBeDefined();
|
|
54
|
-
expect(emitted!.length).toBeGreaterThan(0);
|
|
55
|
-
|
|
56
|
-
// unknown path returns undefined
|
|
57
|
-
expect(pipeline.getEmittedFile("/nonexistent.ts")).toBeUndefined();
|
|
58
|
-
|
|
59
|
-
// SCSS dependencies tracked for styled component
|
|
60
|
-
const styledPath = path
|
|
61
|
-
.join(FIXTURE_DIR, "src/styled.component.ts")
|
|
62
|
-
.replace(/\\/g, "/");
|
|
63
|
-
const styledEmitted = pipeline.getEmittedFile(styledPath);
|
|
64
|
-
expect(styledEmitted).toBeDefined();
|
|
65
|
-
|
|
66
|
-
// diagnostics categorized (no errors expected for valid fixture)
|
|
67
|
-
expect(result.diagnostics.errors).toHaveLength(0);
|
|
68
|
-
expect(Array.isArray(result.diagnostics.warnings)).toBe(true);
|
|
69
|
-
expect(result.scssErrors).toHaveLength(0);
|
|
70
|
-
|
|
71
|
-
// emittedFiles map should contain all source files
|
|
72
|
-
expect(pipeline.getEmittedFiles().size).toBeGreaterThan(0);
|
|
73
|
-
|
|
74
|
-
// getTsProgram should return a valid program
|
|
75
|
-
const program = pipeline.getTsProgram();
|
|
76
|
-
expect(program).toBeDefined();
|
|
77
|
-
expect(program.getSourceFiles().length).toBeGreaterThan(0);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// --- library mode ---
|
|
81
|
-
|
|
82
|
-
it("library mode: initializes with sync SCSS and emits files", async () => {
|
|
83
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("library"));
|
|
84
|
-
const result = await pipeline.initialize();
|
|
85
|
-
|
|
86
|
-
expect(result.diagnostics.errors).toHaveLength(0);
|
|
87
|
-
expect(result.scssErrors).toHaveLength(0);
|
|
88
|
-
expect(pipeline.getEmittedFiles().size).toBeGreaterThan(0);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// --- getTsProgram ---
|
|
92
|
-
|
|
93
|
-
it("getTsProgram throws if called before initialize", () => {
|
|
94
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("client"));
|
|
95
|
-
expect(() => pipeline.getTsProgram()).toThrow();
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
// --- collectRawDiagnostics ---
|
|
99
|
-
|
|
100
|
-
it("collectRawDiagnostics returns ts.Diagnostic array filtered by workspace", async () => {
|
|
101
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("library"));
|
|
102
|
-
await pipeline.initialize();
|
|
103
|
-
|
|
104
|
-
const rawDiags = pipeline.collectRawDiagnostics();
|
|
105
|
-
expect(Array.isArray(rawDiags)).toBe(true);
|
|
106
|
-
for (const d of rawDiags) {
|
|
107
|
-
expect(d).toHaveProperty("category");
|
|
108
|
-
expect(d).toHaveProperty("messageText");
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("collectRawDiagnostics throws if called before initialize", () => {
|
|
113
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("client"));
|
|
114
|
-
expect(() => pipeline.collectRawDiagnostics()).toThrow();
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
// --- writeEmitResults ---
|
|
118
|
-
|
|
119
|
-
it("writeEmitResults writes emitted files to disk without error", async () => {
|
|
120
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("library"));
|
|
121
|
-
await pipeline.initialize();
|
|
122
|
-
|
|
123
|
-
expect(() => pipeline.writeEmitResults({ pkgDir: FIXTURE_DIR })).not.toThrow();
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
// --- findAffectedByScss ---
|
|
127
|
-
|
|
128
|
-
it("findAffectedByScss returns owner files for a dependency SCSS", async () => {
|
|
129
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("client"));
|
|
130
|
-
await pipeline.initialize();
|
|
131
|
-
|
|
132
|
-
const variablesPath = path
|
|
133
|
-
.join(FIXTURE_DIR, "scss/_variables.scss")
|
|
134
|
-
.replace(/\\/g, "/");
|
|
135
|
-
const affectedByVariables = pipeline.findAffectedByScss(variablesPath);
|
|
136
|
-
expect(affectedByVariables.length).toBeGreaterThan(0);
|
|
137
|
-
|
|
138
|
-
// clearScssDependencies should empty the map
|
|
139
|
-
pipeline.clearScssDependencies();
|
|
140
|
-
expect(pipeline.findAffectedByScss(variablesPath)).toHaveLength(0);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it("findAffectedByScss returns empty array when no deps match", async () => {
|
|
144
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("client"));
|
|
145
|
-
await pipeline.initialize();
|
|
146
|
-
|
|
147
|
-
expect(pipeline.findAffectedByScss("/nonexistent.scss")).toHaveLength(0);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
// --- update ---
|
|
151
|
-
|
|
152
|
-
it("update throws if called before initialize", async () => {
|
|
153
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("client"));
|
|
154
|
-
await expect(pipeline.update([])).rejects.toThrow();
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it("update re-compiles changed files incrementally", async () => {
|
|
158
|
-
const pipeline = new AngularBuildPipeline(
|
|
159
|
-
createPipelineOptions("client", { sourceFileCache: new AngularSourceFileCache() }),
|
|
160
|
-
);
|
|
161
|
-
await pipeline.initialize();
|
|
162
|
-
|
|
163
|
-
const appPath = path.join(FIXTURE_DIR, "src/app.component.ts").replace(/\\/g, "/");
|
|
164
|
-
const beforeUpdate = pipeline.getEmittedFile(appPath);
|
|
165
|
-
expect(beforeUpdate).toBeDefined();
|
|
166
|
-
|
|
167
|
-
const updateResult = await pipeline.update([appPath]);
|
|
168
|
-
expect(updateResult.diagnostics.errors).toHaveLength(0);
|
|
169
|
-
expect(pipeline.getEmittedFile(appPath)).toBeDefined();
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// --- updateRootNames ---
|
|
173
|
-
|
|
174
|
-
// Acceptance: Scenario "updateRootNames 호출 시 compiler까지 전파"
|
|
175
|
-
it("updateRootNames로 새 파일 추가 후 update가 성공하고 새 파일이 emit된다", async () => {
|
|
176
|
-
const pipeline = new AngularBuildPipeline(
|
|
177
|
-
createPipelineOptions("library", { sourceFileCache: new AngularSourceFileCache() }),
|
|
178
|
-
);
|
|
179
|
-
await pipeline.initialize();
|
|
180
|
-
|
|
181
|
-
const tempPath = path.join(FIXTURE_DIR, "src/temp-update-root-names-test.ts");
|
|
182
|
-
fs.writeFileSync(tempPath, "export const tempRootNamesValue = 42;", "utf-8");
|
|
183
|
-
|
|
184
|
-
try {
|
|
185
|
-
const parsed = parseFixtureConfig();
|
|
186
|
-
const newRootNames = getPackageSourceFiles(FIXTURE_DIR, parsed);
|
|
187
|
-
pipeline.updateRootNames(newRootNames);
|
|
188
|
-
|
|
189
|
-
const result = await pipeline.update([tempPath]);
|
|
190
|
-
expect(result.diagnostics.errors).toHaveLength(0);
|
|
191
|
-
expect(pipeline.getEmittedFile(tempPath.replace(/\\/g, "/"))).toBeDefined();
|
|
192
|
-
} finally {
|
|
193
|
-
fs.unlinkSync(tempPath);
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
// Acceptance: Scenario "기존 소스 파일 삭제 시 rootNames에서 제거"
|
|
198
|
-
it("updateRootNames로 파일 제거 후 update에서 해당 파일이 프로그램에서 제외된다", async () => {
|
|
199
|
-
const tempPath = path.join(FIXTURE_DIR, "src/temp-to-remove.ts");
|
|
200
|
-
fs.writeFileSync(tempPath, "export const toRemove = 1;", "utf-8");
|
|
201
|
-
|
|
202
|
-
try {
|
|
203
|
-
const sourceFileCache = new AngularSourceFileCache();
|
|
204
|
-
const pipeline = new AngularBuildPipeline(
|
|
205
|
-
createPipelineOptions("library", { sourceFileCache }),
|
|
206
|
-
);
|
|
207
|
-
await pipeline.initialize();
|
|
208
|
-
|
|
209
|
-
// 파일이 초기 프로그램에 포함되어 있는지 확인
|
|
210
|
-
const initialFiles = pipeline.getTsProgram().getSourceFiles().map((sf) => sf.fileName.replace(/\\/g, "/"));
|
|
211
|
-
expect(initialFiles.some((f) => f.includes("temp-to-remove.ts"))).toBe(true);
|
|
212
|
-
|
|
213
|
-
// 파일 삭제 시뮬레이션: 디스크에서 삭제 후 rootNames 재스캔
|
|
214
|
-
fs.unlinkSync(tempPath);
|
|
215
|
-
const parsed = parseFixtureConfig();
|
|
216
|
-
const newRootNames = getPackageSourceFiles(FIXTURE_DIR, parsed);
|
|
217
|
-
pipeline.updateRootNames(newRootNames);
|
|
218
|
-
|
|
219
|
-
const result = await pipeline.update([tempPath]);
|
|
220
|
-
expect(result.diagnostics.errors).toHaveLength(0);
|
|
221
|
-
|
|
222
|
-
// 삭제된 파일이 프로그램에서 제외되었는지 확인
|
|
223
|
-
const updatedFiles = pipeline.getTsProgram().getSourceFiles().map((sf) => sf.fileName.replace(/\\/g, "/"));
|
|
224
|
-
expect(updatedFiles.some((f) => f.includes("temp-to-remove.ts"))).toBe(false);
|
|
225
|
-
} finally {
|
|
226
|
-
if (fs.existsSync(tempPath)) {
|
|
227
|
-
fs.unlinkSync(tempPath);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it("updateRootNames가 compiler 미초기화 상태에서도 에러 없이 동작한다", () => {
|
|
233
|
-
const pipeline = new AngularBuildPipeline(createPipelineOptions("library"));
|
|
234
|
-
expect(() => pipeline.updateRootNames(["src/new.ts"])).not.toThrow();
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
// --- getPackageSourceFiles ---
|
|
238
|
-
|
|
239
|
-
it("getPackageSourceFiles includes fixture files by default", () => {
|
|
240
|
-
const parsed = parseFixtureConfig();
|
|
241
|
-
const files = getPackageSourceFiles(FIXTURE_DIR, parsed);
|
|
242
|
-
const fixtureFiles = files.filter((f) => f.includes(".fixture."));
|
|
243
|
-
expect(fixtureFiles.length).toBeGreaterThan(0);
|
|
244
|
-
const srcFiles = files.filter((f) => f.includes("/src/"));
|
|
245
|
-
expect(srcFiles.length).toBeGreaterThan(0);
|
|
246
|
-
});
|
|
247
|
-
});
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, afterEach } from "vitest";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import ts from "typescript";
|
|
4
|
-
import { AngularCompiler, AngularSourceFileCache } from "../../src/angular/angular-compiler.js";
|
|
5
|
-
|
|
6
|
-
const FIXTURE_DIR = path.resolve(import.meta.dirname, "fixtures/packages/basic-app");
|
|
7
|
-
const TSCONFIG_PATH = path.join(FIXTURE_DIR, "tsconfig.json");
|
|
8
|
-
const APP_COMPONENT_PATH = path.join(FIXTURE_DIR, "src/app.component.ts").replace(/\\/g, "/");
|
|
9
|
-
|
|
10
|
-
function loadTsConfig(): { rootNames: string[]; compilerOptions: ts.CompilerOptions } {
|
|
11
|
-
const configFile = ts.readConfigFile(TSCONFIG_PATH, ts.sys.readFile);
|
|
12
|
-
const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, FIXTURE_DIR);
|
|
13
|
-
return { rootNames: parsed.fileNames, compilerOptions: parsed.options };
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
describe("AngularCompiler AOT (HMR dead code 제거 후)", () => {
|
|
17
|
-
let compiler: AngularCompiler | undefined;
|
|
18
|
-
|
|
19
|
-
afterEach(() => {
|
|
20
|
-
compiler = undefined;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
// Scenario: initialize() 반환에 templateUpdates가 없음
|
|
24
|
-
// Scenario: enableHmr 없이 pipeline.initialize()를 호출하면 AOT 컴파일이 정상 완료된다
|
|
25
|
-
it("initialize returns affectedFiles without templateUpdates", async () => {
|
|
26
|
-
const { rootNames, compilerOptions } = loadTsConfig();
|
|
27
|
-
|
|
28
|
-
compiler = new AngularCompiler({
|
|
29
|
-
rootNames,
|
|
30
|
-
compilerOptions,
|
|
31
|
-
compilerOptionsTransformer: (opts) => ({ ...opts, noEmit: false, declaration: false }),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
const result = await compiler.initialize();
|
|
35
|
-
|
|
36
|
-
// affectedFiles가 반환된다
|
|
37
|
-
expect(result.affectedFiles).toBeDefined();
|
|
38
|
-
expect(result.affectedFiles.size).toBeGreaterThan(0);
|
|
39
|
-
|
|
40
|
-
// templateUpdates가 반환 객체에 존재하지 않는다
|
|
41
|
-
expect("templateUpdates" in result).toBe(false);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
// Scenario: update() 반환에 templateUpdates가 없음
|
|
45
|
-
// Scenario: 증분 재컴파일 정상 동작
|
|
46
|
-
it("update returns affectedFiles without templateUpdates", async () => {
|
|
47
|
-
const { rootNames, compilerOptions } = loadTsConfig();
|
|
48
|
-
const sourceFileCache = new AngularSourceFileCache();
|
|
49
|
-
|
|
50
|
-
compiler = new AngularCompiler({
|
|
51
|
-
rootNames,
|
|
52
|
-
compilerOptions,
|
|
53
|
-
sourceFileCache,
|
|
54
|
-
compilerOptionsTransformer: (opts) => ({ ...opts, noEmit: false, declaration: false }),
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
await compiler.initialize();
|
|
58
|
-
|
|
59
|
-
// 파일 변경 후 update() 호출
|
|
60
|
-
const updateResult = await compiler.update([APP_COMPONENT_PATH]);
|
|
61
|
-
|
|
62
|
-
// affectedFiles가 반환된다
|
|
63
|
-
expect(updateResult.affectedFiles).toBeDefined();
|
|
64
|
-
|
|
65
|
-
// templateUpdates가 반환 객체에 존재하지 않는다
|
|
66
|
-
expect("templateUpdates" in updateResult).toBe(false);
|
|
67
|
-
});
|
|
68
|
-
});
|