@simplysm/sd-cli 14.0.16 → 14.0.17
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/README.md +2 -1
- package/dist/angular/client-transform-stylesheet.d.ts +2 -0
- package/dist/angular/client-transform-stylesheet.d.ts.map +1 -1
- package/dist/angular/client-transform-stylesheet.js +88 -2
- package/dist/angular/client-transform-stylesheet.js.map +1 -1
- package/dist/angular/vite-angular-plugin.d.ts +7 -0
- package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
- package/dist/angular/vite-angular-plugin.js +78 -16
- package/dist/angular/vite-angular-plugin.js.map +1 -1
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +9 -13
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +8 -9
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/device.d.ts.map +1 -1
- package/dist/commands/device.js +33 -1
- package/dist/commands/device.js.map +1 -1
- package/dist/commands/lint.d.ts +0 -1
- package/dist/commands/lint.d.ts.map +1 -1
- package/dist/commands/lint.js +2 -3
- package/dist/commands/lint.js.map +1 -1
- package/dist/commands/publish.js +2 -2
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js +0 -1
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/electron/electron.d.ts +3 -2
- package/dist/electron/electron.d.ts.map +1 -1
- package/dist/electron/electron.js +54 -31
- package/dist/electron/electron.js.map +1 -1
- package/dist/engines/BaseEngine.js +1 -1
- package/dist/engines/BaseEngine.js.map +1 -1
- package/dist/engines/NgtscEngine.d.ts.map +1 -1
- package/dist/engines/NgtscEngine.js +0 -1
- package/dist/engines/NgtscEngine.js.map +1 -1
- package/dist/engines/ServerEsbuildEngine.d.ts.map +1 -1
- package/dist/engines/ServerEsbuildEngine.js +0 -1
- package/dist/engines/ServerEsbuildEngine.js.map +1 -1
- package/dist/engines/TscEngine.d.ts.map +1 -1
- package/dist/engines/TscEngine.js +0 -1
- package/dist/engines/TscEngine.js.map +1 -1
- package/dist/engines/ViteEngine.d.ts.map +1 -1
- package/dist/engines/ViteEngine.js +8 -1
- package/dist/engines/ViteEngine.js.map +1 -1
- package/dist/engines/index.d.ts +0 -10
- package/dist/engines/index.d.ts.map +1 -1
- package/dist/engines/index.js +0 -5
- package/dist/engines/index.js.map +1 -1
- package/dist/engines/types.d.ts +0 -1
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/infra/SignalHandler.d.ts +1 -6
- package/dist/infra/SignalHandler.d.ts.map +1 -1
- package/dist/infra/SignalHandler.js +4 -13
- package/dist/infra/SignalHandler.js.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +7 -12
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevWatchOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevWatchOrchestrator.js +17 -10
- package/dist/orchestrators/DevWatchOrchestrator.js.map +1 -1
- package/dist/sd-cli-entry.d.ts +0 -1
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +7 -8
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-config.types.d.ts +11 -1
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/utils/angular-compiler.d.ts.map +1 -1
- package/dist/utils/angular-compiler.js +20 -13
- package/dist/utils/angular-compiler.js.map +1 -1
- package/dist/utils/esbuild-config.d.ts +1 -1
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/esbuild-config.js +1 -4
- package/dist/utils/esbuild-config.js.map +1 -1
- package/dist/utils/ngtsc-build-core.d.ts.map +1 -1
- package/dist/utils/ngtsc-build-core.js +3 -0
- package/dist/utils/ngtsc-build-core.js.map +1 -1
- package/dist/utils/tsc-build.d.ts +5 -0
- package/dist/utils/tsc-build.d.ts.map +1 -1
- package/dist/utils/tsc-build.js +2 -1
- package/dist/utils/tsc-build.js.map +1 -1
- package/dist/utils/vite-config.d.ts +1 -1
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +22 -53
- package/dist/utils/vite-config.js.map +1 -1
- package/dist/utils/vite-pwa-plugin.d.ts +9 -0
- package/dist/utils/vite-pwa-plugin.d.ts.map +1 -0
- package/dist/utils/vite-pwa-plugin.js +139 -0
- package/dist/utils/vite-pwa-plugin.js.map +1 -0
- package/dist/utils/worker-utils.d.ts +2 -5
- package/dist/utils/worker-utils.d.ts.map +1 -1
- package/dist/utils/worker-utils.js +5 -11
- package/dist/utils/worker-utils.js.map +1 -1
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +9 -3
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/library-build.worker.d.ts.map +1 -1
- package/dist/workers/library-build.worker.js +6 -2
- package/dist/workers/library-build.worker.js.map +1 -1
- package/dist/workers/ngtsc-build.worker.js +2 -2
- package/dist/workers/ngtsc-build.worker.js.map +1 -1
- package/dist/workers/server-build.worker.d.ts.map +1 -1
- package/dist/workers/server-build.worker.js +6 -2
- package/dist/workers/server-build.worker.js.map +1 -1
- package/dist/workers/server-runtime.worker.js +4 -4
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/docs/config.md +26 -0
- package/docs/pwa-configuration-types.md +1 -1
- package/package.json +8 -10
- package/src/angular/client-transform-stylesheet.ts +104 -2
- package/src/angular/vite-angular-plugin.ts +92 -31
- package/src/capacitor/capacitor.ts +10 -26
- package/src/commands/check.ts +8 -11
- package/src/commands/device.ts +38 -3
- package/src/commands/lint.ts +2 -3
- package/src/commands/publish.ts +2 -2
- package/src/commands/typecheck.ts +0 -1
- package/src/electron/electron.ts +62 -43
- package/src/engines/BaseEngine.ts +1 -1
- package/src/engines/NgtscEngine.ts +0 -1
- package/src/engines/ServerEsbuildEngine.ts +0 -1
- package/src/engines/TscEngine.ts +0 -1
- package/src/engines/ViteEngine.ts +7 -1
- package/src/engines/index.ts +0 -10
- package/src/engines/types.ts +0 -1
- package/src/infra/SignalHandler.ts +4 -14
- package/src/orchestrators/BuildOrchestrator.ts +7 -9
- package/src/orchestrators/DevWatchOrchestrator.ts +21 -9
- package/src/sd-cli-entry.ts +11 -16
- package/src/sd-config.types.ts +12 -1
- package/src/utils/angular-compiler.ts +21 -21
- package/src/utils/esbuild-config.ts +2 -5
- package/src/utils/ngtsc-build-core.ts +7 -0
- package/src/utils/tsc-build.ts +7 -0
- package/src/utils/vite-config.ts +23 -55
- package/src/utils/vite-pwa-plugin.ts +168 -0
- package/src/utils/worker-utils.ts +5 -11
- package/src/workers/client.worker.ts +11 -3
- package/src/workers/library-build.worker.ts +6 -2
- package/src/workers/ngtsc-build.worker.ts +2 -2
- package/src/workers/server-build.worker.ts +7 -2
- package/src/workers/server-runtime.worker.ts +4 -4
- package/tests/angular/client-transform-stylesheet.spec.ts +43 -0
- package/tests/angular/find-affected-by-scss.spec.ts +37 -0
- package/tests/angular/fixtures/basic-app/scss/_colors.scss +1 -0
- package/tests/angular/fixtures/basic-app/scss/_variables.scss +3 -0
- package/tests/angular/fixtures/basic-app/src/styled.component.ts +14 -0
- package/tests/angular/linker-disk-cache.spec.ts +158 -0
- package/tests/angular/scss-disk-cache.spec.ts +162 -0
- package/tests/angular/vite-angular-plugin-hmr-fallback.spec.ts +15 -15
- package/tests/angular/vite-angular-plugin-hmr.spec.ts +9 -9
- package/tests/angular/vite-angular-plugin-lint.spec.ts +4 -4
- package/tests/angular/vite-angular-plugin-scss-hmr.spec.ts +87 -0
- package/tests/angular/vite-angular-plugin.spec.ts +15 -15
- package/tests/capacitor/capacitor-icon.spec.ts +2 -4
- package/tests/capacitor/capacitor-init.spec.ts +2 -4
- package/tests/capacitor/capacitor-workspace.spec.ts +2 -4
- package/tests/commands/device.spec.ts +100 -0
- package/tests/electron/electron.spec.ts +24 -17
- package/tests/engines/ngtsc-engine.spec.ts +0 -3
- package/tests/engines/server-esbuild-engine.spec.ts +0 -3
- package/tests/engines/tsc-engine.spec.ts +1 -2
- package/tests/engines/vite-engine.spec.ts +0 -2
- package/tests/infra/signal-handler.spec.ts +1 -12
- package/tests/orchestrators/build-orchestrator.spec.ts +0 -6
- package/tests/orchestrators/dev-watch-orchestrator.spec.ts +24 -66
- package/tests/utils/angular-compiler.spec.ts +1396 -32
- package/tests/utils/esbuild-config.spec.ts +4 -7
- package/tests/utils/{ngtsc-build-core-angular-compiler.spec.ts → ngtsc-build-core.spec.ts} +142 -11
- package/tests/utils/tsc-build.spec.ts +4 -1
- package/tests/utils/vite-config.spec.ts +130 -261
- package/tests/utils/vite-pwa-plugin.acc.spec.ts +143 -0
- package/tests/utils/vite-pwa-plugin.spec.ts +350 -0
- package/tests/utils/worker-utils.spec.ts +8 -7
- package/tests/workers/client-worker.spec.ts +50 -1
- package/tests/workers/dev-port-file.verify.md +6 -0
- package/tests/workers/library-build-lint.spec.ts +1 -1
- package/tests/workers/library-build-worker.spec.ts +1 -1
- package/tests/workers/ngtsc-build-lint.spec.ts +1 -1
- package/tests/workers/server-build-lint.spec.ts +1 -1
- package/tests/workers/server-build-worker.spec.ts +1 -1
- package/tests/workers/server-runtime-worker.spec.ts +8 -1
- package/dist/infra/WorkerManager.d.ts +0 -40
- package/dist/infra/WorkerManager.d.ts.map +0 -1
- package/dist/infra/WorkerManager.js +0 -59
- package/dist/infra/WorkerManager.js.map +0 -1
- package/dist/utils/SdCliReporter.d.ts +0 -18
- package/dist/utils/SdCliReporter.d.ts.map +0 -1
- package/dist/utils/SdCliReporter.js +0 -144
- package/dist/utils/SdCliReporter.js.map +0 -1
- package/src/infra/WorkerManager.ts +0 -65
- package/src/utils/SdCliReporter.ts +0 -177
- package/tests/angular/scss-compiler-async.spec.ts +0 -54
- package/tests/commands/dev.spec.ts +0 -53
- package/tests/commands/watch.spec.ts +0 -53
- package/tests/infra/worker-manager.spec.ts +0 -63
- package/tests/utils/angular-compiler-emit.spec.ts +0 -570
- package/tests/utils/angular-compiler-init.spec.ts +0 -705
- package/tests/utils/angular-compiler-update.spec.ts +0 -293
- package/tests/utils/build-env.spec.ts +0 -33
- package/tests/utils/ngtsc-build-core-transform-stylesheet.spec.ts +0 -124
- package/tests/utils/ngtsc-scss-refactor.spec.ts +0 -47
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
|
|
3
|
-
const mocks = vi.hoisted(() => ({
|
|
4
|
-
initialize: vi.fn(async () => {}),
|
|
5
|
-
start: vi.fn(async () => {}),
|
|
6
|
-
awaitTermination: vi.fn(async () => {}),
|
|
7
|
-
shutdown: vi.fn(async () => {}),
|
|
8
|
-
ctor: vi.fn(),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
vi.mock("../../src/orchestrators/DevWatchOrchestrator", () => ({
|
|
12
|
-
DevWatchOrchestrator: vi.fn().mockImplementation(function (this: any, options: any) {
|
|
13
|
-
mocks.ctor(options);
|
|
14
|
-
this.initialize = mocks.initialize;
|
|
15
|
-
this.start = mocks.start;
|
|
16
|
-
this.awaitTermination = mocks.awaitTermination;
|
|
17
|
-
this.shutdown = mocks.shutdown;
|
|
18
|
-
}),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
const { runWatch } = await import("../../src/commands/watch");
|
|
22
|
-
|
|
23
|
-
describe("runWatch", () => {
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
vi.clearAllMocks();
|
|
26
|
-
mocks.initialize.mockResolvedValue(undefined);
|
|
27
|
-
mocks.start.mockResolvedValue(undefined);
|
|
28
|
-
mocks.awaitTermination.mockResolvedValue(undefined);
|
|
29
|
-
mocks.shutdown.mockResolvedValue(undefined);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it("creates DevWatchOrchestrator with mode:watch and runs lifecycle", async () => {
|
|
33
|
-
await runWatch({ targets: ["core-common"], options: ["-o", "fast"] });
|
|
34
|
-
|
|
35
|
-
expect(mocks.ctor).toHaveBeenCalledWith({
|
|
36
|
-
mode: "watch",
|
|
37
|
-
targets: ["core-common"],
|
|
38
|
-
options: ["-o", "fast"],
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
expect(mocks.initialize).toHaveBeenCalledOnce();
|
|
42
|
-
expect(mocks.start).toHaveBeenCalledOnce();
|
|
43
|
-
expect(mocks.awaitTermination).toHaveBeenCalledOnce();
|
|
44
|
-
expect(mocks.shutdown).toHaveBeenCalledOnce();
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("calls shutdown even when initialize throws", async () => {
|
|
48
|
-
mocks.initialize.mockRejectedValueOnce(new Error("config error"));
|
|
49
|
-
|
|
50
|
-
await expect(runWatch({ targets: [], options: [] })).rejects.toThrow("config error");
|
|
51
|
-
expect(mocks.shutdown).toHaveBeenCalledOnce();
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from "vitest";
|
|
2
|
-
|
|
3
|
-
vi.mock("@simplysm/core-node", () => ({
|
|
4
|
-
Worker: {
|
|
5
|
-
create: vi.fn(() => ({
|
|
6
|
-
terminate: vi.fn(async () => {}),
|
|
7
|
-
on: vi.fn(),
|
|
8
|
-
off: vi.fn(),
|
|
9
|
-
})),
|
|
10
|
-
},
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
const { WorkerManager } = await import("../../src/infra/WorkerManager");
|
|
14
|
-
|
|
15
|
-
describe("WorkerManager", () => {
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
vi.clearAllMocks();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("creates a worker and tracks by ID", () => {
|
|
21
|
-
const manager = new WorkerManager();
|
|
22
|
-
const worker = manager.create("core:build", "./fake.worker.js");
|
|
23
|
-
|
|
24
|
-
expect(worker).toBeDefined();
|
|
25
|
-
expect(manager.size).toBe(1);
|
|
26
|
-
expect(manager.ids).toContain("core:build");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("retrieves a worker by ID", () => {
|
|
30
|
-
const manager = new WorkerManager();
|
|
31
|
-
const created = manager.create("core:build", "./fake.worker.js");
|
|
32
|
-
|
|
33
|
-
const found = manager.get("core:build");
|
|
34
|
-
expect(found).toBe(created);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("returns undefined for non-existent worker", () => {
|
|
38
|
-
const manager = new WorkerManager();
|
|
39
|
-
expect(manager.get("nonexistent")).toBeUndefined();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it("terminates a single worker and removes it", async () => {
|
|
43
|
-
const manager = new WorkerManager();
|
|
44
|
-
const worker = manager.create("core:build", "./fake.worker.js");
|
|
45
|
-
|
|
46
|
-
await manager.terminate("core:build");
|
|
47
|
-
|
|
48
|
-
expect(worker.terminate).toHaveBeenCalledOnce();
|
|
49
|
-
expect(manager.size).toBe(0);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("terminates all workers and clears", async () => {
|
|
53
|
-
const manager = new WorkerManager();
|
|
54
|
-
const w1 = manager.create("core:build", "./fake.worker.js");
|
|
55
|
-
const w2 = manager.create("core:dts", "./fake.worker.js");
|
|
56
|
-
|
|
57
|
-
await manager.terminateAll();
|
|
58
|
-
|
|
59
|
-
expect(w1.terminate).toHaveBeenCalledOnce();
|
|
60
|
-
expect(w2.terminate).toHaveBeenCalledOnce();
|
|
61
|
-
expect(manager.size).toBe(0);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,570 +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-emit-"));
|
|
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/utils/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 } = await import(
|
|
82
|
-
"../../src/utils/angular-compiler"
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
// --- Tests ---
|
|
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
|
-
// --- Unit Tests: Slice 1 — emitAffectedFiles ---
|
|
103
|
-
|
|
104
|
-
describe("AngularCompiler.emitAffectedFiles — Unit Tests", () => {
|
|
105
|
-
it("initialize() 전 호출 시 에러를 던진다", () => {
|
|
106
|
-
const compiler = new AngularCompiler({
|
|
107
|
-
rootNames: ["src/main.ts"],
|
|
108
|
-
compilerOptions: { target: ts.ScriptTarget.ESNext },
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
expect(() => [...compiler.emitAffectedFiles()]).toThrow("initialize()");
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("noEmit=true이면 빈 Iterator를 반환한다", async () => {
|
|
115
|
-
realProgram = createRealTsProgram(
|
|
116
|
-
{ "a.ts": "export const a = 1;" },
|
|
117
|
-
{ noEmit: true },
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
const compiler = new AngularCompiler({
|
|
121
|
-
rootNames: realProgram.rootNames,
|
|
122
|
-
compilerOptions: {
|
|
123
|
-
target: ts.ScriptTarget.ESNext,
|
|
124
|
-
module: ts.ModuleKind.ESNext,
|
|
125
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
126
|
-
skipLibCheck: true,
|
|
127
|
-
types: [],
|
|
128
|
-
noEmit: true,
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
await compiler.initialize();
|
|
133
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
134
|
-
expect(results).toEqual([]);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it("ignoreForEmit에 포함된 파일은 emit되지 않는다", async () => {
|
|
138
|
-
realProgram = createRealTsProgram({ "a.ts": "export const a = 1;" });
|
|
139
|
-
|
|
140
|
-
const compiler = new AngularCompiler({
|
|
141
|
-
rootNames: realProgram.rootNames,
|
|
142
|
-
compilerOptions: {
|
|
143
|
-
target: ts.ScriptTarget.ESNext,
|
|
144
|
-
module: ts.ModuleKind.ESNext,
|
|
145
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
146
|
-
skipLibCheck: true,
|
|
147
|
-
types: [],
|
|
148
|
-
},
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
await compiler.initialize();
|
|
152
|
-
|
|
153
|
-
// ignoreForEmit에 모든 소스 파일 추가
|
|
154
|
-
const tsProgram = compiler.getTsProgram();
|
|
155
|
-
for (const sf of tsProgram.getSourceFiles()) {
|
|
156
|
-
mockIgnoreForEmit.add(sf);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
160
|
-
expect(results).toEqual([]);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it("declaration file은 2차 루프에서 skip된다", async () => {
|
|
164
|
-
realProgram = createRealTsProgram({ "a.ts": "export const a = 1;" });
|
|
165
|
-
|
|
166
|
-
const compiler = new AngularCompiler({
|
|
167
|
-
rootNames: realProgram.rootNames,
|
|
168
|
-
compilerOptions: {
|
|
169
|
-
target: ts.ScriptTarget.ESNext,
|
|
170
|
-
module: ts.ModuleKind.ESNext,
|
|
171
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
172
|
-
skipLibCheck: true,
|
|
173
|
-
types: [],
|
|
174
|
-
},
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
await compiler.initialize();
|
|
178
|
-
// 이미 emit된 파일이 없는 상태에서도 .d.ts 파일은 2차 루프에서 skip
|
|
179
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
180
|
-
// .d.ts 입력 파일이 결과에 포함되지 않아야 한다
|
|
181
|
-
for (const r of results) {
|
|
182
|
-
// emit된 결과의 원본 소스가 declaration file이면 안 됨 (입력 .d.ts 파일)
|
|
183
|
-
expect((r as { filename: string }).filename).not.toMatch(/node_modules/);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
it("sourceFilter가 적용되면 필터를 통과하지 못한 파일은 결과에 포함되지 않는다", async () => {
|
|
188
|
-
realProgram = createRealTsProgram({
|
|
189
|
-
"a.ts": "export const a = 1;",
|
|
190
|
-
"b.ts": "export const b = 2;",
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
const compiler = new AngularCompiler({
|
|
194
|
-
rootNames: realProgram.rootNames,
|
|
195
|
-
compilerOptions: {
|
|
196
|
-
target: ts.ScriptTarget.ESNext,
|
|
197
|
-
module: ts.ModuleKind.ESNext,
|
|
198
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
199
|
-
skipLibCheck: true,
|
|
200
|
-
types: [],
|
|
201
|
-
},
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
await compiler.initialize();
|
|
205
|
-
|
|
206
|
-
// 파일 a만 허용 (sourceFilter는 소스 파일명 기준)
|
|
207
|
-
const results = [...compiler.emitAffectedFiles({
|
|
208
|
-
sourceFilter: (fileName: string) => fileName.includes("a.ts"),
|
|
209
|
-
})];
|
|
210
|
-
|
|
211
|
-
// a.ts에서 나온 출력만 포함 (b.ts 출력은 제외)
|
|
212
|
-
expect(results.length).toBeGreaterThan(0);
|
|
213
|
-
for (const r of results) {
|
|
214
|
-
expect((r as { filename: string }).filename).toMatch(/[/\\]a\./);
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
it("EmitResult는 filename과 contents를 포함한다", async () => {
|
|
219
|
-
realProgram = createRealTsProgram({ "a.ts": "export const a = 1;" });
|
|
220
|
-
|
|
221
|
-
const compiler = new AngularCompiler({
|
|
222
|
-
rootNames: realProgram.rootNames,
|
|
223
|
-
compilerOptions: {
|
|
224
|
-
target: ts.ScriptTarget.ESNext,
|
|
225
|
-
module: ts.ModuleKind.ESNext,
|
|
226
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
227
|
-
skipLibCheck: true,
|
|
228
|
-
types: [],
|
|
229
|
-
},
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
await compiler.initialize();
|
|
233
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
234
|
-
|
|
235
|
-
expect(results.length).toBeGreaterThan(0);
|
|
236
|
-
for (const r of results) {
|
|
237
|
-
expect(r).toHaveProperty("filename");
|
|
238
|
-
expect(r).toHaveProperty("contents");
|
|
239
|
-
expect(typeof (r as { filename: string }).filename).toBe("string");
|
|
240
|
-
expect(typeof (r as { contents: string }).contents).toBe("string");
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// --- Acceptance Tests: Slice 1 — emitAffectedFiles ---
|
|
246
|
-
|
|
247
|
-
describe("AngularCompiler — emitAffectedFiles", () => {
|
|
248
|
-
// Scenario: 변경된 파일만 emit
|
|
249
|
-
it("변경된 파일만 emit하고 변경되지 않은 파일은 emit하지 않는다", async () => {
|
|
250
|
-
// 파일 A, B, C로 프로그램 구성
|
|
251
|
-
realProgram = createRealTsProgram({
|
|
252
|
-
"a.ts": "export const a = 1;",
|
|
253
|
-
"b.ts": "export const b = 2;",
|
|
254
|
-
"c.ts": "export const c = 3;",
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
const compiler = new AngularCompiler({
|
|
258
|
-
rootNames: realProgram.rootNames,
|
|
259
|
-
compilerOptions: {
|
|
260
|
-
target: ts.ScriptTarget.ESNext,
|
|
261
|
-
module: ts.ModuleKind.ESNext,
|
|
262
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
263
|
-
skipLibCheck: true,
|
|
264
|
-
types: [],
|
|
265
|
-
},
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
await compiler.initialize();
|
|
269
|
-
|
|
270
|
-
// 첫 빌드에서 모든 파일이 affected → 모두 emit
|
|
271
|
-
const firstResults = [...compiler.emitAffectedFiles()];
|
|
272
|
-
const firstEmittedFiles = firstResults.map((r: { filename: string }) => r.filename);
|
|
273
|
-
expect(firstEmittedFiles.length).toBeGreaterThan(0);
|
|
274
|
-
|
|
275
|
-
// 두번째 빌드: safeToSkipEmit이 true이면 skip
|
|
276
|
-
mockSafeToSkipEmit.mockReturnValue(true);
|
|
277
|
-
await compiler.initialize();
|
|
278
|
-
|
|
279
|
-
const secondResults = [...compiler.emitAffectedFiles()];
|
|
280
|
-
// safeToSkipEmit=true + affectedFiles에 없는 파일은 emit하지 않는다
|
|
281
|
-
expect(secondResults.length).toBe(0);
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// Scenario: 첫 빌드에서 모든 파일 emit
|
|
285
|
-
it("첫 빌드에서 모든 소스 파일이 emit된다", async () => {
|
|
286
|
-
realProgram = createRealTsProgram({
|
|
287
|
-
"a.ts": "export const a = 1;",
|
|
288
|
-
"b.ts": "export const b = 2;",
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
const compiler = new AngularCompiler({
|
|
292
|
-
rootNames: realProgram.rootNames,
|
|
293
|
-
compilerOptions: {
|
|
294
|
-
target: ts.ScriptTarget.ESNext,
|
|
295
|
-
module: ts.ModuleKind.ESNext,
|
|
296
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
297
|
-
skipLibCheck: true,
|
|
298
|
-
types: [],
|
|
299
|
-
},
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
await compiler.initialize();
|
|
303
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
304
|
-
|
|
305
|
-
// 모든 소스 파일이 emit됨 (declaration file 제외)
|
|
306
|
-
expect(results.length).toBeGreaterThanOrEqual(2);
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
// Scenario: Angular가 affected로 판단하지만 TypeScript가 판단하지 않은 파일
|
|
310
|
-
it("TypeScript가 emit하지 않았지만 safeToSkipEmit이 false인 파일이 emit된다", async () => {
|
|
311
|
-
realProgram = createRealTsProgram({
|
|
312
|
-
"a.ts": "export const a = 1;",
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
// safeToSkipEmit이 false이면 2차 루프에서 emit해야 한다
|
|
316
|
-
mockSafeToSkipEmit.mockReturnValue(false);
|
|
317
|
-
|
|
318
|
-
const compiler = new AngularCompiler({
|
|
319
|
-
rootNames: realProgram.rootNames,
|
|
320
|
-
compilerOptions: {
|
|
321
|
-
target: ts.ScriptTarget.ESNext,
|
|
322
|
-
module: ts.ModuleKind.ESNext,
|
|
323
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
324
|
-
skipLibCheck: true,
|
|
325
|
-
types: [],
|
|
326
|
-
},
|
|
327
|
-
});
|
|
328
|
-
|
|
329
|
-
await compiler.initialize();
|
|
330
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
331
|
-
|
|
332
|
-
// 파일이 emit됨
|
|
333
|
-
expect(results.length).toBeGreaterThan(0);
|
|
334
|
-
// recordSuccessfulEmit이 호출됨
|
|
335
|
-
expect(mockRecordSuccessfulEmit).toHaveBeenCalled();
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
// Scenario: safeToSkipEmit이 true이고 affectedFiles에 없는 파일은 skip
|
|
339
|
-
it("safeToSkipEmit이 true이고 affectedFiles에 없으면 emit하지 않는다", async () => {
|
|
340
|
-
realProgram = createRealTsProgram({
|
|
341
|
-
"a.ts": "export const a = 1;",
|
|
342
|
-
});
|
|
343
|
-
|
|
344
|
-
const compiler = new AngularCompiler({
|
|
345
|
-
rootNames: realProgram.rootNames,
|
|
346
|
-
compilerOptions: {
|
|
347
|
-
target: ts.ScriptTarget.ESNext,
|
|
348
|
-
module: ts.ModuleKind.ESNext,
|
|
349
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
350
|
-
skipLibCheck: true,
|
|
351
|
-
types: [],
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
// 첫 빌드
|
|
356
|
-
await compiler.initialize();
|
|
357
|
-
void [...compiler.emitAffectedFiles()];
|
|
358
|
-
|
|
359
|
-
// 두번째 빌드: safeToSkipEmit=true + 변경 없음
|
|
360
|
-
mockSafeToSkipEmit.mockReturnValue(true);
|
|
361
|
-
await compiler.initialize();
|
|
362
|
-
|
|
363
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
364
|
-
expect(results.length).toBe(0);
|
|
365
|
-
});
|
|
366
|
-
|
|
367
|
-
// Scenario: emit 성공 시 incremental 추적 기록
|
|
368
|
-
it("emit 성공 시 recordSuccessfulEmit이 호출된다", async () => {
|
|
369
|
-
realProgram = createRealTsProgram({
|
|
370
|
-
"a.ts": "export const a = 1;",
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
const compiler = new AngularCompiler({
|
|
374
|
-
rootNames: realProgram.rootNames,
|
|
375
|
-
compilerOptions: {
|
|
376
|
-
target: ts.ScriptTarget.ESNext,
|
|
377
|
-
module: ts.ModuleKind.ESNext,
|
|
378
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
379
|
-
skipLibCheck: true,
|
|
380
|
-
types: [],
|
|
381
|
-
},
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
await compiler.initialize();
|
|
385
|
-
void [...compiler.emitAffectedFiles()];
|
|
386
|
-
|
|
387
|
-
expect(mockRecordSuccessfulEmit).toHaveBeenCalled();
|
|
388
|
-
});
|
|
389
|
-
|
|
390
|
-
// Scenario: prepareEmit()의 transformers가 emit에 적용
|
|
391
|
-
it("prepareEmit()의 transformers가 emit에 적용된다", async () => {
|
|
392
|
-
realProgram = createRealTsProgram({
|
|
393
|
-
"a.ts": "export const a = 1;",
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
const mockTransformerBefore = vi.fn(
|
|
397
|
-
(_ctx: ts.TransformationContext) => (sf: ts.SourceFile) => sf,
|
|
398
|
-
);
|
|
399
|
-
mockPrepareEmit.mockReturnValue({
|
|
400
|
-
transformers: { before: [mockTransformerBefore], after: [] },
|
|
401
|
-
});
|
|
402
|
-
|
|
403
|
-
const compiler = new AngularCompiler({
|
|
404
|
-
rootNames: realProgram.rootNames,
|
|
405
|
-
compilerOptions: {
|
|
406
|
-
target: ts.ScriptTarget.ESNext,
|
|
407
|
-
module: ts.ModuleKind.ESNext,
|
|
408
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
409
|
-
skipLibCheck: true,
|
|
410
|
-
types: [],
|
|
411
|
-
},
|
|
412
|
-
});
|
|
413
|
-
|
|
414
|
-
await compiler.initialize();
|
|
415
|
-
void [...compiler.emitAffectedFiles()];
|
|
416
|
-
|
|
417
|
-
// prepareEmit이 호출되었다
|
|
418
|
-
expect(mockPrepareEmit).toHaveBeenCalled();
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
// Scenario: 추가 transformers를 외부에서 주입 가능
|
|
422
|
-
it("additionalTransformers가 emit 시 적용된다", async () => {
|
|
423
|
-
realProgram = createRealTsProgram({
|
|
424
|
-
"a.ts": "export const a = 1;",
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
const additionalBefore = vi.fn(
|
|
428
|
-
(_ctx: ts.TransformationContext) => (sf: ts.SourceFile) => sf,
|
|
429
|
-
);
|
|
430
|
-
|
|
431
|
-
const compiler = new AngularCompiler({
|
|
432
|
-
rootNames: realProgram.rootNames,
|
|
433
|
-
compilerOptions: {
|
|
434
|
-
target: ts.ScriptTarget.ESNext,
|
|
435
|
-
module: ts.ModuleKind.ESNext,
|
|
436
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
437
|
-
skipLibCheck: true,
|
|
438
|
-
types: [],
|
|
439
|
-
},
|
|
440
|
-
});
|
|
441
|
-
|
|
442
|
-
await compiler.initialize();
|
|
443
|
-
const results = [...compiler.emitAffectedFiles({
|
|
444
|
-
additionalTransformers: {
|
|
445
|
-
before: [additionalBefore],
|
|
446
|
-
},
|
|
447
|
-
})];
|
|
448
|
-
|
|
449
|
-
// emit이 실행되었다
|
|
450
|
-
expect(results.length).toBeGreaterThan(0);
|
|
451
|
-
});
|
|
452
|
-
|
|
453
|
-
// Scenario: JS와 .d.ts 모두 emit
|
|
454
|
-
it("declaration=true, noEmit=false일 때 .js와 .d.ts 모두 emit된다", async () => {
|
|
455
|
-
realProgram = createRealTsProgram(
|
|
456
|
-
{ "a.ts": "export const a = 1;" },
|
|
457
|
-
{ declaration: true, noEmit: false },
|
|
458
|
-
);
|
|
459
|
-
|
|
460
|
-
const compiler = new AngularCompiler({
|
|
461
|
-
rootNames: realProgram.rootNames,
|
|
462
|
-
compilerOptions: {
|
|
463
|
-
target: ts.ScriptTarget.ESNext,
|
|
464
|
-
module: ts.ModuleKind.ESNext,
|
|
465
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
466
|
-
skipLibCheck: true,
|
|
467
|
-
types: [],
|
|
468
|
-
declaration: true,
|
|
469
|
-
noEmit: false,
|
|
470
|
-
outDir: path.join(realProgram.dir, "out"),
|
|
471
|
-
},
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
await compiler.initialize();
|
|
475
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
476
|
-
|
|
477
|
-
const filenames = results.map((r: { filename: string }) => r.filename);
|
|
478
|
-
const hasJs = filenames.some((f: string) => f.endsWith(".js"));
|
|
479
|
-
const hasDts = filenames.some((f: string) => f.endsWith(".d.ts"));
|
|
480
|
-
expect(hasJs).toBe(true);
|
|
481
|
-
expect(hasDts).toBe(true);
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
// Scenario: JS만 emit
|
|
485
|
-
it("declaration=false일 때 .js만 emit되고 .d.ts는 생성되지 않는다", async () => {
|
|
486
|
-
realProgram = createRealTsProgram(
|
|
487
|
-
{ "a.ts": "export const a = 1;" },
|
|
488
|
-
{ declaration: false, noEmit: false },
|
|
489
|
-
);
|
|
490
|
-
|
|
491
|
-
const compiler = new AngularCompiler({
|
|
492
|
-
rootNames: realProgram.rootNames,
|
|
493
|
-
compilerOptions: {
|
|
494
|
-
target: ts.ScriptTarget.ESNext,
|
|
495
|
-
module: ts.ModuleKind.ESNext,
|
|
496
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
497
|
-
skipLibCheck: true,
|
|
498
|
-
types: [],
|
|
499
|
-
declaration: false,
|
|
500
|
-
noEmit: false,
|
|
501
|
-
outDir: path.join(realProgram.dir, "out"),
|
|
502
|
-
},
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
await compiler.initialize();
|
|
506
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
507
|
-
|
|
508
|
-
const filenames = results.map((r: { filename: string }) => r.filename);
|
|
509
|
-
const hasJs = filenames.some((f: string) => f.endsWith(".js"));
|
|
510
|
-
const hasDts = filenames.some((f: string) => f.endsWith(".d.ts"));
|
|
511
|
-
expect(hasJs).toBe(true);
|
|
512
|
-
expect(hasDts).toBe(false);
|
|
513
|
-
});
|
|
514
|
-
|
|
515
|
-
// Scenario: .d.ts만 emit
|
|
516
|
-
it("emitDeclarationOnly=true일 때 .d.ts만 emit되고 .js는 생성되지 않는다", async () => {
|
|
517
|
-
realProgram = createRealTsProgram(
|
|
518
|
-
{ "a.ts": "export const a = 1;" },
|
|
519
|
-
{ declaration: true, emitDeclarationOnly: true },
|
|
520
|
-
);
|
|
521
|
-
|
|
522
|
-
const compiler = new AngularCompiler({
|
|
523
|
-
rootNames: realProgram.rootNames,
|
|
524
|
-
compilerOptions: {
|
|
525
|
-
target: ts.ScriptTarget.ESNext,
|
|
526
|
-
module: ts.ModuleKind.ESNext,
|
|
527
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
528
|
-
skipLibCheck: true,
|
|
529
|
-
types: [],
|
|
530
|
-
declaration: true,
|
|
531
|
-
emitDeclarationOnly: true,
|
|
532
|
-
outDir: path.join(realProgram.dir, "out"),
|
|
533
|
-
},
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
await compiler.initialize();
|
|
537
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
538
|
-
|
|
539
|
-
const filenames = results.map((r: { filename: string }) => r.filename);
|
|
540
|
-
const hasJs = filenames.some((f: string) => f.endsWith(".js"));
|
|
541
|
-
const hasDts = filenames.some((f: string) => f.endsWith(".d.ts"));
|
|
542
|
-
expect(hasJs).toBe(false);
|
|
543
|
-
expect(hasDts).toBe(true);
|
|
544
|
-
});
|
|
545
|
-
|
|
546
|
-
// Scenario: emit 없음 (typecheck 전용)
|
|
547
|
-
it("noEmit=true일 때 어떤 파일도 emit되지 않는다", async () => {
|
|
548
|
-
realProgram = createRealTsProgram(
|
|
549
|
-
{ "a.ts": "export const a = 1;" },
|
|
550
|
-
{ noEmit: true },
|
|
551
|
-
);
|
|
552
|
-
|
|
553
|
-
const compiler = new AngularCompiler({
|
|
554
|
-
rootNames: realProgram.rootNames,
|
|
555
|
-
compilerOptions: {
|
|
556
|
-
target: ts.ScriptTarget.ESNext,
|
|
557
|
-
module: ts.ModuleKind.ESNext,
|
|
558
|
-
moduleResolution: ts.ModuleResolutionKind.Bundler,
|
|
559
|
-
skipLibCheck: true,
|
|
560
|
-
types: [],
|
|
561
|
-
noEmit: true,
|
|
562
|
-
},
|
|
563
|
-
});
|
|
564
|
-
|
|
565
|
-
await compiler.initialize();
|
|
566
|
-
const results = [...compiler.emitAffectedFiles()];
|
|
567
|
-
|
|
568
|
-
expect(results.length).toBe(0);
|
|
569
|
-
});
|
|
570
|
-
});
|