@simplysm/sd-cli 14.0.11 → 14.0.13
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 +58 -253
- package/dist/angular/client-transform-stylesheet.js +1 -1
- package/dist/angular/client-transform-stylesheet.js.map +1 -1
- package/dist/angular/vite-angular-plugin.d.ts +4 -2
- package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
- package/dist/angular/vite-angular-plugin.js +73 -36
- package/dist/angular/vite-angular-plugin.js.map +1 -1
- package/dist/angular/vite-postcss-inline-plugin.d.ts +1 -1
- package/dist/angular/vite-postcss-inline-plugin.js +1 -1
- package/dist/capacitor/capacitor.d.ts +20 -2
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +155 -28
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/build.d.ts +3 -10
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +3 -10
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/check.js +3 -3
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/dev.d.ts +3 -9
- package/dist/commands/dev.d.ts.map +1 -1
- package/dist/commands/dev.js +3 -9
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/device.d.ts +3 -3
- package/dist/commands/device.js +5 -5
- package/dist/commands/device.js.map +1 -1
- package/dist/commands/publish.d.ts +1 -1
- package/dist/commands/publish.d.ts.map +1 -1
- package/dist/commands/publish.js +24 -26
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/replace-deps.d.ts +3 -3
- package/dist/commands/replace-deps.d.ts.map +1 -1
- package/dist/commands/replace-deps.js +1 -1
- package/dist/commands/typecheck.d.ts +4 -3
- package/dist/commands/typecheck.d.ts.map +1 -1
- package/dist/commands/typecheck.js +5 -11
- package/dist/commands/typecheck.js.map +1 -1
- package/dist/commands/watch.d.ts +9 -9
- package/dist/commands/watch.js +9 -9
- package/dist/electron/electron.d.ts.map +1 -1
- package/dist/electron/electron.js +42 -3
- package/dist/electron/electron.js.map +1 -1
- package/dist/engines/BaseEngine.d.ts +1 -1
- package/dist/engines/BaseEngine.d.ts.map +1 -1
- package/dist/engines/BaseEngine.js +3 -1
- package/dist/engines/BaseEngine.js.map +1 -1
- package/dist/engines/NgtscEngine.d.ts +7 -7
- package/dist/engines/NgtscEngine.d.ts.map +1 -1
- package/dist/engines/NgtscEngine.js +3 -3
- package/dist/engines/ServerEsbuildEngine.d.ts +7 -7
- package/dist/engines/ServerEsbuildEngine.d.ts.map +1 -1
- package/dist/engines/ServerEsbuildEngine.js +3 -3
- package/dist/engines/TscEngine.d.ts +7 -7
- package/dist/engines/TscEngine.d.ts.map +1 -1
- package/dist/engines/TscEngine.js +3 -3
- package/dist/engines/ViteEngine.d.ts +7 -1
- package/dist/engines/ViteEngine.d.ts.map +1 -1
- package/dist/engines/ViteEngine.js +13 -12
- package/dist/engines/ViteEngine.js.map +1 -1
- package/dist/engines/index.d.ts +9 -5
- package/dist/engines/index.d.ts.map +1 -1
- package/dist/engines/index.js +7 -5
- package/dist/engines/index.js.map +1 -1
- package/dist/engines/types.d.ts +20 -20
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/infra/ResultCollector.d.ts +9 -9
- package/dist/infra/ResultCollector.js +8 -8
- package/dist/infra/SignalHandler.d.ts +7 -7
- package/dist/infra/SignalHandler.js +7 -7
- package/dist/infra/WorkerManager.d.ts +14 -14
- package/dist/infra/WorkerManager.js +14 -14
- package/dist/orchestrators/BuildOrchestrator.d.ts +25 -25
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +34 -30
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevWatchOrchestrator.d.ts +7 -7
- package/dist/orchestrators/DevWatchOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/DevWatchOrchestrator.js +34 -34
- package/dist/orchestrators/DevWatchOrchestrator.js.map +1 -1
- package/dist/sd-cli-entry.d.ts +2 -2
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +15 -8
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.d.ts +3 -3
- package/dist/sd-cli.js +16 -16
- package/dist/sd-cli.js.map +1 -1
- package/dist/sd-config.types.d.ts +105 -105
- package/dist/sd-config.types.d.ts.map +1 -1
- package/dist/utils/angular-compiler.js +5 -5
- package/dist/utils/angular-compiler.js.map +1 -1
- package/dist/utils/build-env.d.ts +1 -1
- package/dist/utils/build-env.js +1 -1
- package/dist/utils/concurrency.d.ts +7 -7
- package/dist/utils/concurrency.js +7 -7
- package/dist/utils/copy-public.d.ts +9 -9
- package/dist/utils/copy-public.js +17 -17
- package/dist/utils/copy-public.js.map +1 -1
- package/dist/utils/copy-src.d.ts +9 -9
- package/dist/utils/copy-src.js +11 -11
- package/dist/utils/copy-src.js.map +1 -1
- package/dist/utils/engine-stop.d.ts +8 -9
- package/dist/utils/engine-stop.d.ts.map +1 -1
- package/dist/utils/engine-stop.js +9 -10
- package/dist/utils/engine-stop.js.map +1 -1
- package/dist/utils/esbuild-config.d.ts +23 -23
- package/dist/utils/esbuild-config.d.ts.map +1 -1
- package/dist/utils/esbuild-config.js +25 -25
- package/dist/utils/esbuild-config.js.map +1 -1
- package/dist/utils/lint-with-program.d.ts +15 -15
- package/dist/utils/lint-with-program.d.ts.map +1 -1
- package/dist/utils/lint-with-program.js +29 -29
- package/dist/utils/lint-with-program.js.map +1 -1
- package/dist/utils/ngtsc-build-core.d.ts +8 -8
- package/dist/utils/ngtsc-build-core.d.ts.map +1 -1
- package/dist/utils/ngtsc-build-core.js +14 -14
- package/dist/utils/ngtsc-build-core.js.map +1 -1
- package/dist/utils/output-path-rewriter.d.ts +14 -14
- package/dist/utils/output-path-rewriter.js +18 -18
- package/dist/utils/output-path-rewriter.js.map +1 -1
- package/dist/utils/output-utils.d.ts +6 -6
- package/dist/utils/output-utils.js +11 -11
- package/dist/utils/output-utils.js.map +1 -1
- package/dist/utils/package-utils.d.ts +21 -21
- package/dist/utils/package-utils.d.ts.map +1 -1
- package/dist/utils/package-utils.js +56 -45
- package/dist/utils/package-utils.js.map +1 -1
- package/dist/utils/replace-deps.d.ts +25 -25
- package/dist/utils/replace-deps.d.ts.map +1 -1
- package/dist/utils/replace-deps.js +84 -65
- package/dist/utils/replace-deps.js.map +1 -1
- package/dist/utils/sd-config.d.ts +3 -3
- package/dist/utils/sd-config.js +3 -3
- package/dist/utils/tsc-build.d.ts +13 -13
- package/dist/utils/tsc-build.d.ts.map +1 -1
- package/dist/utils/tsc-build.js +9 -9
- package/dist/utils/tsc-build.js.map +1 -1
- package/dist/utils/tsconfig.d.ts +11 -9
- package/dist/utils/tsconfig.d.ts.map +1 -1
- package/dist/utils/tsconfig.js +11 -9
- package/dist/utils/tsconfig.js.map +1 -1
- package/dist/utils/typecheck-non-package.d.ts +5 -6
- package/dist/utils/typecheck-non-package.d.ts.map +1 -1
- package/dist/utils/typecheck-non-package.js +7 -8
- package/dist/utils/typecheck-non-package.js.map +1 -1
- package/dist/utils/typecheck-serialization.d.ts +8 -8
- package/dist/utils/typecheck-serialization.d.ts.map +1 -1
- package/dist/utils/typecheck-serialization.js +12 -16
- package/dist/utils/typecheck-serialization.js.map +1 -1
- package/dist/utils/vite-config.d.ts +12 -5
- package/dist/utils/vite-config.d.ts.map +1 -1
- package/dist/utils/vite-config.js +95 -41
- package/dist/utils/vite-config.js.map +1 -1
- package/dist/utils/vite-scope-watch-plugin.d.ts.map +1 -1
- package/dist/utils/vite-scope-watch-plugin.js +1 -1
- package/dist/utils/vite-scope-watch-plugin.js.map +1 -1
- package/dist/utils/worker-events.d.ts +12 -12
- package/dist/utils/worker-events.d.ts.map +1 -1
- package/dist/utils/worker-events.js +10 -10
- package/dist/utils/worker-events.js.map +1 -1
- package/dist/utils/worker-utils.d.ts +12 -13
- package/dist/utils/worker-utils.d.ts.map +1 -1
- package/dist/utils/worker-utils.js +12 -13
- package/dist/utils/worker-utils.js.map +1 -1
- package/dist/vitest-plugin.d.ts.map +1 -1
- package/dist/vitest-plugin.js +5 -7
- package/dist/vitest-plugin.js.map +1 -1
- package/dist/workers/client.worker.d.ts +8 -2
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +215 -6
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/library-build.worker.d.ts +1 -1
- package/dist/workers/library-build.worker.d.ts.map +1 -1
- package/dist/workers/library-build.worker.js +7 -7
- package/dist/workers/library-build.worker.js.map +1 -1
- package/dist/workers/lint.worker.d.ts +2 -2
- package/dist/workers/lint.worker.js +2 -2
- package/dist/workers/ngtsc-build.worker.js +30 -30
- package/dist/workers/ngtsc-build.worker.js.map +1 -1
- package/dist/workers/server-build.worker.d.ts +17 -17
- package/dist/workers/server-build.worker.d.ts.map +1 -1
- package/dist/workers/server-build.worker.js +46 -46
- package/dist/workers/server-build.worker.js.map +1 -1
- package/dist/workers/server-runtime.worker.d.ts +7 -7
- package/dist/workers/server-runtime.worker.d.ts.map +1 -1
- package/dist/workers/server-runtime.worker.js +17 -17
- package/dist/workers/server-runtime.worker.js.map +1 -1
- package/docs/config.md +340 -0
- package/docs/publish-configuration-types.md +87 -0
- package/docs/pwa-configuration-types.md +55 -0
- package/docs/vitest-plugin.md +47 -0
- package/package.json +9 -7
- package/src/angular/client-transform-stylesheet.ts +1 -1
- package/src/angular/vite-angular-plugin.ts +89 -39
- package/src/angular/vite-postcss-inline-plugin.ts +1 -1
- package/src/capacitor/capacitor.ts +185 -38
- package/src/commands/build.ts +3 -10
- package/src/commands/check.ts +3 -3
- package/src/commands/dev.ts +3 -9
- package/src/commands/device.ts +5 -5
- package/src/commands/publish.ts +30 -26
- package/src/commands/replace-deps.ts +3 -3
- package/src/commands/typecheck.ts +7 -13
- package/src/commands/watch.ts +9 -9
- package/src/electron/electron.ts +49 -4
- package/src/engines/BaseEngine.ts +4 -1
- package/src/engines/NgtscEngine.ts +7 -7
- package/src/engines/ServerEsbuildEngine.ts +7 -7
- package/src/engines/TscEngine.ts +7 -7
- package/src/engines/ViteEngine.ts +18 -13
- package/src/engines/index.ts +11 -5
- package/src/engines/types.ts +20 -20
- package/src/infra/ResultCollector.ts +9 -9
- package/src/infra/SignalHandler.ts +7 -7
- package/src/infra/WorkerManager.ts +14 -14
- package/src/orchestrators/BuildOrchestrator.ts +42 -38
- package/src/orchestrators/DevWatchOrchestrator.ts +36 -36
- package/src/sd-cli-entry.ts +15 -8
- package/src/sd-cli.ts +16 -16
- package/src/sd-config.types.ts +107 -107
- package/src/utils/angular-compiler.ts +5 -5
- package/src/utils/build-env.ts +1 -1
- package/src/utils/concurrency.ts +7 -7
- package/src/utils/copy-public.ts +17 -17
- package/src/utils/copy-src.ts +11 -11
- package/src/utils/engine-stop.ts +9 -10
- package/src/utils/esbuild-config.ts +29 -29
- package/src/utils/lint-with-program.ts +34 -34
- package/src/utils/ngtsc-build-core.ts +17 -17
- package/src/utils/output-path-rewriter.ts +18 -18
- package/src/utils/output-utils.ts +11 -11
- package/src/utils/package-utils.ts +57 -45
- package/src/utils/replace-deps.ts +92 -67
- package/src/utils/sd-config.ts +3 -3
- package/src/utils/tsc-build.ts +18 -18
- package/src/utils/tsconfig.ts +11 -9
- package/src/utils/typecheck-non-package.ts +7 -8
- package/src/utils/typecheck-serialization.ts +13 -15
- package/src/utils/vite-config.ts +108 -46
- package/src/utils/vite-scope-watch-plugin.ts +6 -1
- package/src/utils/worker-events.ts +16 -16
- package/src/utils/worker-utils.ts +12 -13
- package/src/vitest-plugin.ts +5 -8
- package/src/workers/client.worker.ts +246 -7
- package/src/workers/library-build.worker.ts +8 -8
- package/src/workers/lint.worker.ts +2 -2
- package/src/workers/ngtsc-build.worker.ts +31 -31
- package/src/workers/server-build.worker.ts +60 -60
- package/src/workers/server-runtime.worker.ts +22 -22
- package/tests/angular/vite-angular-plugin-hmr-fallback.spec.ts +1 -0
- package/tests/angular/vite-angular-plugin-hmr.spec.ts +78 -0
- package/tests/angular/vite-angular-plugin.spec.ts +67 -0
- package/tests/capacitor/capacitor-build.spec.ts +93 -11
- package/tests/capacitor/capacitor-icon.spec.ts +7 -5
- package/tests/capacitor/capacitor-init.spec.ts +124 -10
- package/tests/capacitor/capacitor-run.spec.ts +14 -17
- package/tests/capacitor/capacitor-workspace.spec.ts +5 -3
- package/tests/commands/check.spec.ts +2 -2
- package/tests/commands/publish.spec.ts +2 -2
- package/tests/commands/typecheck.spec.ts +8 -0
- package/tests/electron/electron.spec.ts +12 -10
- package/tests/engines/base-engine.spec.ts +37 -0
- package/tests/engines/vite-engine.spec.ts +115 -3
- package/tests/utils/vite-config.spec.ts +162 -90
- package/tests/workers/client-worker.spec.ts +690 -0
- package/tests/workers/server-build-worker.spec.ts +3 -3
package/src/utils/copy-public.ts
CHANGED
|
@@ -6,17 +6,17 @@ import {
|
|
|
6
6
|
} from "@simplysm/core-node";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* public-dev
|
|
9
|
+
* public/ 및 public-dev/ 디렉토리의 파일을 dist/로 복사한다.
|
|
10
|
+
* public-dev/가 public/보다 우선한다 (오버레이).
|
|
11
11
|
*
|
|
12
|
-
* @param pkgDir
|
|
13
|
-
* @param includeDev
|
|
12
|
+
* @param pkgDir 패키지 루트 디렉토리
|
|
13
|
+
* @param includeDev public-dev/ 포함 여부 (dev 모드에서만 true)
|
|
14
14
|
*/
|
|
15
15
|
export async function copyPublicFiles(pkgDir: string, includeDev: boolean): Promise<void> {
|
|
16
16
|
const distDir = pathx.posix(path.join(pkgDir, "dist"));
|
|
17
17
|
await fsx.mkdir(distDir);
|
|
18
18
|
|
|
19
|
-
//
|
|
19
|
+
// public/ 복사
|
|
20
20
|
const publicDir = pathx.posix(path.join(pkgDir, "public"));
|
|
21
21
|
if (await fsx.exists(publicDir)) {
|
|
22
22
|
const files = await fsx.glob("**/*", { cwd: publicDir, absolute: true });
|
|
@@ -30,7 +30,7 @@ export async function copyPublicFiles(pkgDir: string, includeDev: boolean): Prom
|
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
//
|
|
33
|
+
// public-dev/ 복사 (오버레이: public/ 덮어쓰기)
|
|
34
34
|
if (includeDev) {
|
|
35
35
|
const publicDevDir = pathx.posix(path.join(pkgDir, "public-dev"));
|
|
36
36
|
if (await fsx.exists(publicDevDir)) {
|
|
@@ -48,12 +48,12 @@ export async function copyPublicFiles(pkgDir: string, includeDev: boolean): Prom
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
51
|
+
* public/ 및 public-dev/ 디렉토리를 감시하고 변경사항을 실시간으로 dist/에 복사한다.
|
|
52
|
+
* 초기 복사 후 변경/추가/삭제를 자동으로 반영한다.
|
|
53
53
|
*
|
|
54
|
-
* @param pkgDir
|
|
55
|
-
* @param includeDev
|
|
56
|
-
* @returns FsWatcher
|
|
54
|
+
* @param pkgDir 패키지 루트 디렉토리
|
|
55
|
+
* @param includeDev public-dev/ 포함 여부 (dev 모드에서만 true)
|
|
56
|
+
* @returns FsWatcher 인스턴스 (종료 시 close() 호출 필요) 또는 감시 대상이 없으면 undefined
|
|
57
57
|
*/
|
|
58
58
|
export async function watchPublicFiles(
|
|
59
59
|
pkgDir: string,
|
|
@@ -63,10 +63,10 @@ export async function watchPublicFiles(
|
|
|
63
63
|
const publicDir = pathx.posix(path.join(pkgDir, "public"));
|
|
64
64
|
const publicDevDir = pathx.posix(path.join(pkgDir, "public-dev"));
|
|
65
65
|
|
|
66
|
-
//
|
|
66
|
+
// 초기 복사
|
|
67
67
|
await copyPublicFiles(pkgDir, includeDev);
|
|
68
68
|
|
|
69
|
-
//
|
|
69
|
+
// 감시 대상 경로 수집
|
|
70
70
|
const watchPaths: string[] = [];
|
|
71
71
|
if (await fsx.exists(publicDir)) {
|
|
72
72
|
watchPaths.push(pathx.posix(path.join(publicDir, "**/*")));
|
|
@@ -83,7 +83,7 @@ export async function watchPublicFiles(
|
|
|
83
83
|
|
|
84
84
|
watcher.onChange({ delay: 300 }, async (changes) => {
|
|
85
85
|
for (const { event, path: filePath } of changes) {
|
|
86
|
-
//
|
|
86
|
+
// 변경이 발생한 소스 디렉토리 결정
|
|
87
87
|
let sourceDir: string;
|
|
88
88
|
if (pathx.isChildPath(filePath, publicDevDir)) {
|
|
89
89
|
sourceDir = publicDevDir;
|
|
@@ -95,14 +95,14 @@ export async function watchPublicFiles(
|
|
|
95
95
|
const distPath = pathx.posix(path.join(distDir, relPath));
|
|
96
96
|
|
|
97
97
|
if (event === "unlink") {
|
|
98
|
-
//
|
|
98
|
+
// public에서 삭제된 경우, public-dev에 같은 파일이 있으면 삭제하지 않음
|
|
99
99
|
if (sourceDir === publicDir && includeDev) {
|
|
100
100
|
const devOverride = pathx.posix(path.join(publicDevDir, relPath));
|
|
101
101
|
if (await fsx.exists(devOverride)) {
|
|
102
102
|
continue;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
//
|
|
105
|
+
// public-dev에서 삭제된 경우, public에 파일이 있으면 복원 (폴백 복원)
|
|
106
106
|
if (sourceDir === publicDevDir && includeDev) {
|
|
107
107
|
const publicFallback = pathx.posix(path.join(publicDir, relPath));
|
|
108
108
|
if (await fsx.exists(publicFallback)) {
|
|
@@ -113,7 +113,7 @@ export async function watchPublicFiles(
|
|
|
113
113
|
}
|
|
114
114
|
await fsx.rm(distPath);
|
|
115
115
|
} else if (event === "add" || event === "change") {
|
|
116
|
-
//
|
|
116
|
+
// public에서 변경된 경우, public-dev에 같은 파일이 있으면 스킵 (오버레이 우선)
|
|
117
117
|
if (sourceDir === publicDir && includeDev) {
|
|
118
118
|
const devOverride = pathx.posix(path.join(publicDevDir, relPath));
|
|
119
119
|
if (await fsx.exists(devOverride)) {
|
package/src/utils/copy-src.ts
CHANGED
|
@@ -2,11 +2,11 @@ import path from "path";
|
|
|
2
2
|
import { fsx, pathx, FsWatcher } from "@simplysm/core-node";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* glob 패턴에 매칭되는 파일을 src/에서 dist/로 복사한다.
|
|
6
|
+
* 상대 경로가 유지된다: src/a/b.css → dist/a/b.css
|
|
7
7
|
*
|
|
8
|
-
* @param pkgDir
|
|
9
|
-
* @param patterns
|
|
8
|
+
* @param pkgDir 패키지 루트 디렉토리
|
|
9
|
+
* @param patterns glob 패턴 배열 (src/ 기준 상대 경로)
|
|
10
10
|
*/
|
|
11
11
|
export async function copySrcFiles(pkgDir: string, patterns: string[]): Promise<void> {
|
|
12
12
|
const srcDir = pathx.posix(path.join(pkgDir, "src"));
|
|
@@ -26,21 +26,21 @@ export async function copySrcFiles(pkgDir: string, patterns: string[]): Promise<
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
29
|
+
* glob 패턴에 매칭되는 파일을 src/에서 dist/로 감시하며 복사한다.
|
|
30
|
+
* 초기 복사 후 변경, 추가, 삭제를 자동으로 반영한다.
|
|
31
31
|
*
|
|
32
|
-
* @param pkgDir
|
|
33
|
-
* @param patterns
|
|
34
|
-
* @returns FsWatcher
|
|
32
|
+
* @param pkgDir 패키지 루트 디렉토리
|
|
33
|
+
* @param patterns glob 패턴 배열 (src/ 기준 상대 경로)
|
|
34
|
+
* @returns FsWatcher 인스턴스 (종료 시 close() 호출)
|
|
35
35
|
*/
|
|
36
36
|
export async function watchCopySrcFiles(pkgDir: string, patterns: string[]): Promise<FsWatcher> {
|
|
37
37
|
const srcDir = pathx.posix(path.join(pkgDir, "src"));
|
|
38
38
|
const distDir = pathx.posix(path.join(pkgDir, "dist"));
|
|
39
39
|
|
|
40
|
-
//
|
|
40
|
+
// 초기 복사
|
|
41
41
|
await copySrcFiles(pkgDir, patterns);
|
|
42
42
|
|
|
43
|
-
//
|
|
43
|
+
// 감시 시작
|
|
44
44
|
const watchPaths = patterns.map((p) => pathx.posix(path.join(srcDir, p)));
|
|
45
45
|
const watcher = await FsWatcher.watch(watchPaths);
|
|
46
46
|
|
package/src/utils/engine-stop.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 빌드 엔진(BaseEngine, ViteEngine)의 공유 중지 로직.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 엔진 구현체 간 shutdown 타임아웃 + stopWatch 경쟁 + terminate
|
|
5
|
+
* 패턴의 중복을 방지하기 위해 추출하였다.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
const SHUTDOWN_TIMEOUT = 3000;
|
|
@@ -13,14 +13,13 @@ interface StoppableWorker {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
|
-
*
|
|
16
|
+
* 빌드 엔진 워커를 정상적으로 중지한다.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* watch 모드에서는 타임아웃 가드와 함께 `stopWatch()`를 시도하여
|
|
19
|
+
* 멈춘 워커가 종료를 차단하지 않도록 한다. 이후 워커를 무조건 종료한다.
|
|
20
20
|
*
|
|
21
|
-
* @param worker -
|
|
22
|
-
* @param isWatchMode -
|
|
23
|
-
* @returns A cleanup function that nullifies the caller's worker reference
|
|
21
|
+
* @param worker - 중지할 워커 프록시 (시작하지 않았으면 undefined)
|
|
22
|
+
* @param isWatchMode - watch 모드 여부
|
|
24
23
|
*/
|
|
25
24
|
export async function stopEngineWorker(
|
|
26
25
|
worker: StoppableWorker | undefined,
|
|
@@ -33,7 +32,7 @@ export async function stopEngineWorker(
|
|
|
33
32
|
new Promise<void>((resolve) => setTimeout(resolve, SHUTDOWN_TIMEOUT)),
|
|
34
33
|
]);
|
|
35
34
|
} catch {
|
|
36
|
-
//
|
|
35
|
+
// stopWatch 실패해도 계속 진행
|
|
37
36
|
}
|
|
38
37
|
}
|
|
39
38
|
|
|
@@ -8,11 +8,11 @@ import { consola } from "consola";
|
|
|
8
8
|
const logger = consola.withTag("sd:cli:esbuild-config");
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* esbuild outputFiles에서 변경된 파일만 디스크에 쓴다.
|
|
12
12
|
*
|
|
13
|
-
* - .js
|
|
14
|
-
* -
|
|
15
|
-
* -
|
|
13
|
+
* - .js 파일: 비교 전 ESM 상대 import 경로에 .js 확장자를 추가한다
|
|
14
|
+
* - 기타 파일(.js.map 등): 원본 내용을 그대로 비교한다
|
|
15
|
+
* - 기존 파일과 내용이 동일하면 타임스탬프 보존을 위해 쓰기를 스킵한다
|
|
16
16
|
*/
|
|
17
17
|
export async function writeChangedOutputFiles(outputFiles: esbuild.OutputFile[]): Promise<boolean> {
|
|
18
18
|
logger.debug(`변경된 출력 파일 쓰기 시작 (${outputFiles.length}개)`);
|
|
@@ -33,7 +33,7 @@ export async function writeChangedOutputFiles(outputFiles: esbuild.OutputFile[])
|
|
|
33
33
|
const existing = await fs.readFile(file.path, "utf-8");
|
|
34
34
|
if (existing === finalText) return;
|
|
35
35
|
} catch {
|
|
36
|
-
//
|
|
36
|
+
// 파일이 아직 존재하지 않음
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
hasChanges = true;
|
|
@@ -46,23 +46,23 @@ export async function writeChangedOutputFiles(outputFiles: esbuild.OutputFile[])
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
*
|
|
50
|
-
* - bundle: true (
|
|
49
|
+
* Server 빌드용 esbuild 옵션
|
|
50
|
+
* - bundle: true (모든 의존성을 포함한 단일 번들)
|
|
51
51
|
*/
|
|
52
52
|
export interface ServerEsbuildOptions {
|
|
53
53
|
pkgDir: string;
|
|
54
54
|
entryPoints: string[];
|
|
55
55
|
env?: Record<string, string>;
|
|
56
|
-
/**
|
|
56
|
+
/** 번들에서 제외할 외부 모듈 */
|
|
57
57
|
external?: string[];
|
|
58
|
-
/**
|
|
58
|
+
/** dev 모드: 빠른 빌드를 위해 minification 스킵 */
|
|
59
59
|
dev?: boolean;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
* 런타임에 환경변수를 process.env에 병합하는 JS 배너 스니펫을 생성한다.
|
|
64
|
+
* ??=를 사용하여 런타임 ENV(예: `DEV=false node server.js`)가
|
|
65
|
+
* 빌드 타임 기본값보다 우선하도록 한다.
|
|
66
66
|
*/
|
|
67
67
|
export function createEnvBanner(env?: Record<string, string>): string {
|
|
68
68
|
if (env == null || Object.keys(env).length === 0) return "";
|
|
@@ -70,12 +70,12 @@ export function createEnvBanner(env?: Record<string, string>): string {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
/**
|
|
73
|
-
*
|
|
73
|
+
* Server 빌드용 esbuild 설정을 생성한다.
|
|
74
74
|
*
|
|
75
|
-
*
|
|
76
|
-
* - bundle: true (
|
|
77
|
-
* - minify: true (
|
|
78
|
-
* - banner:
|
|
75
|
+
* server 패키지 빌드에 사용한다.
|
|
76
|
+
* - bundle: true (모든 의존성을 포함한 단일 번들)
|
|
77
|
+
* - minify: true (코드 보호를 위한 minify)
|
|
78
|
+
* - banner: CJS 패키지 require() 지원을 위한 createRequire shim + 환경변수 주입
|
|
79
79
|
*/
|
|
80
80
|
export function createServerEsbuildOptions(options: ServerEsbuildOptions): esbuild.BuildOptions {
|
|
81
81
|
const envBanner = createEnvBanner(options.env);
|
|
@@ -107,7 +107,7 @@ interface PkgJson {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
110
|
+
* 의존성 트리를 재귀적으로 스캔하고 predicate 기반으로 externals를 수집한다.
|
|
111
111
|
*/
|
|
112
112
|
function scanDependencyTree(
|
|
113
113
|
pkgName: string,
|
|
@@ -132,13 +132,13 @@ function scanDependencyTree(
|
|
|
132
132
|
const depDir = path.dirname(pkgJsonPath);
|
|
133
133
|
const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf-8")) as PkgJson;
|
|
134
134
|
|
|
135
|
-
//
|
|
135
|
+
// predicate에 의해 external로 표시된 패키지 수집
|
|
136
136
|
const toExternal = collector(pkgName, depDir, pkgJson);
|
|
137
137
|
for (const name of toExternal) {
|
|
138
138
|
external.add(name);
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
//
|
|
141
|
+
// 하위 의존성 재귀 탐색
|
|
142
142
|
const subDeps = Object.keys(pkgJson.dependencies ?? {});
|
|
143
143
|
if (subDeps.length > 0) {
|
|
144
144
|
logger.debug(
|
|
@@ -151,7 +151,7 @@ function scanDependencyTree(
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
/**
|
|
154
|
-
*
|
|
154
|
+
* 단일 트리 탐색으로 미설치 optional peer deps와 네이티브 모듈을 모두 수집한다.
|
|
155
155
|
*/
|
|
156
156
|
export function collectAllDependencyExternals(pkgDir: string): {
|
|
157
157
|
optionalPeerDeps: string[];
|
|
@@ -178,7 +178,7 @@ export function collectAllDependencyExternals(pkgDir: string): {
|
|
|
178
178
|
(pkgName, depDir, depPkgJson) => {
|
|
179
179
|
const found: string[] = [];
|
|
180
180
|
|
|
181
|
-
// Optional peer deps
|
|
181
|
+
// Optional peer deps 확인
|
|
182
182
|
if (depPkgJson.peerDependenciesMeta != null) {
|
|
183
183
|
const peerDeps = depPkgJson.peerDependencies ?? {};
|
|
184
184
|
const depReq = createRequire(path.join(depDir, "noop.js"));
|
|
@@ -193,7 +193,7 @@ export function collectAllDependencyExternals(pkgDir: string): {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
|
|
196
|
-
//
|
|
196
|
+
// 네이티브 모듈 확인
|
|
197
197
|
if (existsSync(path.join(depDir, "binding.gyp"))) {
|
|
198
198
|
nativeModules.add(pkgName);
|
|
199
199
|
}
|
|
@@ -215,10 +215,10 @@ export function collectAllDependencyExternals(pkgDir: string): {
|
|
|
215
215
|
}
|
|
216
216
|
|
|
217
217
|
/**
|
|
218
|
-
*
|
|
218
|
+
* 의존성 트리에서 미설치 optional peer deps를 수집한다.
|
|
219
219
|
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
220
|
+
* server 빌드(bundle: true)에서 미설치 optional peer dependencies를
|
|
221
|
+
* esbuild externals로 지정하여 빌드 실패를 방지한다.
|
|
222
222
|
*/
|
|
223
223
|
export function collectUninstalledOptionalPeerDeps(pkgDir: string): string[] {
|
|
224
224
|
return collectAllDependencyExternals(pkgDir).optionalPeerDeps;
|
|
@@ -229,10 +229,10 @@ export function collectUninstalledOptionalPeerDeps(pkgDir: string): string[] {
|
|
|
229
229
|
//#region Native Module Externals
|
|
230
230
|
|
|
231
231
|
/**
|
|
232
|
-
*
|
|
232
|
+
* 의존성에서 binding.gyp가 있는 네이티브 모듈을 수집한다.
|
|
233
233
|
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
234
|
+
* node-gyp로 빌드된 네이티브 모듈은 esbuild로 번들링할 수 없으므로
|
|
235
|
+
* externals로 지정해야 한다.
|
|
236
236
|
*/
|
|
237
237
|
export function collectNativeModuleExternals(pkgDir: string): string[] {
|
|
238
238
|
return collectAllDependencyExternals(pkgDir).nativeModules;
|
|
@@ -7,7 +7,7 @@ import { consola } from "consola";
|
|
|
7
7
|
const logger = consola.withTag("sd:cli:lint-with-program");
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* LintWithProgramRunner.lint()가 반환하는 lint 결과
|
|
11
11
|
*/
|
|
12
12
|
export interface LintWithProgramResult {
|
|
13
13
|
success: boolean;
|
|
@@ -17,7 +17,7 @@ export interface LintWithProgramResult {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* LintWithProgramRunner 생성자 옵션
|
|
21
21
|
*/
|
|
22
22
|
export interface LintWithProgramRunnerOptions {
|
|
23
23
|
cwd: string;
|
|
@@ -25,22 +25,22 @@ export interface LintWithProgramRunnerOptions {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* LintWithProgramRunner.lint() 옵션
|
|
29
29
|
*/
|
|
30
30
|
export interface LintRunOptions {
|
|
31
31
|
program: ts.Program;
|
|
32
|
-
/**
|
|
33
|
-
*
|
|
32
|
+
/** 제공 시 이 집합의 파일만 lint한다 (추출된 파일과의 교집합).
|
|
33
|
+
* watch 재빌드에서 affected 파일 기반 증분 lint에 사용한다. */
|
|
34
34
|
affectedFiles?: ReadonlySet<string>;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* 기존 ts.Program을 사용하여 ESLint를 실행한다 (중복 Program 생성을 방지).
|
|
39
39
|
*
|
|
40
|
-
* -
|
|
41
|
-
* -
|
|
42
|
-
* -
|
|
43
|
-
* -
|
|
40
|
+
* - program.getSourceFiles()에서 pkgDir로 필터링하여 소스 파일을 추출한다
|
|
41
|
+
* - .d.ts 파일과 node_modules 경로를 제외한다
|
|
42
|
+
* - parserOptions.programs를 통해 ts.Program을 주입한다 (typescript-eslint)
|
|
43
|
+
* - 호출 간 ESLint 인스턴스를 재사용한다 (watch 모드 최적화)
|
|
44
44
|
*/
|
|
45
45
|
export class LintWithProgramRunner {
|
|
46
46
|
private readonly _cwd: string;
|
|
@@ -55,8 +55,8 @@ export class LintWithProgramRunner {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
58
|
+
* ts.Program에서 lint 대상 파일을 추출한다.
|
|
59
|
+
* 모든 워크스페이스 소스 파일(cwd 범위)을 포함하고 .d.ts, node_modules, Angular shim을 제외한다.
|
|
60
60
|
*/
|
|
61
61
|
private _extractFiles(program: ts.Program): string[] {
|
|
62
62
|
logger.debug(`[${this._pkgName}] 린트 대상 파일 추출 시작`);
|
|
@@ -66,22 +66,22 @@ export class LintWithProgramRunner {
|
|
|
66
66
|
for (const sf of program.getSourceFiles()) {
|
|
67
67
|
const fileName = pathx.posix(sf.fileName);
|
|
68
68
|
|
|
69
|
-
//
|
|
69
|
+
// 워크스페이스 루트 내에 있어야 함
|
|
70
70
|
if (!fileName.startsWith(normalizedCwd + "/")) {
|
|
71
71
|
continue;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
//
|
|
74
|
+
// 선언 파일 제외
|
|
75
75
|
if (sf.isDeclarationFile) {
|
|
76
76
|
continue;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
//
|
|
79
|
+
// node_modules 제외
|
|
80
80
|
if (fileName.includes("/node_modules/")) {
|
|
81
81
|
continue;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
//
|
|
84
|
+
// Angular 타입체크 shim 파일 제외 (가상 파일, 디스크에 없음)
|
|
85
85
|
if (fileName.endsWith(".ngtypecheck.ts")) {
|
|
86
86
|
continue;
|
|
87
87
|
}
|
|
@@ -94,17 +94,17 @@ export class LintWithProgramRunner {
|
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
97
|
+
* 주어진 ts.Program의 파일에 대해 ESLint를 실행한다.
|
|
98
|
+
* affectedFiles가 제공되면 교집합만 lint한다 (watch 재빌드).
|
|
99
|
+
* 첫 호출 시 ESLint 인스턴스를 생성하고, 이후 호출에서 재사용한다.
|
|
100
100
|
*/
|
|
101
101
|
async lint(options: LintRunOptions): Promise<LintWithProgramResult> {
|
|
102
102
|
const { program, affectedFiles } = options;
|
|
103
103
|
|
|
104
|
-
//
|
|
104
|
+
// 대상 파일 추출 (워크스페이스 범위)
|
|
105
105
|
let files = this._extractFiles(program);
|
|
106
106
|
|
|
107
|
-
//
|
|
107
|
+
// affectedFiles가 제공되면 추출된 파일과 교집합
|
|
108
108
|
if (affectedFiles != null) {
|
|
109
109
|
files = files.filter((f) => affectedFiles.has(pathx.posix(f)));
|
|
110
110
|
}
|
|
@@ -118,23 +118,23 @@ export class LintWithProgramRunner {
|
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
//
|
|
121
|
+
// programs 참조 업데이트 (가변 배열 — ESLint가 lintFiles 시 읽음)
|
|
122
122
|
this._programsRef.length = 0;
|
|
123
123
|
this._programsRef.push(program);
|
|
124
124
|
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
//
|
|
125
|
+
// 캐시 정책: affected 파일 기반 증분 lint가 ESLint의
|
|
126
|
+
// 파일 내용 기반 캐시(의존성 변경을 놓침)보다 정확하다.
|
|
127
|
+
// affectedFiles가 제공되면 (watch 재빌드) 캐시를 비활성화한다.
|
|
128
|
+
// 제공되지 않으면 (일회성 빌드) 성능을 위해 캐시를 활성화한다.
|
|
129
129
|
const useCache = affectedFiles == null;
|
|
130
130
|
|
|
131
|
-
//
|
|
131
|
+
// 캐시 정책이 변경되거나 첫 호출 시 새 ESLint 인스턴스 생성
|
|
132
132
|
if (this._eslint == null || this._lastUseCache !== useCache) {
|
|
133
133
|
logger.debug(`[${this._pkgName}] ESLint 인스턴스 생성 (cache: ${String(useCache)})`);
|
|
134
|
-
// ESLint Flat Config
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
//
|
|
134
|
+
// ESLint Flat Config는 languageOptionsToJSON()을 통해 languageOptions를 직렬화하는데,
|
|
135
|
+
// parserOptions를 재귀 탐색하면서 ts.Program 메서드에서 예외가 발생한다.
|
|
136
|
+
// parserOptions에 toJSON()을 추가하여 직렬화 가능한 표현을 반환하면서
|
|
137
|
+
// typescript-eslint가 실제 programs 배열에 접근할 수 있도록 한다.
|
|
138
138
|
const parserOptions = {
|
|
139
139
|
programs: this._programsRef,
|
|
140
140
|
project: null,
|
|
@@ -157,11 +157,11 @@ export class LintWithProgramRunner {
|
|
|
157
157
|
this._lastUseCache = useCache;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
-
//
|
|
160
|
+
// lint 실행
|
|
161
161
|
logger.debug(`[${this._pkgName}] 린트 시작 (${files.length}개 파일, affected: ${affectedFiles != null})`);
|
|
162
162
|
const results = await this._eslint.lintFiles(files);
|
|
163
163
|
|
|
164
|
-
//
|
|
164
|
+
// 결과 집계
|
|
165
165
|
let errorCount = 0;
|
|
166
166
|
let warningCount = 0;
|
|
167
167
|
for (const r of results) {
|
|
@@ -169,7 +169,7 @@ export class LintWithProgramRunner {
|
|
|
169
169
|
warningCount += r.warningCount;
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
//
|
|
172
|
+
// 출력 포맷팅
|
|
173
173
|
const formatter = await this._eslint.loadFormatter("stylish");
|
|
174
174
|
const formattedOutput = await formatter.format(results);
|
|
175
175
|
|
|
@@ -29,9 +29,9 @@ export interface NgtscBuildInfo {
|
|
|
29
29
|
cwd: string;
|
|
30
30
|
pkgDir: string;
|
|
31
31
|
output: BuildOutput;
|
|
32
|
-
/**
|
|
32
|
+
/** 타입체크 환경. 설정 시 getCompilerOptionsForEnv()로 compilerOptions를 조정한다. */
|
|
33
33
|
env?: TypecheckEnv;
|
|
34
|
-
/**
|
|
34
|
+
/** sd.config.ts의 replaceDeps 설정 */
|
|
35
35
|
replaceDeps?: Record<string, string>;
|
|
36
36
|
}
|
|
37
37
|
|
|
@@ -40,7 +40,7 @@ export interface NgtscBuildResult {
|
|
|
40
40
|
lint?: LintWithProgramResult;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
/** runNgtscBuild 내부 반환 타입. program은 워커 내에서 lint 용도로만
|
|
43
|
+
/** runNgtscBuild 내부 반환 타입. program은 워커 내에서 lint 용도로만 사용한다. */
|
|
44
44
|
export interface NgtscBuildInternalResult extends NgtscBuildResult {
|
|
45
45
|
program?: ts.Program;
|
|
46
46
|
}
|
|
@@ -83,7 +83,7 @@ export function buildCompilerOptions(
|
|
|
83
83
|
options.emitDeclarationOnly = true;
|
|
84
84
|
options.declarationDir = path.join(pkgDir, "dist");
|
|
85
85
|
} else {
|
|
86
|
-
//
|
|
86
|
+
// 둘 다 false — 타입체크만 수행
|
|
87
87
|
options.noEmit = true;
|
|
88
88
|
options.declaration = false;
|
|
89
89
|
options.declarationMap = false;
|
|
@@ -199,12 +199,12 @@ export function writeEmitResults(
|
|
|
199
199
|
if (rewrite == null) continue;
|
|
200
200
|
let [newPath, newContent] = rewrite;
|
|
201
201
|
|
|
202
|
-
//
|
|
202
|
+
// .js 파일 내 side-effect SCSS import 처리
|
|
203
203
|
if (scss != null && newPath.endsWith(".js")) {
|
|
204
204
|
const { text, scssImports } = rewriteScssImports(newContent);
|
|
205
205
|
newContent = text;
|
|
206
206
|
|
|
207
|
-
//
|
|
207
|
+
// 새 항목 등록 전에 이 소스 파일의 기존 레지스트리 항목 제거
|
|
208
208
|
if (scss.registry != null && sourceFileName != null) {
|
|
209
209
|
for (const [key, entry] of scss.registry) {
|
|
210
210
|
if (entry.sourceFileName === sourceFileName) {
|
|
@@ -222,7 +222,7 @@ export function writeEmitResults(
|
|
|
222
222
|
const cssFileName = scssImport.replace(/\.scss$/, ".css");
|
|
223
223
|
const cssAbsPath = path.resolve(outputDir, cssFileName);
|
|
224
224
|
|
|
225
|
-
//
|
|
225
|
+
// 레지스트리가 제공된 경우 등록 (scssAbsPath를 키로 사용하여 중복 방지)
|
|
226
226
|
if (scss.registry != null) {
|
|
227
227
|
scss.registry.set(scssAbsPath, { scssAbsPath, cssAbsPath, sourceFileName });
|
|
228
228
|
}
|
|
@@ -248,9 +248,9 @@ export function writeEmitResults(
|
|
|
248
248
|
//#region Side-effect SCSS
|
|
249
249
|
|
|
250
250
|
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
251
|
+
* 레지스트리의 모든 side-effect SCSS 항목을 CSS로 컴파일한다.
|
|
252
|
+
* compileGlobalScss와 동일한 패턴 — 항상 모든 항목을 재컴파일한다.
|
|
253
|
+
* 에러 발생 시 scssErrors에 추가하고 기존 CSS 파일을 보존한다.
|
|
254
254
|
*/
|
|
255
255
|
export function compileSideEffectScss(
|
|
256
256
|
registry: ReadonlyMap<string, SideEffectScssEntry>,
|
|
@@ -300,8 +300,8 @@ export function compileGlobalScss(
|
|
|
300
300
|
//#endregion
|
|
301
301
|
|
|
302
302
|
/**
|
|
303
|
-
*
|
|
304
|
-
* (
|
|
303
|
+
* AngularCompiler를 사용한 전체 Angular 라이브러리 빌드를 수행한다.
|
|
304
|
+
* (파싱, 초기화, 진단, emit, global SCSS)
|
|
305
305
|
*/
|
|
306
306
|
export async function runNgtscBuild(info: NgtscBuildInfo): Promise<NgtscBuildInternalResult> {
|
|
307
307
|
try {
|
|
@@ -328,7 +328,7 @@ export async function runNgtscBuild(info: NgtscBuildInfo): Promise<NgtscBuildInt
|
|
|
328
328
|
const scssDependencies = new Map<string, Set<string>>();
|
|
329
329
|
const loadPaths = buildScssLoadPaths(info);
|
|
330
330
|
|
|
331
|
-
//
|
|
331
|
+
// AngularCompiler 생성
|
|
332
332
|
logger.debug(`[${info.name}] AngularCompiler 생성 중...`);
|
|
333
333
|
const compiler = new AngularCompiler({
|
|
334
334
|
rootNames: sourceFiles,
|
|
@@ -337,12 +337,12 @@ export async function runNgtscBuild(info: NgtscBuildInfo): Promise<NgtscBuildInt
|
|
|
337
337
|
transformStylesheet: createLibraryTransformStylesheet(loadPaths, scssErrors, scssDependencies),
|
|
338
338
|
});
|
|
339
339
|
|
|
340
|
-
//
|
|
340
|
+
// 초기화 (프로그램 생성, AOT 분석, affected 파일 탐색)
|
|
341
341
|
logger.debug(`[${info.name}] AngularCompiler 초기화 중...`);
|
|
342
342
|
await compiler.initialize();
|
|
343
343
|
logger.debug(`[${info.name}] AngularCompiler 초기화 완료`);
|
|
344
344
|
|
|
345
|
-
//
|
|
345
|
+
// 진단 수집 — workspace 스코프 (패키지 단위 필터링 없음)
|
|
346
346
|
const allDiagnostics = [...compiler.collectDiagnostics()].filter(
|
|
347
347
|
(d) => isWorkspaceDiagnostic(d, info.cwd),
|
|
348
348
|
);
|
|
@@ -357,7 +357,7 @@ export async function runNgtscBuild(info: NgtscBuildInfo): Promise<NgtscBuildInt
|
|
|
357
357
|
.filter((d) => d.category === ts.DiagnosticCategory.Error)
|
|
358
358
|
.map(formatDiagnosticError);
|
|
359
359
|
|
|
360
|
-
//
|
|
360
|
+
// AngularCompiler를 통한 emit + output-path-rewriting
|
|
361
361
|
const emitResults = compiler.emitAffectedFiles({
|
|
362
362
|
sourceFilter: (fileName: string) =>
|
|
363
363
|
pathx.posix(fileName).startsWith(normalizedSrcDir + "/"),
|
|
@@ -368,7 +368,7 @@ export async function runNgtscBuild(info: NgtscBuildInfo): Promise<NgtscBuildInt
|
|
|
368
368
|
scssDependencies,
|
|
369
369
|
});
|
|
370
370
|
|
|
371
|
-
// Global SCSS
|
|
371
|
+
// Global SCSS 컴파일
|
|
372
372
|
const globalScssErrors = compileGlobalScss(info.pkgDir, loadPaths);
|
|
373
373
|
|
|
374
374
|
const allErrors = [...errors, ...scssErrors, ...globalScssErrors];
|