@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
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import type { SideEffectScssEntry, SideEffectScssOptions } from "../../src/angular/ngtsc-build-core";
|
|
4
|
+
|
|
5
|
+
// Mock fs — filesystem I/O (OS 의존)
|
|
6
|
+
vi.mock("fs", () => ({
|
|
7
|
+
default: {
|
|
8
|
+
mkdirSync: vi.fn(),
|
|
9
|
+
writeFileSync: vi.fn(),
|
|
10
|
+
existsSync: vi.fn(() => false),
|
|
11
|
+
},
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
// Mock scss-compiler — dart-sass 외부 의존성
|
|
15
|
+
const mockCompileScssFile = vi.fn<(filePath: string, loadPaths: string[]) => { css: string; dependencies: string[] }>()
|
|
16
|
+
.mockReturnValue({ css: "/* compiled */", dependencies: [] });
|
|
17
|
+
|
|
18
|
+
vi.mock("../../src/angular/scss-compiler", () => ({
|
|
19
|
+
compileScssFile: (filePath: string, loadPaths: string[]) => mockCompileScssFile(filePath, loadPaths),
|
|
20
|
+
compileScssString: vi.fn(() => ({ css: "", dependencies: [] })),
|
|
21
|
+
}));
|
|
22
|
+
|
|
23
|
+
const { writeEmitResults, compileSideEffectScss } = await import("../../src/angular/ngtsc-build-core");
|
|
24
|
+
|
|
25
|
+
beforeEach(() => {
|
|
26
|
+
vi.clearAllMocks();
|
|
27
|
+
mockCompileScssFile.mockReturnValue({ css: "/* compiled */", dependencies: [] as string[] });
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("writeEmitResults — registryReverseIndex", () => {
|
|
31
|
+
// 테스트용 경로 헬퍼
|
|
32
|
+
const pkgDir = path.resolve("/test-pkg");
|
|
33
|
+
const srcFile = path.resolve(pkgDir, "src", "comp.ts");
|
|
34
|
+
const distDir = path.resolve(pkgDir, "dist");
|
|
35
|
+
|
|
36
|
+
function makeEmitResult(jsContent: string, sourceFileName?: string) {
|
|
37
|
+
// createOutputPathRewriter는 dist/ 하위 파일만 처리하므로 dist/ 경로로 생성
|
|
38
|
+
return {
|
|
39
|
+
filename: path.resolve(distDir, "comp.js"),
|
|
40
|
+
contents: jsContent,
|
|
41
|
+
sourceFileName,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Acceptance: registryReverseIndex가 제공되면 O(1) 삭제를 수행한다
|
|
46
|
+
it("deletes registry entries using reverseIndex and cleans up reverseIndex", () => {
|
|
47
|
+
const oldScssPath = path.resolve(pkgDir, "src", "old.scss");
|
|
48
|
+
const registry = new Map<string, SideEffectScssEntry>([
|
|
49
|
+
[oldScssPath, { scssAbsPath: oldScssPath, cssAbsPath: "/out/old.css", sourceFileName: srcFile }],
|
|
50
|
+
]);
|
|
51
|
+
const registryReverseIndex = new Map<string, Set<string>>([
|
|
52
|
+
[srcFile, new Set([oldScssPath])],
|
|
53
|
+
]);
|
|
54
|
+
const scss: SideEffectScssOptions = {
|
|
55
|
+
loadPaths: [],
|
|
56
|
+
scssErrors: [],
|
|
57
|
+
scssDependencies: new Map(),
|
|
58
|
+
registry,
|
|
59
|
+
registryReverseIndex,
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// SCSS import 없는 JS → 삭제만 발생, 등록 없음
|
|
63
|
+
writeEmitResults([makeEmitResult("export class Comp {}", srcFile)], pkgDir, scss);
|
|
64
|
+
|
|
65
|
+
expect(registry.has(oldScssPath)).toBe(false);
|
|
66
|
+
expect(registryReverseIndex.has(srcFile)).toBe(false);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Acceptance: 삭제 후 새 SCSS import가 있으면 등록하고 reverseIndex도 갱신
|
|
70
|
+
it("registers new entries and updates reverseIndex after deletion", () => {
|
|
71
|
+
const oldScssPath = path.resolve(pkgDir, "src", "old.scss");
|
|
72
|
+
const registry = new Map<string, SideEffectScssEntry>([
|
|
73
|
+
[oldScssPath, { scssAbsPath: oldScssPath, cssAbsPath: "/out/old.css", sourceFileName: srcFile }],
|
|
74
|
+
]);
|
|
75
|
+
const registryReverseIndex = new Map<string, Set<string>>([
|
|
76
|
+
[srcFile, new Set([oldScssPath])],
|
|
77
|
+
]);
|
|
78
|
+
const scss: SideEffectScssOptions = {
|
|
79
|
+
loadPaths: [],
|
|
80
|
+
scssErrors: [],
|
|
81
|
+
scssDependencies: new Map(),
|
|
82
|
+
registry,
|
|
83
|
+
registryReverseIndex,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// JS with SCSS import → 삭제 + 등록
|
|
87
|
+
const jsContent = 'import "./button.scss";\nexport class Comp {}';
|
|
88
|
+
writeEmitResults([makeEmitResult(jsContent, srcFile)], pkgDir, scss);
|
|
89
|
+
|
|
90
|
+
// old.scss 삭제됨
|
|
91
|
+
expect(registry.has(oldScssPath)).toBe(false);
|
|
92
|
+
// button.scss가 등록됨 (scssAbsPath = path.resolve(srcDir, "./button.scss"))
|
|
93
|
+
const expectedScssPath = path.resolve(pkgDir, "src", "button.scss");
|
|
94
|
+
expect(registry.has(expectedScssPath)).toBe(true);
|
|
95
|
+
// reverseIndex에 새 항목 반영
|
|
96
|
+
expect(registryReverseIndex.get(srcFile)).toEqual(new Set([expectedScssPath]));
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// Acceptance: reverseIndex에 없는 sourceFileName이면 삭제 없음
|
|
100
|
+
it("does not delete when sourceFileName is not in reverseIndex", () => {
|
|
101
|
+
const otherScssPath = path.resolve(pkgDir, "src", "other.scss");
|
|
102
|
+
const otherSrcFile = path.resolve(pkgDir, "src", "other.ts");
|
|
103
|
+
const registry = new Map<string, SideEffectScssEntry>([
|
|
104
|
+
[otherScssPath, { scssAbsPath: otherScssPath, cssAbsPath: "/out/other.css", sourceFileName: otherSrcFile }],
|
|
105
|
+
]);
|
|
106
|
+
const registryReverseIndex = new Map<string, Set<string>>([
|
|
107
|
+
[otherSrcFile, new Set([otherScssPath])],
|
|
108
|
+
]);
|
|
109
|
+
const scss: SideEffectScssOptions = {
|
|
110
|
+
loadPaths: [],
|
|
111
|
+
scssErrors: [],
|
|
112
|
+
scssDependencies: new Map(),
|
|
113
|
+
registry,
|
|
114
|
+
registryReverseIndex,
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// srcFile (comp.ts)에 대한 emit → other.ts의 항목은 건드리지 않음
|
|
118
|
+
writeEmitResults([makeEmitResult("export class Comp {}", srcFile)], pkgDir, scss);
|
|
119
|
+
|
|
120
|
+
expect(registry.has(otherScssPath)).toBe(true);
|
|
121
|
+
expect(registryReverseIndex.has(otherSrcFile)).toBe(true);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
describe("compileSideEffectScss — incremental compilation", () => {
|
|
126
|
+
function makeEntry(scssAbsPath: string, sourceFileName: string): SideEffectScssEntry {
|
|
127
|
+
return {
|
|
128
|
+
scssAbsPath,
|
|
129
|
+
cssAbsPath: scssAbsPath.replace(/\.scss$/, ".css"),
|
|
130
|
+
sourceFileName,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Acceptance: changedScssFiles 미제공 시 전체 재컴파일
|
|
135
|
+
it("compiles all entries when changedScssFiles is not provided", () => {
|
|
136
|
+
const registry = new Map<string, SideEffectScssEntry>([
|
|
137
|
+
["/src/button.scss", makeEntry("/src/button.scss", "/src/comp.ts")],
|
|
138
|
+
["/src/dialog.scss", makeEntry("/src/dialog.scss", "/src/comp.ts")],
|
|
139
|
+
["/src/card.scss", makeEntry("/src/card.scss", "/src/other.ts")],
|
|
140
|
+
]);
|
|
141
|
+
|
|
142
|
+
compileSideEffectScss(registry, [], [], new Map());
|
|
143
|
+
|
|
144
|
+
expect(mockCompileScssFile).toHaveBeenCalledTimes(3);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Acceptance: 변경된 SCSS 파일만 재컴파일 (직접 히트)
|
|
148
|
+
it("only compiles entries whose scssAbsPath is in changedScssFiles", () => {
|
|
149
|
+
const registry = new Map<string, SideEffectScssEntry>([
|
|
150
|
+
["/src/button.scss", makeEntry("/src/button.scss", "/src/comp.ts")],
|
|
151
|
+
["/src/dialog.scss", makeEntry("/src/dialog.scss", "/src/other.ts")],
|
|
152
|
+
]);
|
|
153
|
+
const changedScssFiles = new Set(["/src/button.scss"]);
|
|
154
|
+
const sideEffectScssDeps = new Map<string, Set<string>>();
|
|
155
|
+
|
|
156
|
+
compileSideEffectScss(registry, [], [], new Map(), changedScssFiles, sideEffectScssDeps);
|
|
157
|
+
|
|
158
|
+
expect(mockCompileScssFile).toHaveBeenCalledTimes(1);
|
|
159
|
+
expect(mockCompileScssFile).toHaveBeenCalledWith("/src/button.scss", []);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// Acceptance: 의존성이 변경된 SCSS도 재컴파일
|
|
163
|
+
it("recompiles entries whose dependency is in changedScssFiles", () => {
|
|
164
|
+
const registry = new Map<string, SideEffectScssEntry>([
|
|
165
|
+
["/src/button.scss", makeEntry("/src/button.scss", "/src/comp.ts")],
|
|
166
|
+
]);
|
|
167
|
+
const changedScssFiles = new Set(["/src/shared.scss"]);
|
|
168
|
+
// button.scss의 이전 컴파일에서 shared.scss가 의존성이었음
|
|
169
|
+
const sideEffectScssDeps = new Map<string, Set<string>>([
|
|
170
|
+
["/src/button.scss", new Set(["/src/shared.scss"])],
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
compileSideEffectScss(registry, [], [], new Map(), changedScssFiles, sideEffectScssDeps);
|
|
174
|
+
|
|
175
|
+
expect(mockCompileScssFile).toHaveBeenCalledTimes(1);
|
|
176
|
+
expect(mockCompileScssFile).toHaveBeenCalledWith("/src/button.scss", []);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Acceptance: 영향받지 않는 항목은 건너뜀
|
|
180
|
+
it("skips entries not affected by changedScssFiles", () => {
|
|
181
|
+
const registry = new Map<string, SideEffectScssEntry>([
|
|
182
|
+
["/src/button.scss", makeEntry("/src/button.scss", "/src/comp.ts")],
|
|
183
|
+
["/src/dialog.scss", makeEntry("/src/dialog.scss", "/src/other.ts")],
|
|
184
|
+
]);
|
|
185
|
+
const changedScssFiles = new Set(["/src/shared.scss"]);
|
|
186
|
+
const sideEffectScssDeps = new Map<string, Set<string>>([
|
|
187
|
+
["/src/button.scss", new Set(["/src/shared.scss"])],
|
|
188
|
+
["/src/dialog.scss", new Set(["/src/theme.scss"])],
|
|
189
|
+
]);
|
|
190
|
+
|
|
191
|
+
compileSideEffectScss(registry, [], [], new Map(), changedScssFiles, sideEffectScssDeps);
|
|
192
|
+
|
|
193
|
+
// button.scss만 재컴파일 (shared.scss가 의존성), dialog.scss는 건너뜀
|
|
194
|
+
expect(mockCompileScssFile).toHaveBeenCalledTimes(1);
|
|
195
|
+
expect(mockCompileScssFile).toHaveBeenCalledWith("/src/button.scss", []);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// Unit: 컴파일 후 sideEffectScssDeps가 갱신됨
|
|
199
|
+
it("updates sideEffectScssDeps after compilation", () => {
|
|
200
|
+
const registry = new Map<string, SideEffectScssEntry>([
|
|
201
|
+
["/src/button.scss", makeEntry("/src/button.scss", "/src/comp.ts")],
|
|
202
|
+
]);
|
|
203
|
+
mockCompileScssFile.mockReturnValue({ css: "/* ok */", dependencies: ["/src/new-dep.scss"] });
|
|
204
|
+
const sideEffectScssDeps = new Map<string, Set<string>>();
|
|
205
|
+
|
|
206
|
+
compileSideEffectScss(registry, [], [], new Map(), undefined, sideEffectScssDeps);
|
|
207
|
+
|
|
208
|
+
expect(sideEffectScssDeps.get("/src/button.scss")).toEqual(new Set(["/src/new-dep.scss"]));
|
|
209
|
+
});
|
|
210
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { describe, it, expect } from "vitest";
|
|
2
|
+
import { buildReverseDeps } from "../../src/angular/ngtsc-build-core";
|
|
3
|
+
|
|
4
|
+
describe("buildReverseDeps", () => {
|
|
5
|
+
// Acceptance: 정방향 맵에서 역방향 인덱스를 구축한다
|
|
6
|
+
it("builds reverse index from forward deps with multiple owners sharing a dep", () => {
|
|
7
|
+
const forward = new Map<string, ReadonlySet<string>>([
|
|
8
|
+
["comp.ts", new Set(["shared.scss", "theme.scss"])],
|
|
9
|
+
["dialog.ts", new Set(["shared.scss"])],
|
|
10
|
+
]);
|
|
11
|
+
|
|
12
|
+
const reverse = buildReverseDeps(forward);
|
|
13
|
+
|
|
14
|
+
expect(reverse.get("shared.scss")).toEqual(new Set(["comp.ts", "dialog.ts"]));
|
|
15
|
+
expect(reverse.get("theme.scss")).toEqual(new Set(["comp.ts"]));
|
|
16
|
+
expect(reverse.size).toBe(2);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Acceptance: 빈 맵이면 역방향 맵도 비어있다
|
|
20
|
+
it("returns empty map for empty input", () => {
|
|
21
|
+
const reverse = buildReverseDeps(new Map());
|
|
22
|
+
|
|
23
|
+
expect(reverse.size).toBe(0);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Unit: 하나의 소유자가 여러 의존성을 가진 경우
|
|
27
|
+
it("maps each dep to its single owner", () => {
|
|
28
|
+
const forward = new Map<string, ReadonlySet<string>>([
|
|
29
|
+
["comp.ts", new Set(["a.scss", "b.scss", "c.scss"])],
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
const reverse = buildReverseDeps(forward);
|
|
33
|
+
|
|
34
|
+
expect(reverse.size).toBe(3);
|
|
35
|
+
expect(reverse.get("a.scss")).toEqual(new Set(["comp.ts"]));
|
|
36
|
+
expect(reverse.get("b.scss")).toEqual(new Set(["comp.ts"]));
|
|
37
|
+
expect(reverse.get("c.scss")).toEqual(new Set(["comp.ts"]));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
// Unit: 의존성이 빈 Set인 소유자는 역방향 맵에 영향 없음
|
|
41
|
+
it("ignores owners with empty dep sets", () => {
|
|
42
|
+
const forward = new Map<string, ReadonlySet<string>>([
|
|
43
|
+
["comp.ts", new Set<string>()],
|
|
44
|
+
["dialog.ts", new Set(["shared.scss"])],
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
const reverse = buildReverseDeps(forward);
|
|
48
|
+
|
|
49
|
+
expect(reverse.size).toBe(1);
|
|
50
|
+
expect(reverse.get("shared.scss")).toEqual(new Set(["dialog.ts"]));
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# vite-angular-plugin SdTsCompiler 전환 — LLM 검증
|
|
2
|
+
|
|
3
|
+
## 검증 항목
|
|
4
|
+
|
|
5
|
+
- [x] AngularBuildPipeline import 제거: `vite-angular-plugin.ts:6` — `SdTsCompiler` import으로 교체, `AngularBuildPipeline` 미사용
|
|
6
|
+
- [x] SdTsCompiler 인스턴스 생성: `:69-81` — `new SdTsCompiler({ pkgDir, cwd, output: { js: true, dts: false }, sourceFileCache, compilerOptionsTransformer })` 올바르게 구성
|
|
7
|
+
- [x] compileAsync 호출: `:90` — `sdTsCompiler.compileAsync(modifiedFiles)` 호출, modifiedFiles는 pendingWatchChanges에서 수집
|
|
8
|
+
- [x] emitResults → emittedFilesBySource 매핑: `:93-95` — `pathx.posix(sourceFileName)` 키로 저장
|
|
9
|
+
- [x] transform 훅: `:107-124` — `emittedFilesBySource.get(normalizedId)` 조회, 인라인 소스맵 분리 유지
|
|
10
|
+
- [x] buildEnd에서 sdTsCompiler 참조 해제: `:127` — `sdTsCompiler = undefined`
|
|
11
|
+
- [x] watch 모드 증분 빌드: `:61-66` — pendingWatchChanges를 modifiedFiles로 전달, compileAsync에서 증분 처리
|
|
12
|
+
- [x] 이미 초기화됐고 변경 없으면 건너뜀: `:84-87` — `emittedFilesBySource.size > 0 && modifiedFiles == null` 조건
|
|
13
|
+
- [x] 기존 테스트 회귀: vite-angular-plugin.spec.ts 6개, vite-angular-plugin-vitest.spec.ts + legacy-watch.spec.ts 5개 모두 통과
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from "vitest";
|
|
2
|
+
import ts from "typescript";
|
|
3
|
+
|
|
4
|
+
const { createWorkerTransformer } = await import(
|
|
5
|
+
"../../src/angular/web-worker-transformer.js"
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
//#region 헬퍼
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* TypeScript 소스 코드에 transformer를 적용하고 결과 코드를 반환한다.
|
|
12
|
+
*/
|
|
13
|
+
function transformCode(
|
|
14
|
+
code: string,
|
|
15
|
+
fileProcessor: (workerFile: string, containingFile: string) => string,
|
|
16
|
+
fileName = "test.ts",
|
|
17
|
+
): string {
|
|
18
|
+
const sourceFile = ts.createSourceFile(fileName, code, ts.ScriptTarget.ES2022, true);
|
|
19
|
+
const transformer = createWorkerTransformer(fileProcessor);
|
|
20
|
+
const result = ts.transform(sourceFile, [transformer]);
|
|
21
|
+
const printer = ts.createPrinter();
|
|
22
|
+
const output = printer.printFile(result.transformed[0]);
|
|
23
|
+
result.dispose();
|
|
24
|
+
return output;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
|
|
29
|
+
describe("createWorkerTransformer", () => {
|
|
30
|
+
// Acceptance: Worker 표준 패턴을 감지하여 번들된 경로로 치환한다
|
|
31
|
+
it("Worker 표준 패턴 — URL 치환 + { type: 'module' } 자동 추가", () => {
|
|
32
|
+
const fileProcessor = vi.fn().mockReturnValue("worker-ABCD1234.js");
|
|
33
|
+
const code = `const w = new Worker(new URL('./my-worker.ts', import.meta.url));`;
|
|
34
|
+
|
|
35
|
+
const output = transformCode(code, fileProcessor);
|
|
36
|
+
|
|
37
|
+
expect(fileProcessor).toHaveBeenCalledWith("./my-worker.ts", "test.ts");
|
|
38
|
+
expect(output).toContain('"worker-ABCD1234.js"');
|
|
39
|
+
expect(output).toContain('type');
|
|
40
|
+
expect(output).toContain('"module"');
|
|
41
|
+
expect(output).not.toContain("./my-worker.ts");
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Acceptance: SharedWorker도 동일하게 처리한다
|
|
45
|
+
it("SharedWorker도 동일하게 변환한다", () => {
|
|
46
|
+
const fileProcessor = vi.fn().mockReturnValue("worker-SHARED01.js");
|
|
47
|
+
const code = `const sw = new SharedWorker(new URL('./shared.ts', import.meta.url));`;
|
|
48
|
+
|
|
49
|
+
const output = transformCode(code, fileProcessor);
|
|
50
|
+
|
|
51
|
+
expect(fileProcessor).toHaveBeenCalledWith("./shared.ts", "test.ts");
|
|
52
|
+
expect(output).toContain('"worker-SHARED01.js"');
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Acceptance: Worker의 기존 options 인자가 있으면 유지한다
|
|
56
|
+
it("기존 options 인자가 있으면 유지한다", () => {
|
|
57
|
+
const fileProcessor = vi.fn().mockReturnValue("worker-OPT00001.js");
|
|
58
|
+
const code = `const w = new Worker(new URL('./w.ts', import.meta.url), { name: 'test' });`;
|
|
59
|
+
|
|
60
|
+
const output = transformCode(code, fileProcessor);
|
|
61
|
+
|
|
62
|
+
expect(output).toContain('"worker-OPT00001.js"');
|
|
63
|
+
expect(output).toContain("name");
|
|
64
|
+
// { type: 'module' } 자동 추가 없이 기존 options가 유지됨
|
|
65
|
+
expect(output).not.toMatch(/type.*module.*name/);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
describe("createWorkerTransformer — 변환하지 않는 케이스", () => {
|
|
70
|
+
const noopProcessor = vi.fn().mockReturnValue("should-not-appear.js");
|
|
71
|
+
|
|
72
|
+
// URL 패턴이 아닌 Worker 생성
|
|
73
|
+
it("URL 패턴 없이 문자열 인자만 있으면 변환하지 않는다", () => {
|
|
74
|
+
const code = `const w = new Worker('./my-worker.ts');`;
|
|
75
|
+
const output = transformCode(code, noopProcessor);
|
|
76
|
+
|
|
77
|
+
expect(noopProcessor).not.toHaveBeenCalled();
|
|
78
|
+
expect(output).toContain("./my-worker.ts");
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// import.meta.url이 아닌 URL
|
|
82
|
+
it("import.meta.url이 아닌 URL은 변환하지 않는다", () => {
|
|
83
|
+
const code = `const w = new Worker(new URL('./w.ts', 'http://example.com'));`;
|
|
84
|
+
const output = transformCode(code, noopProcessor);
|
|
85
|
+
|
|
86
|
+
expect(noopProcessor).not.toHaveBeenCalled();
|
|
87
|
+
expect(output).toContain("./w.ts");
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Worker 인자 없음
|
|
91
|
+
it("Worker 인자가 없으면 변환하지 않는다", () => {
|
|
92
|
+
const code = `const w = new Worker();`;
|
|
93
|
+
transformCode(code, noopProcessor);
|
|
94
|
+
|
|
95
|
+
expect(noopProcessor).not.toHaveBeenCalled();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// Worker 인자 3개 이상
|
|
99
|
+
it("Worker 인자가 3개 이상이면 변환하지 않는다", () => {
|
|
100
|
+
const code = `const w = new Worker(new URL('./w.ts', import.meta.url), {}, 'extra');`;
|
|
101
|
+
transformCode(code, noopProcessor);
|
|
102
|
+
|
|
103
|
+
expect(noopProcessor).not.toHaveBeenCalled();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// URL 인자가 1개
|
|
107
|
+
it("URL 인자가 1개면 변환하지 않는다", () => {
|
|
108
|
+
const code = `const w = new Worker(new URL('./w.ts'));`;
|
|
109
|
+
transformCode(code, noopProcessor);
|
|
110
|
+
|
|
111
|
+
expect(noopProcessor).not.toHaveBeenCalled();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// URL 인자가 3개
|
|
115
|
+
it("URL 인자가 3개면 변환하지 않는다", () => {
|
|
116
|
+
const code = `const w = new Worker(new URL('./w.ts', import.meta.url, 'extra'));`;
|
|
117
|
+
transformCode(code, noopProcessor);
|
|
118
|
+
|
|
119
|
+
expect(noopProcessor).not.toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// 'Worker' 문자열 없으면 skip
|
|
123
|
+
it("소스에 'Worker' 문자열이 없으면 변환을 건너뛴다", () => {
|
|
124
|
+
const code = `const x = 1 + 2;`;
|
|
125
|
+
const output = transformCode(code, noopProcessor);
|
|
126
|
+
|
|
127
|
+
expect(noopProcessor).not.toHaveBeenCalled();
|
|
128
|
+
expect(output).toContain("1 + 2");
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
describe("createWorkerTransformer — 추가 경계 케이스", () => {
|
|
133
|
+
// fileProcessor가 원본과 동일한 경로를 반환하면 변환하지 않는다
|
|
134
|
+
it("fileProcessor가 원본 경로를 그대로 반환하면 AST를 변경하지 않는다", () => {
|
|
135
|
+
const fileProcessor = vi.fn().mockReturnValue("./my-worker.ts");
|
|
136
|
+
const code = `const w = new Worker(new URL('./my-worker.ts', import.meta.url));`;
|
|
137
|
+
|
|
138
|
+
const output = transformCode(code, fileProcessor);
|
|
139
|
+
|
|
140
|
+
expect(fileProcessor).toHaveBeenCalledWith("./my-worker.ts", "test.ts");
|
|
141
|
+
// 원본 경로가 그대로 유지 (변환 없음)
|
|
142
|
+
expect(output).toContain("./my-worker.ts");
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// 소스에 Worker 문자열은 있지만 new 표현이 아닌 경우
|
|
146
|
+
it("Worker 문자열이 있지만 new 표현이 아니면 변환하지 않는다", () => {
|
|
147
|
+
const fileProcessor = vi.fn();
|
|
148
|
+
const code = `const WorkerName = "test";`;
|
|
149
|
+
|
|
150
|
+
transformCode(code, fileProcessor);
|
|
151
|
+
|
|
152
|
+
expect(fileProcessor).not.toHaveBeenCalled();
|
|
153
|
+
});
|
|
154
|
+
});
|
|
@@ -66,7 +66,7 @@ vi.mock("sharp", () => ({
|
|
|
66
66
|
|
|
67
67
|
// consola mock (logger assertion 필요)
|
|
68
68
|
const mockLoggerWarn = vi.fn();
|
|
69
|
-
vi.spyOn(consola, "withTag").mockReturnValue({ debug: vi.fn(), warn: mockLoggerWarn, error: vi.fn(), info: vi.fn(), success: vi.fn() } as any);
|
|
69
|
+
vi.spyOn(consola, "withTag").mockReturnValue({ debug: vi.fn(), warn: mockLoggerWarn, error: vi.fn(), info: vi.fn(), success: vi.fn(), start: vi.fn() } as any);
|
|
70
70
|
|
|
71
71
|
//#endregion
|
|
72
72
|
|
|
@@ -66,7 +66,7 @@ vi.mock("sharp", () => ({ default: mockSharp }));
|
|
|
66
66
|
|
|
67
67
|
// consola mock (logger assertion 필요)
|
|
68
68
|
const mockLoggerWarn = vi.fn();
|
|
69
|
-
vi.spyOn(consola, "withTag").mockReturnValue({ debug: vi.fn(), warn: mockLoggerWarn, error: vi.fn(), info: vi.fn(), success: vi.fn() } as any);
|
|
69
|
+
vi.spyOn(consola, "withTag").mockReturnValue({ debug: vi.fn(), warn: mockLoggerWarn, error: vi.fn(), info: vi.fn(), success: vi.fn(), start: vi.fn() } as any);
|
|
70
70
|
|
|
71
71
|
//#endregion
|
|
72
72
|
|
|
@@ -62,7 +62,7 @@ vi.mock("sharp", () => ({
|
|
|
62
62
|
}));
|
|
63
63
|
|
|
64
64
|
const mockLoggerWarn = vi.fn();
|
|
65
|
-
vi.spyOn(consola, "withTag").mockReturnValue({ debug: vi.fn(), warn: mockLoggerWarn, error: vi.fn(), info: vi.fn(), success: vi.fn() } as any);
|
|
65
|
+
vi.spyOn(consola, "withTag").mockReturnValue({ debug: vi.fn(), warn: mockLoggerWarn, error: vi.fn(), info: vi.fn(), success: vi.fn(), start: vi.fn() } as any);
|
|
66
66
|
|
|
67
67
|
//#endregion
|
|
68
68
|
|