@simplysm/sd-cli 14.0.42 → 14.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular/angular-compiler.d.ts +0 -35
- package/dist/angular/angular-compiler.d.ts.map +1 -1
- package/dist/angular/angular-compiler.js +0 -374
- package/dist/angular/angular-compiler.js.map +1 -1
- package/dist/angular/hmr-candidates.d.ts +13 -0
- package/dist/angular/hmr-candidates.d.ts.map +1 -0
- package/dist/angular/hmr-candidates.js +230 -0
- package/dist/angular/hmr-candidates.js.map +1 -0
- package/dist/angular/ngtsc-build-core.d.ts +41 -37
- package/dist/angular/ngtsc-build-core.d.ts.map +1 -1
- package/dist/angular/ngtsc-build-core.js +155 -52
- package/dist/angular/ngtsc-build-core.js.map +1 -1
- package/dist/angular/vite-angular-plugin.d.ts +1 -1
- package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
- package/dist/angular/vite-angular-plugin.js +63 -56
- package/dist/angular/vite-angular-plugin.js.map +1 -1
- package/dist/angular/web-worker-transformer.d.ts +9 -0
- package/dist/angular/web-worker-transformer.d.ts.map +1 -0
- package/dist/angular/web-worker-transformer.js +73 -0
- package/dist/angular/web-worker-transformer.js.map +1 -0
- package/dist/capacitor/capacitor.d.ts.map +1 -1
- package/dist/capacitor/capacitor.js +6 -4
- package/dist/capacitor/capacitor.js.map +1 -1
- package/dist/commands/check.d.ts +1 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +15 -65
- package/dist/commands/check.js.map +1 -1
- package/dist/commands/publish/deployment-phase.d.ts.map +1 -1
- package/dist/commands/publish/deployment-phase.js +13 -5
- package/dist/commands/publish/deployment-phase.js.map +1 -1
- package/dist/commands/publish/npm-publisher.js +1 -1
- package/dist/commands/publish/npm-publisher.js.map +1 -1
- package/dist/commands/publish/publish-command.js +1 -1
- package/dist/commands/publish/publish-command.js.map +1 -1
- package/dist/commands/publish/version-upgrade.d.ts.map +1 -1
- package/dist/commands/publish/version-upgrade.js +16 -13
- package/dist/commands/publish/version-upgrade.js.map +1 -1
- package/dist/commands/replace-deps.d.ts.map +1 -1
- package/dist/commands/replace-deps.js +2 -1
- package/dist/commands/replace-deps.js.map +1 -1
- package/dist/deps/replace-deps/collect-deps.d.ts.map +1 -1
- package/dist/deps/replace-deps/collect-deps.js +5 -2
- package/dist/deps/replace-deps/collect-deps.js.map +1 -1
- package/dist/deps/replace-deps/replace-deps-resolve.d.ts.map +1 -1
- package/dist/deps/replace-deps/replace-deps-resolve.js +6 -7
- package/dist/deps/replace-deps/replace-deps-resolve.js.map +1 -1
- package/dist/deps/replace-deps/replace-deps.d.ts +21 -3
- package/dist/deps/replace-deps/replace-deps.d.ts.map +1 -1
- package/dist/deps/replace-deps/replace-deps.js +175 -66
- package/dist/deps/replace-deps/replace-deps.js.map +1 -1
- package/dist/electron/electron.js +7 -7
- package/dist/electron/electron.js.map +1 -1
- package/dist/engines/BaseEngine.d.ts.map +1 -1
- package/dist/engines/BaseEngine.js +2 -5
- package/dist/engines/BaseEngine.js.map +1 -1
- package/dist/engines/EsbuildClientEngine.d.ts.map +1 -1
- package/dist/engines/EsbuildClientEngine.js +16 -9
- package/dist/engines/EsbuildClientEngine.js.map +1 -1
- package/dist/engines/NgtscEngine.d.ts +4 -4
- package/dist/engines/NgtscEngine.d.ts.map +1 -1
- package/dist/engines/NgtscEngine.js +5 -5
- package/dist/engines/NgtscEngine.js.map +1 -1
- package/dist/engines/TscEngine.d.ts.map +1 -1
- package/dist/engines/TscEngine.js +0 -2
- package/dist/engines/TscEngine.js.map +1 -1
- package/dist/engines/types.d.ts +2 -0
- package/dist/engines/types.d.ts.map +1 -1
- package/dist/esbuild/esbuild-angular-compiler-plugin.d.ts +36 -0
- package/dist/esbuild/esbuild-angular-compiler-plugin.d.ts.map +1 -0
- package/dist/esbuild/esbuild-angular-compiler-plugin.js +464 -0
- package/dist/esbuild/esbuild-angular-compiler-plugin.js.map +1 -0
- package/dist/esbuild/esbuild-client-config.d.ts +8 -2
- package/dist/esbuild/esbuild-client-config.d.ts.map +1 -1
- package/dist/esbuild/esbuild-client-config.js +48 -33
- package/dist/esbuild/esbuild-client-config.js.map +1 -1
- package/dist/esbuild/esbuild-postcss-plugin.d.ts.map +1 -1
- package/dist/esbuild/esbuild-postcss-plugin.js +9 -6
- package/dist/esbuild/esbuild-postcss-plugin.js.map +1 -1
- package/dist/esbuild/esbuild-tsc-plugin.d.ts +4 -1
- package/dist/esbuild/esbuild-tsc-plugin.d.ts.map +1 -1
- package/dist/esbuild/esbuild-tsc-plugin.js +27 -23
- package/dist/esbuild/esbuild-tsc-plugin.js.map +1 -1
- package/dist/esbuild/file-reference-tracker.d.ts +24 -0
- package/dist/esbuild/file-reference-tracker.d.ts.map +1 -0
- package/dist/esbuild/file-reference-tracker.js +57 -0
- package/dist/esbuild/file-reference-tracker.js.map +1 -0
- package/dist/esbuild/lmdb-cache-store.d.ts +18 -0
- package/dist/esbuild/lmdb-cache-store.d.ts.map +1 -0
- package/dist/esbuild/lmdb-cache-store.js +41 -0
- package/dist/esbuild/lmdb-cache-store.js.map +1 -0
- package/dist/esbuild/load-result-cache.d.ts +17 -0
- package/dist/esbuild/load-result-cache.d.ts.map +1 -0
- package/dist/esbuild/load-result-cache.js +61 -0
- package/dist/esbuild/load-result-cache.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lint/lint-core.js +7 -7
- package/dist/lint/lint-core.js.map +1 -1
- package/dist/orchestrators/BaseOrchestrator.js +2 -2
- package/dist/orchestrators/BaseOrchestrator.js.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
- package/dist/orchestrators/BuildOrchestrator.js +5 -19
- package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
- package/dist/orchestrators/DevOrchestrator.js +5 -5
- package/dist/orchestrators/DevOrchestrator.js.map +1 -1
- package/dist/orchestrators/WatchOrchestrator.js +6 -6
- package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
- package/dist/runtime/ResultCollector.d.ts +1 -0
- package/dist/runtime/ResultCollector.d.ts.map +1 -1
- package/dist/runtime/ResultCollector.js.map +1 -1
- package/dist/runtime/engine-watch-events.d.ts.map +1 -1
- package/dist/runtime/engine-watch-events.js +3 -0
- package/dist/runtime/engine-watch-events.js.map +1 -1
- package/dist/runtime/rebuild-manager.js +1 -1
- package/dist/runtime/rebuild-manager.js.map +1 -1
- package/dist/runtime/worker-utils.js +1 -1
- package/dist/runtime/worker-utils.js.map +1 -1
- package/dist/sd-cli-entry.d.ts.map +1 -1
- package/dist/sd-cli-entry.js +4 -3
- package/dist/sd-cli-entry.js.map +1 -1
- package/dist/sd-cli.js +3 -3
- package/dist/sd-cli.js.map +1 -1
- package/dist/ts-compiler/SdTsCompiler.d.ts +39 -0
- package/dist/ts-compiler/SdTsCompiler.d.ts.map +1 -0
- package/dist/ts-compiler/SdTsCompiler.js +593 -0
- package/dist/ts-compiler/SdTsCompiler.js.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-options.d.ts +40 -0
- package/dist/ts-compiler/sd-ts-compiler-options.d.ts.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-options.js +2 -0
- package/dist/ts-compiler/sd-ts-compiler-options.js.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-result.d.ts +34 -0
- package/dist/ts-compiler/sd-ts-compiler-result.d.ts.map +1 -0
- package/dist/ts-compiler/sd-ts-compiler-result.js +2 -0
- package/dist/ts-compiler/sd-ts-compiler-result.js.map +1 -0
- package/dist/utils/copy-public.d.ts +6 -4
- package/dist/utils/copy-public.d.ts.map +1 -1
- package/dist/utils/copy-public.js +9 -7
- package/dist/utils/copy-public.js.map +1 -1
- package/dist/utils/diagnostic-utils.d.ts +2 -3
- package/dist/utils/diagnostic-utils.d.ts.map +1 -1
- package/dist/utils/diagnostic-utils.js +8 -9
- package/dist/utils/diagnostic-utils.js.map +1 -1
- package/dist/utils/output-utils.d.ts +8 -2
- package/dist/utils/output-utils.d.ts.map +1 -1
- package/dist/utils/output-utils.js +32 -8
- package/dist/utils/output-utils.js.map +1 -1
- package/dist/workers/client.worker.d.ts +1 -1
- package/dist/workers/client.worker.d.ts.map +1 -1
- package/dist/workers/client.worker.js +115 -110
- package/dist/workers/client.worker.js.map +1 -1
- package/dist/workers/incremental-mtime-tracker.d.ts +13 -0
- package/dist/workers/incremental-mtime-tracker.d.ts.map +1 -0
- package/dist/workers/incremental-mtime-tracker.js +65 -0
- package/dist/workers/incremental-mtime-tracker.js.map +1 -0
- package/dist/workers/library-build.worker.d.ts +0 -2
- package/dist/workers/library-build.worker.d.ts.map +1 -1
- package/dist/workers/library-build.worker.js +169 -70
- package/dist/workers/library-build.worker.js.map +1 -1
- package/dist/workers/server-build.worker.d.ts.map +1 -1
- package/dist/workers/server-build.worker.js +30 -57
- package/dist/workers/server-build.worker.js.map +1 -1
- package/dist/workers/server-esbuild-context.d.ts +7 -0
- package/dist/workers/server-esbuild-context.d.ts.map +1 -1
- package/dist/workers/server-esbuild-context.js +11 -2
- package/dist/workers/server-esbuild-context.js.map +1 -1
- package/package.json +5 -4
- package/src/angular/angular-compiler.ts +0 -502
- package/src/angular/hmr-candidates.ts +295 -0
- package/src/angular/ngtsc-build-core.ts +192 -91
- package/src/angular/vite-angular-plugin.ts +71 -65
- package/src/angular/web-worker-transformer.ts +117 -0
- package/src/capacitor/capacitor.ts +6 -4
- package/src/commands/check.ts +17 -76
- package/src/commands/publish/deployment-phase.ts +11 -7
- package/src/commands/publish/npm-publisher.ts +1 -1
- package/src/commands/publish/publish-command.ts +1 -1
- package/src/commands/publish/version-upgrade.ts +44 -35
- package/src/commands/replace-deps.ts +3 -1
- package/src/deps/replace-deps/collect-deps.ts +4 -2
- package/src/deps/replace-deps/replace-deps-resolve.ts +12 -7
- package/src/deps/replace-deps/replace-deps.ts +191 -69
- package/src/electron/electron.ts +7 -7
- package/src/engines/BaseEngine.ts +2 -6
- package/src/engines/EsbuildClientEngine.ts +16 -10
- package/src/engines/NgtscEngine.ts +7 -7
- package/src/engines/TscEngine.ts +0 -2
- package/src/engines/types.ts +2 -0
- package/src/esbuild/esbuild-angular-compiler-plugin.ts +647 -0
- package/src/esbuild/esbuild-client-config.ts +57 -41
- package/src/esbuild/esbuild-postcss-plugin.ts +9 -6
- package/src/esbuild/esbuild-tsc-plugin.ts +33 -23
- package/src/esbuild/file-reference-tracker.ts +61 -0
- package/src/esbuild/lmdb-cache-store.ts +46 -0
- package/src/esbuild/load-result-cache.ts +85 -0
- package/src/index.ts +5 -0
- package/src/lint/lint-core.ts +7 -7
- package/src/orchestrators/BaseOrchestrator.ts +2 -2
- package/src/orchestrators/BuildOrchestrator.ts +5 -24
- package/src/orchestrators/DevOrchestrator.ts +5 -5
- package/src/orchestrators/WatchOrchestrator.ts +6 -6
- package/src/runtime/ResultCollector.ts +1 -0
- package/src/runtime/engine-watch-events.ts +3 -0
- package/src/runtime/rebuild-manager.ts +1 -1
- package/src/runtime/worker-utils.ts +1 -1
- package/src/sd-cli-entry.ts +5 -3
- package/src/sd-cli.ts +4 -4
- package/src/ts-compiler/SdTsCompiler.ts +815 -0
- package/src/ts-compiler/sd-ts-compiler-options.ts +46 -0
- package/src/ts-compiler/sd-ts-compiler-result.ts +34 -0
- package/src/utils/copy-public.ts +9 -6
- package/src/utils/diagnostic-utils.ts +8 -9
- package/src/utils/output-utils.ts +38 -8
- package/src/workers/client.worker.ts +141 -126
- package/src/workers/incremental-mtime-tracker.ts +68 -0
- package/src/workers/library-build.worker.ts +214 -75
- package/src/workers/server-build.worker.ts +31 -61
- package/src/workers/server-esbuild-context.ts +14 -2
- package/tests/angular/fixtures/packages/basic-app/dist/styles.css +3 -0
- package/tests/angular/fixtures/packages/basic-app/scss/styles.scss +5 -0
- package/tests/angular/ngtsc-build-core.acc.spec.ts +210 -0
- package/tests/angular/ngtsc-build-core.spec.ts +52 -0
- package/tests/angular/vite-angular-plugin-sdtscompiler.verify.md +13 -0
- package/tests/angular/web-worker-transformer.spec.ts +154 -0
- package/tests/capacitor/capacitor-build.spec.ts +1 -1
- package/tests/capacitor/capacitor-icon.spec.ts +1 -1
- package/tests/capacitor/capacitor-init.spec.ts +1 -1
- package/tests/commands/check.spec.ts +90 -104
- package/tests/commands/publish.spec.ts +12 -4
- package/tests/commands/slice3-severity-cleanup.verify.md +12 -0
- package/tests/commands/version-upgrade.acc.spec.ts +210 -0
- package/tests/commands/version-upgrade.spec.ts +148 -0
- package/tests/deps/replace-deps/collect-deps.acc.spec.ts +62 -0
- package/tests/deps/replace-deps/collect-deps.spec.ts +49 -0
- package/tests/deps/replace-deps/replace-deps-filter.spec.ts +103 -0
- package/tests/deps/replace-deps/replace-deps-perf.verify.md +15 -0
- package/tests/deps/replace-deps/replace-deps-resolve.acc.spec.ts +124 -0
- package/tests/deps/replace-deps/replace-deps-setup.acc.spec.ts +156 -0
- package/tests/electron/electron.spec.ts +4 -1
- package/tests/engines/engine-adapter-isolation.spec.ts +5 -6
- package/tests/engines/engine-duplicate-output-removal.verify.md +10 -0
- package/tests/engines/esbuild-client-engine.acc.spec.ts +79 -0
- package/tests/engines/esbuild-client-engine.spec.ts +73 -3
- package/tests/esbuild/esbuild-angular-compiler-plugin-hmr.verify.md +23 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-onload.verify.md +21 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-onstart-extraction.verify.md +16 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-sdtscompiler.verify.md +15 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-stylesheet.verify.md +31 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin-worker.verify.md +31 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin.spec.ts +397 -0
- package/tests/esbuild/esbuild-angular-compiler-plugin.verify.md +21 -0
- package/tests/esbuild/esbuild-postcss-plugin-chunking.verify.md +17 -0
- package/tests/esbuild/esbuild-postcss-plugin.acc.spec.ts +152 -0
- package/tests/esbuild/esbuild-tsc-plugin-imports.verify.md +13 -0
- package/tests/esbuild/esbuild-tsc-plugin.acc.spec.ts +56 -111
- package/tests/esbuild/esbuild-tsc-plugin.spec.ts +116 -52
- package/tests/esbuild/file-reference-tracker.spec.ts +99 -0
- package/tests/esbuild/lmdb-cache-store.spec.ts +58 -0
- package/tests/esbuild/load-result-cache.acc.spec.ts +55 -0
- package/tests/esbuild/load-result-cache.spec.ts +133 -0
- package/tests/orchestrators/build-orchestrator.spec.ts +4 -3
- package/tests/orchestrators/dev-orchestrator.spec.ts +5 -5
- package/tests/orchestrators/slice1-stdout-to-consola.verify.md +10 -0
- package/tests/orchestrators/typecheck-orchestrator.spec.ts +1 -1
- package/tests/orchestrators/watch-orchestrator.spec.ts +7 -7
- package/tests/runtime/result-collector.spec.ts +64 -0
- package/tests/sd-cli-entry.spec.ts +3 -4
- package/tests/sd-cli-log-tag.verify.md +11 -0
- package/tests/ts-compiler/SdTsCompiler-affected-files.verify.md +8 -0
- package/tests/ts-compiler/SdTsCompiler-diagnostics.verify.md +12 -0
- package/tests/ts-compiler/SdTsCompiler-emit.verify.md +9 -0
- package/tests/ts-compiler/SdTsCompiler.acc.spec.ts +603 -0
- package/tests/ts-compiler/SdTsCompiler.spec.ts +265 -0
- package/tests/ts-compiler/SdTsCompiler.verify.md +41 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck-browser.tsbuildinfo +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck-node.tsbuildinfo +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck.tsbuildinfo +1 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/src/index.ts +3 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/src/util.ts +3 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/tests/sample.test-file.ts +3 -0
- package/tests/ts-compiler/fixtures/non-angular-pkg/tsconfig.json +12 -0
- package/tests/ts-compiler/scss-lint-integration.verify.md +14 -0
- package/tests/utils/angular-build.spec.ts +1 -1
- package/tests/utils/copy-public-outdir.verify.md +8 -0
- package/tests/utils/copy-public.acc.spec.ts +52 -0
- package/tests/utils/copy-public.spec.ts +56 -0
- package/tests/utils/diagnostic-utils.spec.ts +24 -15
- package/tests/utils/engine-watch-events.acc.spec.ts +59 -0
- package/tests/utils/engine-watch-events.spec.ts +58 -0
- package/tests/utils/esbuild-client-config-integration.verify.md +9 -0
- package/tests/utils/esbuild-client-config.acc.spec.ts +45 -61
- package/tests/utils/esbuild-client-config.spec.ts +70 -52
- package/tests/utils/ngtsc-build-core-write-emit.spec.ts +136 -12
- package/tests/utils/ngtsc-build-core.spec.ts +1 -44
- package/tests/utils/output-utils.spec.ts +133 -13
- package/tests/utils/replace-deps-watch.acc.spec.ts +7 -1
- package/tests/utils/replace-deps-watch.spec.ts +57 -1
- package/tests/utils/worker-utils.spec.ts +8 -2
- package/tests/workers/client-worker-initial-build-error.verify.md +2 -3
- package/tests/workers/client-worker-initial-build-warnings.verify.md +7 -0
- package/tests/workers/client-worker-mtime-incremental.verify.md +10 -0
- package/tests/workers/client-worker-refactor.verify.md +22 -0
- package/tests/workers/client-worker-ts-cache-invalidation.verify.md +12 -0
- package/tests/workers/client-worker.acc.spec.ts +6 -3
- package/tests/workers/incremental-mtime-tracker.acc.spec.ts +144 -0
- package/tests/workers/incremental-mtime-tracker.spec.ts +102 -0
- package/tests/workers/library-build-lint.spec.ts +40 -45
- package/tests/workers/library-build-worker.spec.ts +298 -40
- package/tests/workers/server-build-lint.spec.ts +59 -45
- package/tests/workers/server-build-worker.spec.ts +63 -24
- package/tests/workers/server-esbuild-context.acc.spec.ts +2 -0
- package/tests/workers/server-esbuild-context.spec.ts +2 -0
- package/tests/workers/server-runtime-worker.spec.ts +1 -1
- package/tests/workers/shared-worker-lifecycle.acc.spec.ts +1 -1
- package/dist/angular/angular-build-pipeline.d.ts +0 -97
- package/dist/angular/angular-build-pipeline.d.ts.map +0 -1
- package/dist/angular/angular-build-pipeline.js +0 -285
- package/dist/angular/angular-build-pipeline.js.map +0 -1
- package/dist/utils/tsc-build.d.ts +0 -51
- package/dist/utils/tsc-build.d.ts.map +0 -1
- package/dist/utils/tsc-build.js +0 -156
- package/dist/utils/tsc-build.js.map +0 -1
- package/dist/workers/ngtsc-build.worker.d.ts +0 -23
- package/dist/workers/ngtsc-build.worker.d.ts.map +0 -1
- package/dist/workers/ngtsc-build.worker.js +0 -267
- package/dist/workers/ngtsc-build.worker.js.map +0 -1
- package/src/angular/angular-build-pipeline.ts +0 -406
- package/src/utils/tsc-build.ts +0 -226
- package/src/workers/ngtsc-build.worker.ts +0 -351
- package/tests/angular/angular-build-pipeline.spec.ts +0 -247
- package/tests/angular/angular-compiler-aot.acc.spec.ts +0 -68
- package/tests/angular/angular-compiler-aot.spec.ts +0 -80
- package/tests/utils/angular-compiler-emit.spec.ts +0 -666
- package/tests/utils/angular-compiler.spec.ts +0 -707
- package/tests/utils/tsc-build.spec.ts +0 -527
- package/tests/workers/ngtsc-build-lint.spec.ts +0 -141
- package/tests/workers/ngtsc-build-worker.spec.ts +0 -199
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
import path from "path";
|
|
1
2
|
import type ts from "typescript";
|
|
2
3
|
import { createWorker, FsWatcher, pathx } from "@simplysm/core-node";
|
|
3
4
|
import { err as errNs } from "@simplysm/core-common";
|
|
4
|
-
import type { SdBuildPackageConfig } from "../sd-config.types";
|
|
5
5
|
import type { BuildOutput } from "../engines/types";
|
|
6
6
|
import type { SerializedDiagnostic } from "../typecheck/typecheck-serialization";
|
|
7
7
|
import type { LintWithProgramResult } from "../lint/lint-with-program";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { SdTsCompiler } from "../ts-compiler/SdTsCompiler";
|
|
9
|
+
import type { ISdTsCompilerResult } from "../ts-compiler/sd-ts-compiler-result";
|
|
10
|
+
import { writeEmitResults, compileSideEffectScss, buildReverseDeps } from "../angular/ngtsc-build-core";
|
|
10
11
|
import { setupWorkerLifecycle } from "./shared-worker-lifecycle";
|
|
11
12
|
import { buildWatchPaths } from "./build-watch-paths";
|
|
12
13
|
import { hasFileAddOrRemove, shouldSkipRebuild } from "./build-change-filter";
|
|
@@ -15,7 +16,6 @@ import { hasFileAddOrRemove, shouldSkipRebuild } from "./build-change-filter";
|
|
|
15
16
|
|
|
16
17
|
export interface LibraryBuildInfo {
|
|
17
18
|
name: string;
|
|
18
|
-
config: SdBuildPackageConfig;
|
|
19
19
|
cwd: string;
|
|
20
20
|
pkgDir: string;
|
|
21
21
|
output: BuildOutput;
|
|
@@ -44,12 +44,21 @@ export interface LibraryBuildWorkerEvents extends Record<string, unknown> {
|
|
|
44
44
|
//#region Resource Management
|
|
45
45
|
|
|
46
46
|
let fsWatcher: FsWatcher | undefined;
|
|
47
|
+
let compiler: SdTsCompiler | undefined;
|
|
48
|
+
let combinedScssDeps = new Map<string, Set<string>>();
|
|
49
|
+
let reverseScssDeps = new Map<string, Set<string>>();
|
|
50
|
+
let registryReverseIndex = new Map<string, Set<string>>();
|
|
51
|
+
let sideEffectScssDeps = new Map<string, Set<string>>();
|
|
47
52
|
|
|
48
53
|
async function cleanup(): Promise<void> {
|
|
49
54
|
const watcherToClose = fsWatcher;
|
|
50
55
|
fsWatcher = undefined;
|
|
56
|
+
compiler = undefined;
|
|
51
57
|
lastSourceFilePaths = undefined;
|
|
52
|
-
|
|
58
|
+
combinedScssDeps = new Map();
|
|
59
|
+
reverseScssDeps = new Map();
|
|
60
|
+
registryReverseIndex = new Map();
|
|
61
|
+
sideEffectScssDeps = new Map();
|
|
53
62
|
await watcherToClose?.close();
|
|
54
63
|
}
|
|
55
64
|
|
|
@@ -61,36 +70,75 @@ const { logger, guardStartWatch } = setupWorkerLifecycle("library-build", cleanu
|
|
|
61
70
|
|
|
62
71
|
async function build(info: LibraryBuildInfo): Promise<LibraryBuildResult> {
|
|
63
72
|
logger.debug(`[${info.name}] library worker build 시작 (pkgDir: ${info.pkgDir})`);
|
|
64
|
-
const tscResult = runTscPackageBuild({
|
|
65
|
-
pkgDir: info.pkgDir,
|
|
66
|
-
cwd: info.cwd,
|
|
67
|
-
output: info.output,
|
|
68
|
-
env: info.output.env,
|
|
69
|
-
includeTests: info.output.includeTests,
|
|
70
|
-
});
|
|
71
|
-
logger.debug(`[${info.name}] library worker build 완료 (success: ${tscResult.success})`);
|
|
72
73
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
logger.debug(`[${info.name}] lint 시작`);
|
|
77
|
-
const lintRunner = new LintWithProgramRunner({
|
|
74
|
+
try {
|
|
75
|
+
compiler = new SdTsCompiler({
|
|
76
|
+
pkgDir: info.pkgDir,
|
|
78
77
|
cwd: info.cwd,
|
|
79
|
-
|
|
78
|
+
output: { js: info.output.js, dts: info.output.dts },
|
|
79
|
+
includeTests: info.output.includeTests,
|
|
80
|
+
env: info.output.env,
|
|
81
|
+
lint: info.output.lint,
|
|
82
|
+
globalScss: info.output.globalScss,
|
|
80
83
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
+
const result = await compiler.compileAsync();
|
|
85
|
+
const isAngular = info.output.globalScss === true;
|
|
86
|
+
|
|
87
|
+
// Angular: emit 결과 디스크 쓰기 + side-effect SCSS 처리
|
|
88
|
+
const sideEffectScssErrors: string[] = [];
|
|
89
|
+
if (result.emitResults != null) {
|
|
90
|
+
const normalizedSrcDir = pathx.posix(path.join(info.pkgDir, "src"));
|
|
91
|
+
const filteredEmitResults = result.emitResults.filter((r) =>
|
|
92
|
+
pathx.posix(r.sourceFileName).startsWith(normalizedSrcDir + "/"),
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
if (isAngular) {
|
|
96
|
+
const loadPaths = [path.join(info.pkgDir, "scss"), path.join(info.cwd, "node_modules")];
|
|
97
|
+
writeEmitResults(filteredEmitResults, info.pkgDir, {
|
|
98
|
+
loadPaths,
|
|
99
|
+
scssErrors: sideEffectScssErrors,
|
|
100
|
+
scssDependencies: combinedScssDeps,
|
|
101
|
+
registry: compiler.sideEffectScssRegistry,
|
|
102
|
+
registryReverseIndex,
|
|
103
|
+
sideEffectScssDeps,
|
|
104
|
+
});
|
|
105
|
+
// 초기 빌드: 등록된 side-effect SCSS 전체 컴파일 (changedScssFiles 미전달)
|
|
106
|
+
compileSideEffectScss(
|
|
107
|
+
compiler.sideEffectScssRegistry,
|
|
108
|
+
loadPaths,
|
|
109
|
+
sideEffectScssErrors,
|
|
110
|
+
combinedScssDeps,
|
|
111
|
+
undefined,
|
|
112
|
+
sideEffectScssDeps,
|
|
113
|
+
);
|
|
114
|
+
} else {
|
|
115
|
+
writeEmitResults(filteredEmitResults, info.pkgDir);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
84
118
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
119
|
+
// 에러 통합 (ts errors + scss errors + side-effect scss errors)
|
|
120
|
+
const allErrors = [...(result.errors ?? []), ...result.scssErrors, ...sideEffectScssErrors];
|
|
121
|
+
|
|
122
|
+
logger.debug(`[${info.name}] library worker build 완료 (success: ${result.errorCount === 0})`);
|
|
123
|
+
return {
|
|
124
|
+
build: {
|
|
125
|
+
success:
|
|
126
|
+
result.errorCount === 0 &&
|
|
127
|
+
result.scssErrors.length === 0 &&
|
|
128
|
+
sideEffectScssErrors.length === 0,
|
|
129
|
+
errors: allErrors.length > 0 ? allErrors : undefined,
|
|
130
|
+
warnings: undefined,
|
|
131
|
+
diagnostics: result.diagnostics,
|
|
132
|
+
},
|
|
133
|
+
lint: result.lint,
|
|
134
|
+
};
|
|
135
|
+
} catch (err) {
|
|
136
|
+
const message = errNs.message(err);
|
|
137
|
+
logger.debug(`[${info.name}] library worker build 예외 발생: ${message}`);
|
|
138
|
+
return {
|
|
139
|
+
build: { success: false, errors: [message], diagnostics: [] },
|
|
140
|
+
};
|
|
141
|
+
}
|
|
94
142
|
}
|
|
95
143
|
|
|
96
144
|
//#endregion
|
|
@@ -98,10 +146,7 @@ async function build(info: LibraryBuildInfo): Promise<LibraryBuildResult> {
|
|
|
98
146
|
//#region startWatch (watch mode)
|
|
99
147
|
|
|
100
148
|
// watch 모드용 가변 상태
|
|
101
|
-
let watchInfo: LibraryBuildInfo | undefined;
|
|
102
|
-
let watchLintRunner: LintWithProgramRunner | undefined;
|
|
103
149
|
let lastSourceFilePaths: Set<string> | undefined;
|
|
104
|
-
let lastBuilderProgram: ts.EmitAndSemanticDiagnosticsBuilderProgram | undefined;
|
|
105
150
|
|
|
106
151
|
function extractSourceFilePaths(program: ts.Program | undefined): Set<string> | undefined {
|
|
107
152
|
if (program == null) return undefined;
|
|
@@ -112,61 +157,122 @@ function extractSourceFilePaths(program: ts.Program | undefined): Set<string> |
|
|
|
112
157
|
return paths;
|
|
113
158
|
}
|
|
114
159
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
160
|
+
/** compile-time SCSS 의존성으로 combinedScssDeps와 reverseScssDeps를 갱신한다 */
|
|
161
|
+
function updateCombinedScssDeps(result: ISdTsCompilerResult): void {
|
|
162
|
+
combinedScssDeps = new Map();
|
|
163
|
+
for (const [file, deps] of result.scssDependencies) {
|
|
164
|
+
combinedScssDeps.set(file, new Set(deps));
|
|
165
|
+
}
|
|
166
|
+
rebuildReverseScssDeps();
|
|
167
|
+
}
|
|
118
168
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
169
|
+
/** combinedScssDeps에서 역방향 인덱스를 재구축한다 */
|
|
170
|
+
function rebuildReverseScssDeps(): void {
|
|
171
|
+
reverseScssDeps = buildReverseDeps(combinedScssDeps);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* SdTsCompiler 결과를 CombinedBuildEvent로 변환한다.
|
|
176
|
+
* Angular일 경우 emit 디스크 쓰기 + side-effect SCSS 처리를 포함한다.
|
|
177
|
+
*/
|
|
178
|
+
function buildWatchEvent(
|
|
179
|
+
info: LibraryBuildInfo,
|
|
180
|
+
result: ISdTsCompilerResult,
|
|
181
|
+
changedScssFiles?: ReadonlySet<string>,
|
|
182
|
+
): CombinedBuildEvent {
|
|
183
|
+
const isAngular = info.output.globalScss === true;
|
|
184
|
+
|
|
185
|
+
if (isAngular && result.emitResults != null) {
|
|
186
|
+
const normalizedSrcDir = pathx.posix(path.join(info.pkgDir, "src"));
|
|
187
|
+
const loadPaths = [path.join(info.pkgDir, "scss"), path.join(info.cwd, "node_modules")];
|
|
188
|
+
const sideEffectScssErrors: string[] = [];
|
|
189
|
+
|
|
190
|
+
// emit 결과 디스크 쓰기 (side-effect SCSS 등록 포함)
|
|
191
|
+
writeEmitResults(
|
|
192
|
+
result.emitResults.filter((r) =>
|
|
193
|
+
pathx.posix(r.sourceFileName).startsWith(normalizedSrcDir + "/"),
|
|
194
|
+
),
|
|
195
|
+
info.pkgDir,
|
|
196
|
+
{
|
|
197
|
+
loadPaths,
|
|
198
|
+
scssErrors: sideEffectScssErrors,
|
|
199
|
+
scssDependencies: combinedScssDeps,
|
|
200
|
+
registry: compiler!.sideEffectScssRegistry,
|
|
201
|
+
registryReverseIndex,
|
|
202
|
+
sideEffectScssDeps,
|
|
203
|
+
},
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
// side-effect SCSS 재컴파일
|
|
207
|
+
// changedScssFiles 미제공 = 초기 빌드 → 전체 컴파일
|
|
208
|
+
// changedScssFiles 제공 + size > 0 → 증분 컴파일
|
|
209
|
+
if (changedScssFiles == null || changedScssFiles.size > 0) {
|
|
210
|
+
compileSideEffectScss(
|
|
211
|
+
compiler!.sideEffectScssRegistry,
|
|
212
|
+
loadPaths,
|
|
213
|
+
sideEffectScssErrors,
|
|
214
|
+
combinedScssDeps,
|
|
215
|
+
changedScssFiles,
|
|
216
|
+
sideEffectScssDeps,
|
|
217
|
+
);
|
|
218
|
+
// side-effect SCSS 의존성이 combinedScssDeps에 추가되었으므로 역방향 인덱스 재구축
|
|
219
|
+
rebuildReverseScssDeps();
|
|
141
220
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
221
|
+
|
|
222
|
+
// 모든 에러 통합
|
|
223
|
+
const allErrors = [...(result.errors ?? []), ...result.scssErrors, ...sideEffectScssErrors];
|
|
224
|
+
return {
|
|
225
|
+
build: {
|
|
226
|
+
success:
|
|
227
|
+
result.errorCount === 0 &&
|
|
228
|
+
result.scssErrors.length === 0 &&
|
|
229
|
+
sideEffectScssErrors.length === 0,
|
|
230
|
+
errors: allErrors.length > 0 ? allErrors : undefined,
|
|
231
|
+
},
|
|
232
|
+
lint: result.lint,
|
|
233
|
+
};
|
|
147
234
|
}
|
|
148
235
|
|
|
149
|
-
|
|
236
|
+
// Non-Angular 경로
|
|
150
237
|
return {
|
|
151
|
-
build: {
|
|
152
|
-
|
|
238
|
+
build: {
|
|
239
|
+
success: result.errorCount === 0,
|
|
240
|
+
errors: result.errors,
|
|
241
|
+
},
|
|
242
|
+
lint: result.lint,
|
|
153
243
|
};
|
|
154
244
|
}
|
|
155
245
|
|
|
156
246
|
async function startWatch(info: LibraryBuildInfo): Promise<void> {
|
|
157
247
|
guardStartWatch();
|
|
158
|
-
|
|
248
|
+
const isAngular = info.output.globalScss === true;
|
|
249
|
+
|
|
250
|
+
compiler = new SdTsCompiler({
|
|
251
|
+
pkgDir: info.pkgDir,
|
|
252
|
+
cwd: info.cwd,
|
|
253
|
+
output: { js: info.output.js, dts: info.output.dts },
|
|
254
|
+
includeTests: info.output.includeTests,
|
|
255
|
+
env: info.output.env,
|
|
256
|
+
lint: info.output.lint,
|
|
257
|
+
globalScss: info.output.globalScss,
|
|
258
|
+
});
|
|
159
259
|
|
|
160
260
|
try {
|
|
161
261
|
// 초기 빌드
|
|
162
|
-
const initialResult = await
|
|
163
|
-
|
|
262
|
+
const initialResult = await compiler.compileAsync();
|
|
263
|
+
lastSourceFilePaths = extractSourceFilePaths(initialResult.program) ?? lastSourceFilePaths;
|
|
264
|
+
if (isAngular) {
|
|
265
|
+
updateCombinedScssDeps(initialResult);
|
|
266
|
+
}
|
|
267
|
+
const initialEvent = buildWatchEvent(info, initialResult);
|
|
268
|
+
sender.send("build", initialEvent);
|
|
164
269
|
|
|
165
270
|
// workspace 의존성 경로 + replaceDeps 수집
|
|
166
271
|
const { watchPaths } = buildWatchPaths({
|
|
167
272
|
pkgDir: info.pkgDir,
|
|
168
273
|
cwd: info.cwd,
|
|
169
|
-
srcGlobs: ["*.ts"],
|
|
274
|
+
srcGlobs: isAngular ? ["*.{ts,scss,css}"] : ["*.ts"],
|
|
275
|
+
extraDirs: isAngular ? [{ dir: "scss", globs: ["*.{scss,css}"] }] : undefined,
|
|
170
276
|
replaceDeps: info.replaceDeps,
|
|
171
277
|
});
|
|
172
278
|
|
|
@@ -174,15 +280,48 @@ async function startWatch(info: LibraryBuildInfo): Promise<void> {
|
|
|
174
280
|
logger.debug(`[${info.name}] FsWatcher 시작`);
|
|
175
281
|
fsWatcher = await FsWatcher.watch(watchPaths);
|
|
176
282
|
|
|
177
|
-
fsWatcher.onChange({ delay: 300 }, async (
|
|
283
|
+
fsWatcher.onChange({ delay: 300 }, async (changedFiles) => {
|
|
178
284
|
try {
|
|
179
|
-
|
|
285
|
+
const addOrRemove = hasFileAddOrRemove(changedFiles);
|
|
286
|
+
|
|
287
|
+
// 변경된 파일 수집
|
|
288
|
+
const modifiedFiles = new Set<string>();
|
|
289
|
+
for (const f of changedFiles) {
|
|
290
|
+
modifiedFiles.add(f.path);
|
|
291
|
+
|
|
292
|
+
// Angular: SCSS 역방향 의존성 탐색 (O(1) 조회)
|
|
293
|
+
if (isAngular && (f.path.endsWith(".scss") || f.path.endsWith(".css"))) {
|
|
294
|
+
const normalizedPath = pathx.posix(f.path);
|
|
295
|
+
const owners = reverseScssDeps.get(normalizedPath);
|
|
296
|
+
if (owners != null) {
|
|
297
|
+
for (const owner of owners) {
|
|
298
|
+
modifiedFiles.add(owner);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// 의존성 필터: 관련 변경이 없으면 리빌드 건너뜀
|
|
305
|
+
if (shouldSkipRebuild(modifiedFiles, addOrRemove, lastSourceFilePaths, logger)) {
|
|
180
306
|
return;
|
|
181
307
|
}
|
|
182
308
|
|
|
183
309
|
sender.send("buildStart", {});
|
|
184
|
-
|
|
185
|
-
|
|
310
|
+
|
|
311
|
+
const result = await compiler!.compileAsync(modifiedFiles);
|
|
312
|
+
lastSourceFilePaths = extractSourceFilePaths(result.program) ?? lastSourceFilePaths;
|
|
313
|
+
if (isAngular) {
|
|
314
|
+
updateCombinedScssDeps(result);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
const changedScssFiles = new Set(
|
|
318
|
+
changedFiles
|
|
319
|
+
.filter((f) => f.path.endsWith(".scss") || f.path.endsWith(".css"))
|
|
320
|
+
.map((f) => pathx.posix(f.path)),
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
const event = buildWatchEvent(info, result, changedScssFiles);
|
|
324
|
+
sender.send("build", event);
|
|
186
325
|
} catch (err) {
|
|
187
326
|
sender.send("error", { message: errNs.message(err) });
|
|
188
327
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type ts from "typescript";
|
|
2
1
|
import path from "path";
|
|
3
2
|
import fs from "fs";
|
|
4
3
|
import esbuild from "esbuild";
|
|
5
4
|
import { createWorker, FsWatcher, pathx } from "@simplysm/core-node";
|
|
6
5
|
import { err as errNs } from "@simplysm/core-common";
|
|
6
|
+
import { formatEsbuildMessages } from "../utils/output-utils";
|
|
7
7
|
import type { BuildOutput } from "../engines/types";
|
|
8
8
|
import type { SerializedDiagnostic } from "../typecheck/typecheck-serialization";
|
|
9
9
|
import type { LintWithProgramResult } from "../lint/lint-with-program";
|
|
@@ -16,9 +16,8 @@ import {
|
|
|
16
16
|
writeChangedOutputFiles,
|
|
17
17
|
} from "../esbuild/esbuild-config";
|
|
18
18
|
import { collectAllExternals, generateProductionFiles } from "../deps/server-externals/server-production-files";
|
|
19
|
-
import {
|
|
19
|
+
import { SdTsCompiler } from "../ts-compiler/SdTsCompiler";
|
|
20
20
|
import { createTscPlugin } from "../esbuild/esbuild-tsc-plugin";
|
|
21
|
-
import { LintWithProgramRunner } from "../lint/lint-with-program";
|
|
22
21
|
import { setupWorkerLifecycle } from "./shared-worker-lifecycle";
|
|
23
22
|
import { buildWatchPaths } from "./build-watch-paths";
|
|
24
23
|
import { copyPublicFiles, watchPublicFiles } from "../utils/copy-public";
|
|
@@ -146,7 +145,7 @@ async function build(info: ServerBuildInfo): Promise<ServerBuildResult> {
|
|
|
146
145
|
let jsResult: { success: boolean; errors?: string[]; warnings?: string[] };
|
|
147
146
|
let tscErrors: string[];
|
|
148
147
|
let tscDiagnostics: SerializedDiagnostic[];
|
|
149
|
-
let
|
|
148
|
+
let lint: LintWithProgramResult | undefined;
|
|
150
149
|
|
|
151
150
|
if (info.output.js) {
|
|
152
151
|
// js=true: tsc 플러그인 통합 — 단일 esbuild.build() 호출
|
|
@@ -156,6 +155,7 @@ async function build(info: ServerBuildInfo): Promise<ServerBuildResult> {
|
|
|
156
155
|
output: { dts: info.output.dts },
|
|
157
156
|
env: info.output.env,
|
|
158
157
|
includeTests: info.output.includeTests,
|
|
158
|
+
lint: info.output.lint,
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
const esbuildOptions = createServerEsbuildOptions({
|
|
@@ -170,8 +170,8 @@ async function build(info: ServerBuildInfo): Promise<ServerBuildResult> {
|
|
|
170
170
|
if (result.outputFiles) {
|
|
171
171
|
await writeChangedOutputFiles(result.outputFiles);
|
|
172
172
|
}
|
|
173
|
-
const errors = result.errors
|
|
174
|
-
const warnings = result.warnings
|
|
173
|
+
const errors = formatEsbuildMessages(result.errors, "error");
|
|
174
|
+
const warnings = formatEsbuildMessages(result.warnings, "warning");
|
|
175
175
|
return {
|
|
176
176
|
success: result.errors.length === 0,
|
|
177
177
|
errors: errors.length > 0 ? errors : undefined,
|
|
@@ -186,34 +186,23 @@ async function build(info: ServerBuildInfo): Promise<ServerBuildResult> {
|
|
|
186
186
|
|
|
187
187
|
tscErrors = tscPlugin.getErrors() ?? [];
|
|
188
188
|
tscDiagnostics = tscPlugin.getDiagnostics();
|
|
189
|
-
|
|
189
|
+
lint = tscPlugin.getLintResult();
|
|
190
190
|
} else {
|
|
191
|
-
// js=false:
|
|
192
|
-
const
|
|
191
|
+
// js=false: SdTsCompiler 직접 호출 (플러그인 경유 불가)
|
|
192
|
+
const compiler = new SdTsCompiler({
|
|
193
193
|
pkgDir: info.pkgDir,
|
|
194
194
|
cwd: info.cwd,
|
|
195
195
|
output: { js: false, dts: info.output.dts },
|
|
196
|
-
parsedConfig,
|
|
197
196
|
env: info.output.env,
|
|
198
197
|
includeTests: info.output.includeTests,
|
|
198
|
+
lint: info.output.lint,
|
|
199
199
|
});
|
|
200
|
+
const tscResult = await compiler.compileAsync();
|
|
200
201
|
|
|
201
202
|
jsResult = { success: true, errors: undefined, warnings: undefined };
|
|
202
203
|
tscErrors = tscResult.errors ?? [];
|
|
203
204
|
tscDiagnostics = tscResult.diagnostics;
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
// lint 실행 (활성화 + program 사용 가능 시)
|
|
208
|
-
let lint: LintWithProgramResult | undefined;
|
|
209
|
-
if (info.output.lint === true && tscProgram != null) {
|
|
210
|
-
logger.debug(`[${info.name}] lint 시작`);
|
|
211
|
-
const lintRunner = new LintWithProgramRunner({
|
|
212
|
-
cwd: info.cwd,
|
|
213
|
-
pkgName: info.name,
|
|
214
|
-
});
|
|
215
|
-
lint = await lintRunner.lint({ program: tscProgram });
|
|
216
|
-
logger.debug(`[${info.name}] lint 완료`);
|
|
205
|
+
lint = tscResult.lint;
|
|
217
206
|
}
|
|
218
207
|
|
|
219
208
|
// JS 출력이 요청된 경우에만 프로덕션 아티팩트 생성
|
|
@@ -261,65 +250,45 @@ async function startWatch(info: ServerWatchInfo): Promise<void> {
|
|
|
261
250
|
logger.debug(`[${info.name}] server worker startWatch 시작`);
|
|
262
251
|
|
|
263
252
|
// watch 모드 로컬 상태 (클로저로 관리)
|
|
264
|
-
|
|
265
|
-
let
|
|
253
|
+
// js=false 경로에서 SdTsCompiler 인스턴스를 유지하여 증분 빌드를 지원한다
|
|
254
|
+
let watchCompiler: SdTsCompiler | undefined;
|
|
266
255
|
|
|
267
256
|
/**
|
|
268
257
|
* esbuild + tsc 리빌드 (watch 모드)
|
|
269
258
|
* js=true: esbuildCtx.rebuild() 단일 호출 (tsc 플러그인 자동 트리거)
|
|
270
|
-
* js=false:
|
|
259
|
+
* js=false: SdTsCompiler.compileAsync() 직접 호출
|
|
271
260
|
*/
|
|
272
261
|
async function rebuildAll(): Promise<ServerCombinedBuildEvent> {
|
|
273
262
|
logger.debug(`[${info.name}] rebuildAll 시작`);
|
|
274
263
|
const mainJsPath = pathx.posixResolve(info.pkgDir, "dist", "main.js");
|
|
275
264
|
|
|
276
265
|
let jsResult: { success: boolean; errors?: string[]; warnings?: string[] };
|
|
277
|
-
let tscProgram: ts.Program | undefined;
|
|
278
|
-
let tscAffectedFiles: ReadonlySet<string> | undefined;
|
|
279
266
|
let tscErrors: string[];
|
|
267
|
+
let lint: LintWithProgramResult | undefined;
|
|
280
268
|
|
|
281
269
|
if (info.output.js) {
|
|
282
270
|
// js=true: esbuildCtx.rebuild() 단일 호출 (tsc 에러 자동 병합)
|
|
283
271
|
const rebuildResult = await esbuildCtx.rebuild();
|
|
284
272
|
jsResult = rebuildResult ?? { success: true, errors: undefined, warnings: undefined };
|
|
285
|
-
tscProgram = esbuildCtx.getTscProgram();
|
|
286
|
-
tscAffectedFiles = esbuildCtx.getTscAffectedFiles();
|
|
287
273
|
tscErrors = [];
|
|
274
|
+
lint = esbuildCtx.getTscLintResult();
|
|
288
275
|
} else {
|
|
289
|
-
// js=false:
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
cwd: info.cwd,
|
|
294
|
-
output: { js: false, dts: info.output.dts },
|
|
295
|
-
parsedConfig,
|
|
296
|
-
env: info.output.env,
|
|
297
|
-
includeTests: info.output.includeTests,
|
|
298
|
-
oldBuilderProgram: lastBuilderProgram,
|
|
299
|
-
});
|
|
300
|
-
lastBuilderProgram = tscResult.builderProgram ?? lastBuilderProgram;
|
|
301
|
-
|
|
302
|
-
jsResult = { success: true, errors: undefined, warnings: undefined };
|
|
303
|
-
tscProgram = tscResult.program;
|
|
304
|
-
tscAffectedFiles = tscResult.affectedFiles;
|
|
305
|
-
tscErrors = tscResult.errors ?? [];
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// lint 실행 (활성화 + program 사용 가능 시)
|
|
309
|
-
let lint: LintWithProgramResult | undefined;
|
|
310
|
-
if (info.output.lint === true && tscProgram != null) {
|
|
311
|
-
logger.debug(`[${info.name}] lint 시작`);
|
|
312
|
-
if (watchLintRunner == null) {
|
|
313
|
-
watchLintRunner = new LintWithProgramRunner({
|
|
276
|
+
// js=false: SdTsCompiler 직접 호출
|
|
277
|
+
if (watchCompiler == null) {
|
|
278
|
+
watchCompiler = new SdTsCompiler({
|
|
279
|
+
pkgDir: info.pkgDir,
|
|
314
280
|
cwd: info.cwd,
|
|
315
|
-
|
|
281
|
+
output: { js: false, dts: info.output.dts },
|
|
282
|
+
env: info.output.env,
|
|
283
|
+
includeTests: info.output.includeTests,
|
|
284
|
+
lint: info.output.lint,
|
|
316
285
|
});
|
|
317
286
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
287
|
+
const tscResult = await watchCompiler.compileAsync();
|
|
288
|
+
|
|
289
|
+
jsResult = { success: true, errors: undefined, warnings: undefined };
|
|
290
|
+
tscErrors = tscResult.errors ?? [];
|
|
291
|
+
lint = tscResult.lint;
|
|
323
292
|
}
|
|
324
293
|
|
|
325
294
|
const allErrors = [...(jsResult.errors ?? []), ...tscErrors];
|
|
@@ -355,6 +324,7 @@ async function startWatch(info: ServerWatchInfo): Promise<void> {
|
|
|
355
324
|
output: { dts: info.output.dts },
|
|
356
325
|
env: info.output.env,
|
|
357
326
|
includeTests: info.output.includeTests,
|
|
327
|
+
lint: info.output.lint,
|
|
358
328
|
},
|
|
359
329
|
});
|
|
360
330
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type ts from "typescript";
|
|
2
2
|
import esbuild from "esbuild";
|
|
3
3
|
import { err as errNs } from "@simplysm/core-common";
|
|
4
|
+
import { formatEsbuildMessages } from "../utils/output-utils";
|
|
4
5
|
import {
|
|
5
6
|
createServerEsbuildOptions,
|
|
6
7
|
writeChangedOutputFiles,
|
|
@@ -8,6 +9,7 @@ import {
|
|
|
8
9
|
import { createTscPlugin, type TscPluginResult } from "../esbuild/esbuild-tsc-plugin";
|
|
9
10
|
import type { TypecheckEnv } from "../utils/tsconfig";
|
|
10
11
|
import type { SerializedDiagnostic } from "../typecheck/typecheck-serialization";
|
|
12
|
+
import type { LintWithProgramResult } from "../lint/lint-with-program";
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* esbuild watch context 생성 옵션
|
|
@@ -23,6 +25,7 @@ export interface EsbuildContextOptions {
|
|
|
23
25
|
output: { dts: boolean };
|
|
24
26
|
env?: TypecheckEnv;
|
|
25
27
|
includeTests?: boolean;
|
|
28
|
+
lint?: boolean;
|
|
26
29
|
};
|
|
27
30
|
}
|
|
28
31
|
|
|
@@ -47,6 +50,7 @@ export async function createContext(options: EsbuildContextOptions): Promise<voi
|
|
|
47
50
|
output: options.tsc.output,
|
|
48
51
|
env: options.tsc.env,
|
|
49
52
|
includeTests: options.tsc.includeTests,
|
|
53
|
+
lint: options.tsc.lint,
|
|
50
54
|
});
|
|
51
55
|
}
|
|
52
56
|
|
|
@@ -98,10 +102,10 @@ export async function rebuild(): Promise<{
|
|
|
98
102
|
await writeChangedOutputFiles(result.outputFiles);
|
|
99
103
|
}
|
|
100
104
|
|
|
101
|
-
const esbuildErrors = result.errors
|
|
105
|
+
const esbuildErrors = formatEsbuildMessages(result.errors, "error");
|
|
102
106
|
const tscErrors = tscPlugin?.getErrors() ?? [];
|
|
103
107
|
const allErrors = [...esbuildErrors, ...tscErrors];
|
|
104
|
-
const warnings = result.warnings
|
|
108
|
+
const warnings = formatEsbuildMessages(result.warnings, "warning");
|
|
105
109
|
|
|
106
110
|
return {
|
|
107
111
|
success: allErrors.length === 0,
|
|
@@ -188,3 +192,11 @@ export function getTscAffectedFiles(): ReadonlySet<string> | undefined {
|
|
|
188
192
|
export function getTscDiagnostics(): SerializedDiagnostic[] {
|
|
189
193
|
return tscPlugin?.getDiagnostics() ?? [];
|
|
190
194
|
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* tsc 플러그인의 lint 결과를 반환한다.
|
|
198
|
+
* 플러그인이 없거나 lint가 비활성이면 undefined를 반환한다.
|
|
199
|
+
*/
|
|
200
|
+
export function getTscLintResult(): LintWithProgramResult | undefined {
|
|
201
|
+
return tscPlugin?.getLintResult();
|
|
202
|
+
}
|