@simplysm/sd-cli 14.0.41 → 14.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (321) hide show
  1. package/dist/angular/angular-compiler.d.ts +0 -35
  2. package/dist/angular/angular-compiler.d.ts.map +1 -1
  3. package/dist/angular/angular-compiler.js +0 -374
  4. package/dist/angular/angular-compiler.js.map +1 -1
  5. package/dist/angular/hmr-candidates.d.ts +13 -0
  6. package/dist/angular/hmr-candidates.d.ts.map +1 -0
  7. package/dist/angular/hmr-candidates.js +230 -0
  8. package/dist/angular/hmr-candidates.js.map +1 -0
  9. package/dist/angular/ngtsc-build-core.d.ts +29 -34
  10. package/dist/angular/ngtsc-build-core.d.ts.map +1 -1
  11. package/dist/angular/ngtsc-build-core.js +90 -51
  12. package/dist/angular/ngtsc-build-core.js.map +1 -1
  13. package/dist/angular/vite-angular-plugin.d.ts +1 -1
  14. package/dist/angular/vite-angular-plugin.d.ts.map +1 -1
  15. package/dist/angular/vite-angular-plugin.js +63 -56
  16. package/dist/angular/vite-angular-plugin.js.map +1 -1
  17. package/dist/angular/web-worker-transformer.d.ts +9 -0
  18. package/dist/angular/web-worker-transformer.d.ts.map +1 -0
  19. package/dist/angular/web-worker-transformer.js +73 -0
  20. package/dist/angular/web-worker-transformer.js.map +1 -0
  21. package/dist/capacitor/capacitor.d.ts.map +1 -1
  22. package/dist/capacitor/capacitor.js +6 -4
  23. package/dist/capacitor/capacitor.js.map +1 -1
  24. package/dist/commands/check.d.ts +1 -1
  25. package/dist/commands/check.d.ts.map +1 -1
  26. package/dist/commands/check.js +15 -65
  27. package/dist/commands/check.js.map +1 -1
  28. package/dist/commands/publish/deployment-phase.d.ts.map +1 -1
  29. package/dist/commands/publish/deployment-phase.js +13 -5
  30. package/dist/commands/publish/deployment-phase.js.map +1 -1
  31. package/dist/commands/publish/npm-publisher.js +1 -1
  32. package/dist/commands/publish/npm-publisher.js.map +1 -1
  33. package/dist/commands/publish/publish-command.js +1 -1
  34. package/dist/commands/publish/publish-command.js.map +1 -1
  35. package/dist/commands/publish/version-upgrade.js +1 -1
  36. package/dist/commands/publish/version-upgrade.js.map +1 -1
  37. package/dist/commands/replace-deps.d.ts.map +1 -1
  38. package/dist/commands/replace-deps.js +2 -1
  39. package/dist/commands/replace-deps.js.map +1 -1
  40. package/dist/deps/replace-deps/collect-deps.d.ts.map +1 -1
  41. package/dist/deps/replace-deps/collect-deps.js +5 -2
  42. package/dist/deps/replace-deps/collect-deps.js.map +1 -1
  43. package/dist/deps/replace-deps/replace-deps.d.ts +21 -3
  44. package/dist/deps/replace-deps/replace-deps.d.ts.map +1 -1
  45. package/dist/deps/replace-deps/replace-deps.js +107 -62
  46. package/dist/deps/replace-deps/replace-deps.js.map +1 -1
  47. package/dist/electron/electron.js +7 -7
  48. package/dist/electron/electron.js.map +1 -1
  49. package/dist/engines/BaseEngine.d.ts.map +1 -1
  50. package/dist/engines/BaseEngine.js +2 -5
  51. package/dist/engines/BaseEngine.js.map +1 -1
  52. package/dist/engines/EsbuildClientEngine.d.ts.map +1 -1
  53. package/dist/engines/EsbuildClientEngine.js +16 -9
  54. package/dist/engines/EsbuildClientEngine.js.map +1 -1
  55. package/dist/engines/NgtscEngine.d.ts +4 -4
  56. package/dist/engines/NgtscEngine.d.ts.map +1 -1
  57. package/dist/engines/NgtscEngine.js +5 -5
  58. package/dist/engines/NgtscEngine.js.map +1 -1
  59. package/dist/engines/TscEngine.d.ts.map +1 -1
  60. package/dist/engines/TscEngine.js +0 -2
  61. package/dist/engines/TscEngine.js.map +1 -1
  62. package/dist/engines/types.d.ts +2 -0
  63. package/dist/engines/types.d.ts.map +1 -1
  64. package/dist/esbuild/esbuild-angular-compiler-plugin.d.ts +36 -0
  65. package/dist/esbuild/esbuild-angular-compiler-plugin.d.ts.map +1 -0
  66. package/dist/esbuild/esbuild-angular-compiler-plugin.js +464 -0
  67. package/dist/esbuild/esbuild-angular-compiler-plugin.js.map +1 -0
  68. package/dist/esbuild/esbuild-client-config.d.ts +8 -2
  69. package/dist/esbuild/esbuild-client-config.d.ts.map +1 -1
  70. package/dist/esbuild/esbuild-client-config.js +48 -33
  71. package/dist/esbuild/esbuild-client-config.js.map +1 -1
  72. package/dist/esbuild/esbuild-tsc-plugin.d.ts +4 -1
  73. package/dist/esbuild/esbuild-tsc-plugin.d.ts.map +1 -1
  74. package/dist/esbuild/esbuild-tsc-plugin.js +27 -23
  75. package/dist/esbuild/esbuild-tsc-plugin.js.map +1 -1
  76. package/dist/esbuild/file-reference-tracker.d.ts +24 -0
  77. package/dist/esbuild/file-reference-tracker.d.ts.map +1 -0
  78. package/dist/esbuild/file-reference-tracker.js +57 -0
  79. package/dist/esbuild/file-reference-tracker.js.map +1 -0
  80. package/dist/esbuild/lmdb-cache-store.d.ts +18 -0
  81. package/dist/esbuild/lmdb-cache-store.d.ts.map +1 -0
  82. package/dist/esbuild/lmdb-cache-store.js +41 -0
  83. package/dist/esbuild/lmdb-cache-store.js.map +1 -0
  84. package/dist/esbuild/load-result-cache.d.ts +17 -0
  85. package/dist/esbuild/load-result-cache.d.ts.map +1 -0
  86. package/dist/esbuild/load-result-cache.js +61 -0
  87. package/dist/esbuild/load-result-cache.js.map +1 -0
  88. package/dist/index.d.ts +3 -0
  89. package/dist/index.d.ts.map +1 -1
  90. package/dist/index.js +2 -0
  91. package/dist/index.js.map +1 -1
  92. package/dist/lint/lint-core.js +7 -7
  93. package/dist/lint/lint-core.js.map +1 -1
  94. package/dist/orchestrators/BaseOrchestrator.js +2 -2
  95. package/dist/orchestrators/BaseOrchestrator.js.map +1 -1
  96. package/dist/orchestrators/BuildOrchestrator.d.ts.map +1 -1
  97. package/dist/orchestrators/BuildOrchestrator.js +5 -19
  98. package/dist/orchestrators/BuildOrchestrator.js.map +1 -1
  99. package/dist/orchestrators/DevOrchestrator.js +5 -5
  100. package/dist/orchestrators/DevOrchestrator.js.map +1 -1
  101. package/dist/orchestrators/WatchOrchestrator.js +6 -6
  102. package/dist/orchestrators/WatchOrchestrator.js.map +1 -1
  103. package/dist/runtime/ResultCollector.d.ts +1 -0
  104. package/dist/runtime/ResultCollector.d.ts.map +1 -1
  105. package/dist/runtime/ResultCollector.js.map +1 -1
  106. package/dist/runtime/engine-watch-events.d.ts.map +1 -1
  107. package/dist/runtime/engine-watch-events.js +3 -0
  108. package/dist/runtime/engine-watch-events.js.map +1 -1
  109. package/dist/runtime/rebuild-manager.js +1 -1
  110. package/dist/runtime/rebuild-manager.js.map +1 -1
  111. package/dist/runtime/worker-utils.js +1 -1
  112. package/dist/runtime/worker-utils.js.map +1 -1
  113. package/dist/sd-cli-entry.d.ts.map +1 -1
  114. package/dist/sd-cli-entry.js +4 -3
  115. package/dist/sd-cli-entry.js.map +1 -1
  116. package/dist/sd-cli.js +3 -3
  117. package/dist/sd-cli.js.map +1 -1
  118. package/dist/ts-compiler/SdTsCompiler.d.ts +39 -0
  119. package/dist/ts-compiler/SdTsCompiler.d.ts.map +1 -0
  120. package/dist/ts-compiler/SdTsCompiler.js +593 -0
  121. package/dist/ts-compiler/SdTsCompiler.js.map +1 -0
  122. package/dist/ts-compiler/sd-ts-compiler-options.d.ts +40 -0
  123. package/dist/ts-compiler/sd-ts-compiler-options.d.ts.map +1 -0
  124. package/dist/ts-compiler/sd-ts-compiler-options.js +2 -0
  125. package/dist/ts-compiler/sd-ts-compiler-options.js.map +1 -0
  126. package/dist/ts-compiler/sd-ts-compiler-result.d.ts +34 -0
  127. package/dist/ts-compiler/sd-ts-compiler-result.d.ts.map +1 -0
  128. package/dist/ts-compiler/sd-ts-compiler-result.js +2 -0
  129. package/dist/ts-compiler/sd-ts-compiler-result.js.map +1 -0
  130. package/dist/utils/copy-public.d.ts +6 -4
  131. package/dist/utils/copy-public.d.ts.map +1 -1
  132. package/dist/utils/copy-public.js +9 -7
  133. package/dist/utils/copy-public.js.map +1 -1
  134. package/dist/utils/diagnostic-utils.d.ts +2 -3
  135. package/dist/utils/diagnostic-utils.d.ts.map +1 -1
  136. package/dist/utils/diagnostic-utils.js +8 -9
  137. package/dist/utils/diagnostic-utils.js.map +1 -1
  138. package/dist/utils/output-utils.d.ts +8 -2
  139. package/dist/utils/output-utils.d.ts.map +1 -1
  140. package/dist/utils/output-utils.js +32 -8
  141. package/dist/utils/output-utils.js.map +1 -1
  142. package/dist/workers/client.worker.d.ts +1 -1
  143. package/dist/workers/client.worker.d.ts.map +1 -1
  144. package/dist/workers/client.worker.js +136 -110
  145. package/dist/workers/client.worker.js.map +1 -1
  146. package/dist/workers/library-build.worker.d.ts +0 -2
  147. package/dist/workers/library-build.worker.d.ts.map +1 -1
  148. package/dist/workers/library-build.worker.js +147 -70
  149. package/dist/workers/library-build.worker.js.map +1 -1
  150. package/dist/workers/server-build.worker.d.ts.map +1 -1
  151. package/dist/workers/server-build.worker.js +30 -57
  152. package/dist/workers/server-build.worker.js.map +1 -1
  153. package/dist/workers/server-esbuild-context.d.ts +7 -0
  154. package/dist/workers/server-esbuild-context.d.ts.map +1 -1
  155. package/dist/workers/server-esbuild-context.js +11 -2
  156. package/dist/workers/server-esbuild-context.js.map +1 -1
  157. package/package.json +7 -6
  158. package/src/angular/angular-compiler.ts +0 -502
  159. package/src/angular/hmr-candidates.ts +295 -0
  160. package/src/angular/ngtsc-build-core.ts +125 -92
  161. package/src/angular/vite-angular-plugin.ts +71 -65
  162. package/src/angular/web-worker-transformer.ts +117 -0
  163. package/src/capacitor/capacitor.ts +6 -4
  164. package/src/commands/check.ts +17 -76
  165. package/src/commands/publish/deployment-phase.ts +11 -7
  166. package/src/commands/publish/npm-publisher.ts +1 -1
  167. package/src/commands/publish/publish-command.ts +1 -1
  168. package/src/commands/publish/version-upgrade.ts +1 -1
  169. package/src/commands/replace-deps.ts +3 -1
  170. package/src/deps/replace-deps/collect-deps.ts +4 -2
  171. package/src/deps/replace-deps/replace-deps.ts +114 -66
  172. package/src/electron/electron.ts +7 -7
  173. package/src/engines/BaseEngine.ts +2 -6
  174. package/src/engines/EsbuildClientEngine.ts +16 -10
  175. package/src/engines/NgtscEngine.ts +7 -7
  176. package/src/engines/TscEngine.ts +0 -2
  177. package/src/engines/types.ts +2 -0
  178. package/src/esbuild/esbuild-angular-compiler-plugin.ts +647 -0
  179. package/src/esbuild/esbuild-client-config.ts +57 -41
  180. package/src/esbuild/esbuild-tsc-plugin.ts +33 -23
  181. package/src/esbuild/file-reference-tracker.ts +61 -0
  182. package/src/esbuild/lmdb-cache-store.ts +46 -0
  183. package/src/esbuild/load-result-cache.ts +85 -0
  184. package/src/index.ts +5 -0
  185. package/src/lint/lint-core.ts +7 -7
  186. package/src/orchestrators/BaseOrchestrator.ts +2 -2
  187. package/src/orchestrators/BuildOrchestrator.ts +5 -24
  188. package/src/orchestrators/DevOrchestrator.ts +5 -5
  189. package/src/orchestrators/WatchOrchestrator.ts +6 -6
  190. package/src/runtime/ResultCollector.ts +1 -0
  191. package/src/runtime/engine-watch-events.ts +3 -0
  192. package/src/runtime/rebuild-manager.ts +1 -1
  193. package/src/runtime/worker-utils.ts +1 -1
  194. package/src/sd-cli-entry.ts +5 -3
  195. package/src/sd-cli.ts +4 -4
  196. package/src/ts-compiler/SdTsCompiler.ts +815 -0
  197. package/src/ts-compiler/sd-ts-compiler-options.ts +46 -0
  198. package/src/ts-compiler/sd-ts-compiler-result.ts +34 -0
  199. package/src/utils/copy-public.ts +9 -6
  200. package/src/utils/diagnostic-utils.ts +8 -9
  201. package/src/utils/output-utils.ts +38 -8
  202. package/src/workers/client.worker.ts +160 -126
  203. package/src/workers/library-build.worker.ts +187 -75
  204. package/src/workers/server-build.worker.ts +31 -61
  205. package/src/workers/server-esbuild-context.ts +14 -2
  206. package/tests/angular/fixtures/packages/basic-app/dist/styles.css +3 -0
  207. package/tests/angular/fixtures/packages/basic-app/scss/styles.scss +5 -0
  208. package/tests/angular/vite-angular-plugin-sdtscompiler.verify.md +13 -0
  209. package/tests/angular/web-worker-transformer.spec.ts +154 -0
  210. package/tests/capacitor/capacitor-build.spec.ts +1 -1
  211. package/tests/capacitor/capacitor-icon.spec.ts +1 -1
  212. package/tests/capacitor/capacitor-init.spec.ts +1 -1
  213. package/tests/commands/check.spec.ts +90 -104
  214. package/tests/commands/publish.spec.ts +12 -4
  215. package/tests/commands/slice3-severity-cleanup.verify.md +12 -0
  216. package/tests/deps/replace-deps/collect-deps.acc.spec.ts +62 -0
  217. package/tests/deps/replace-deps/collect-deps.spec.ts +49 -0
  218. package/tests/deps/replace-deps/replace-deps-filter.spec.ts +103 -0
  219. package/tests/deps/replace-deps/replace-deps-setup.acc.spec.ts +156 -0
  220. package/tests/electron/electron.spec.ts +4 -1
  221. package/tests/engines/engine-adapter-isolation.spec.ts +5 -6
  222. package/tests/engines/engine-duplicate-output-removal.verify.md +10 -0
  223. package/tests/engines/esbuild-client-engine.acc.spec.ts +79 -0
  224. package/tests/engines/esbuild-client-engine.spec.ts +73 -3
  225. package/tests/esbuild/esbuild-angular-compiler-plugin-hmr.verify.md +23 -0
  226. package/tests/esbuild/esbuild-angular-compiler-plugin-onload.verify.md +21 -0
  227. package/tests/esbuild/esbuild-angular-compiler-plugin-onstart-extraction.verify.md +16 -0
  228. package/tests/esbuild/esbuild-angular-compiler-plugin-sdtscompiler.verify.md +15 -0
  229. package/tests/esbuild/esbuild-angular-compiler-plugin-stylesheet.verify.md +31 -0
  230. package/tests/esbuild/esbuild-angular-compiler-plugin-worker.verify.md +31 -0
  231. package/tests/esbuild/esbuild-angular-compiler-plugin.spec.ts +397 -0
  232. package/tests/esbuild/esbuild-angular-compiler-plugin.verify.md +21 -0
  233. package/tests/esbuild/esbuild-tsc-plugin-imports.verify.md +13 -0
  234. package/tests/esbuild/esbuild-tsc-plugin.acc.spec.ts +56 -111
  235. package/tests/esbuild/esbuild-tsc-plugin.spec.ts +116 -52
  236. package/tests/esbuild/file-reference-tracker.spec.ts +99 -0
  237. package/tests/esbuild/lmdb-cache-store.spec.ts +58 -0
  238. package/tests/esbuild/load-result-cache.acc.spec.ts +55 -0
  239. package/tests/esbuild/load-result-cache.spec.ts +133 -0
  240. package/tests/orchestrators/build-orchestrator.spec.ts +4 -3
  241. package/tests/orchestrators/dev-orchestrator.spec.ts +5 -5
  242. package/tests/orchestrators/slice1-stdout-to-consola.verify.md +10 -0
  243. package/tests/orchestrators/typecheck-orchestrator.spec.ts +1 -1
  244. package/tests/orchestrators/watch-orchestrator.spec.ts +7 -7
  245. package/tests/runtime/result-collector.spec.ts +64 -0
  246. package/tests/sd-cli-entry.spec.ts +3 -4
  247. package/tests/sd-cli-log-tag.verify.md +11 -0
  248. package/tests/ts-compiler/SdTsCompiler-affected-files.verify.md +8 -0
  249. package/tests/ts-compiler/SdTsCompiler-diagnostics.verify.md +12 -0
  250. package/tests/ts-compiler/SdTsCompiler-emit.verify.md +9 -0
  251. package/tests/ts-compiler/SdTsCompiler.acc.spec.ts +603 -0
  252. package/tests/ts-compiler/SdTsCompiler.spec.ts +265 -0
  253. package/tests/ts-compiler/SdTsCompiler.verify.md +41 -0
  254. package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck-browser.tsbuildinfo +1 -0
  255. package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck-node.tsbuildinfo +1 -0
  256. package/tests/ts-compiler/fixtures/non-angular-pkg/.cache/typecheck.tsbuildinfo +1 -0
  257. package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.d.ts +2 -0
  258. package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.d.ts.map +1 -0
  259. package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.js +4 -0
  260. package/tests/ts-compiler/fixtures/non-angular-pkg/dist/index.js.map +1 -0
  261. package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.d.ts +2 -0
  262. package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.d.ts.map +1 -0
  263. package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.js +4 -0
  264. package/tests/ts-compiler/fixtures/non-angular-pkg/dist/util.js.map +1 -0
  265. package/tests/ts-compiler/fixtures/non-angular-pkg/src/index.ts +3 -0
  266. package/tests/ts-compiler/fixtures/non-angular-pkg/src/util.ts +3 -0
  267. package/tests/ts-compiler/fixtures/non-angular-pkg/tests/sample.test-file.ts +3 -0
  268. package/tests/ts-compiler/fixtures/non-angular-pkg/tsconfig.json +12 -0
  269. package/tests/ts-compiler/scss-lint-integration.verify.md +14 -0
  270. package/tests/utils/angular-build.spec.ts +1 -1
  271. package/tests/utils/copy-public-outdir.verify.md +8 -0
  272. package/tests/utils/copy-public.acc.spec.ts +52 -0
  273. package/tests/utils/copy-public.spec.ts +56 -0
  274. package/tests/utils/diagnostic-utils.spec.ts +24 -15
  275. package/tests/utils/engine-watch-events.acc.spec.ts +59 -0
  276. package/tests/utils/engine-watch-events.spec.ts +58 -0
  277. package/tests/utils/esbuild-client-config-integration.verify.md +9 -0
  278. package/tests/utils/esbuild-client-config.acc.spec.ts +45 -61
  279. package/tests/utils/esbuild-client-config.spec.ts +70 -52
  280. package/tests/utils/ngtsc-build-core-write-emit.spec.ts +12 -12
  281. package/tests/utils/ngtsc-build-core.spec.ts +1 -44
  282. package/tests/utils/output-utils.spec.ts +133 -13
  283. package/tests/utils/replace-deps-watch.acc.spec.ts +7 -1
  284. package/tests/utils/replace-deps-watch.spec.ts +57 -1
  285. package/tests/utils/worker-utils.spec.ts +8 -2
  286. package/tests/workers/client-worker-initial-build-error.verify.md +2 -3
  287. package/tests/workers/client-worker-initial-build-warnings.verify.md +7 -0
  288. package/tests/workers/client-worker-refactor.verify.md +22 -0
  289. package/tests/workers/client-worker-ts-cache-invalidation.verify.md +12 -0
  290. package/tests/workers/client-worker.acc.spec.ts +6 -3
  291. package/tests/workers/library-build-lint.spec.ts +40 -45
  292. package/tests/workers/library-build-worker.spec.ts +294 -40
  293. package/tests/workers/server-build-lint.spec.ts +59 -45
  294. package/tests/workers/server-build-worker.spec.ts +63 -24
  295. package/tests/workers/server-esbuild-context.acc.spec.ts +2 -0
  296. package/tests/workers/server-esbuild-context.spec.ts +2 -0
  297. package/tests/workers/server-runtime-worker.spec.ts +1 -1
  298. package/tests/workers/shared-worker-lifecycle.acc.spec.ts +1 -1
  299. package/dist/angular/angular-build-pipeline.d.ts +0 -97
  300. package/dist/angular/angular-build-pipeline.d.ts.map +0 -1
  301. package/dist/angular/angular-build-pipeline.js +0 -285
  302. package/dist/angular/angular-build-pipeline.js.map +0 -1
  303. package/dist/utils/tsc-build.d.ts +0 -51
  304. package/dist/utils/tsc-build.d.ts.map +0 -1
  305. package/dist/utils/tsc-build.js +0 -156
  306. package/dist/utils/tsc-build.js.map +0 -1
  307. package/dist/workers/ngtsc-build.worker.d.ts +0 -23
  308. package/dist/workers/ngtsc-build.worker.d.ts.map +0 -1
  309. package/dist/workers/ngtsc-build.worker.js +0 -267
  310. package/dist/workers/ngtsc-build.worker.js.map +0 -1
  311. package/src/angular/angular-build-pipeline.ts +0 -406
  312. package/src/utils/tsc-build.ts +0 -226
  313. package/src/workers/ngtsc-build.worker.ts +0 -351
  314. package/tests/angular/angular-build-pipeline.spec.ts +0 -247
  315. package/tests/angular/angular-compiler-aot.acc.spec.ts +0 -68
  316. package/tests/angular/angular-compiler-aot.spec.ts +0 -80
  317. package/tests/utils/angular-compiler-emit.spec.ts +0 -666
  318. package/tests/utils/angular-compiler.spec.ts +0 -707
  319. package/tests/utils/tsc-build.spec.ts +0 -527
  320. package/tests/workers/ngtsc-build-lint.spec.ts +0 -141
  321. package/tests/workers/ngtsc-build-worker.spec.ts +0 -199
@@ -1,527 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
- import path from "path";
3
- import type ts from "typescript";
4
-
5
- // Mocks
6
-
7
- const PKG_DIR = path.resolve("/pkg");
8
- const SRC_DIR = path.join(PKG_DIR, "src");
9
- const SRC_INDEX = path.join(SRC_DIR, "index.ts");
10
- const SRC_UTIL = path.join(SRC_DIR, "util.ts");
11
- const TEST_INDEX = path.join(PKG_DIR, "tests", "index.spec.ts");
12
-
13
- const mockParsedConfig: ts.ParsedCommandLine = {
14
- options: { target: 1, module: 99, strict: true },
15
- fileNames: [SRC_INDEX, SRC_UTIL, TEST_INDEX],
16
- errors: [],
17
- };
18
-
19
- const mockGetCompilerOptionsForEnv = vi.fn(
20
- (baseOptions: ts.CompilerOptions, _env: string, _pkgDir: string) => ({
21
- ...baseOptions,
22
- __envApplied: true,
23
- }),
24
- );
25
-
26
- vi.mock("../../src/utils/tsconfig", () => ({
27
- parseTsconfig: vi.fn(() => mockParsedConfig),
28
- getPackageSourceFiles: vi.fn(() => [SRC_INDEX, SRC_UTIL]),
29
- getPackageFiles: vi.fn(() => [SRC_INDEX, SRC_UTIL, TEST_INDEX]),
30
- getCompilerOptionsForEnv: (baseOptions: ts.CompilerOptions, env: string, pkgDir: string) => mockGetCompilerOptionsForEnv(baseOptions, env, pkgDir),
31
- }));
32
-
33
- const mockRewritePath = vi.fn(
34
- (fileName: string, content: string) => [fileName, content] as [string, string],
35
- );
36
- vi.mock("../../src/utils/output-path-rewriter", () => ({
37
- createOutputPathRewriter: vi.fn(() => mockRewritePath),
38
- addJsExtensionToImports: vi.fn((text: string) => text + "/* js-ext-applied */"),
39
- }));
40
-
41
- vi.mock("../../src/typecheck/typecheck-serialization", () => ({
42
- serializeDiagnostic: vi.fn((d: any) => ({ code: d.code, category: d.category })),
43
- }));
44
-
45
- let mockEmitResult: { diagnostics: ts.Diagnostic[] };
46
- let mockTsProgram: Record<string, unknown>;
47
- let mockProgram: {
48
- emit: ReturnType<typeof vi.fn>;
49
- getConfigFileParsingDiagnostics: ReturnType<typeof vi.fn>;
50
- getSyntacticDiagnostics: ReturnType<typeof vi.fn>;
51
- getOptionsDiagnostics: ReturnType<typeof vi.fn>;
52
- getGlobalDiagnostics: ReturnType<typeof vi.fn>;
53
- getSemanticDiagnostics: ReturnType<typeof vi.fn>;
54
- getSemanticDiagnosticsOfNextAffectedFile: ReturnType<typeof vi.fn>;
55
- getProgram: ReturnType<typeof vi.fn>;
56
- };
57
- let capturedOptions: ts.CompilerOptions | undefined;
58
- let capturedHost: any;
59
-
60
- vi.mock("typescript", () => {
61
- const DiagnosticCategory = { Warning: 0, Error: 1, Suggestion: 2, Message: 3 };
62
- return {
63
- default: {
64
- DiagnosticCategory,
65
- createIncrementalCompilerHost: vi.fn((options: ts.CompilerOptions) => {
66
- capturedOptions = options;
67
- capturedHost = { writeFile: vi.fn() };
68
- return capturedHost;
69
- }),
70
- createEmitAndSemanticDiagnosticsBuilderProgram: vi.fn(() => mockProgram),
71
- flattenDiagnosticMessageText: vi.fn((msg: string) => msg),
72
- },
73
- };
74
- });
75
-
76
- describe("runTscPackageBuild", () => {
77
- beforeEach(() => {
78
- vi.clearAllMocks();
79
- capturedOptions = undefined;
80
- capturedHost = undefined;
81
- mockEmitResult = { diagnostics: [] };
82
- mockTsProgram = { __isTsProgram: true };
83
- mockProgram = {
84
- emit: vi.fn(() => mockEmitResult),
85
- getConfigFileParsingDiagnostics: vi.fn(() => []),
86
- getSyntacticDiagnostics: vi.fn(() => []),
87
- getOptionsDiagnostics: vi.fn(() => []),
88
- getGlobalDiagnostics: vi.fn(() => []),
89
- getSemanticDiagnostics: vi.fn(() => []),
90
- getSemanticDiagnosticsOfNextAffectedFile: vi.fn(() => undefined),
91
- getProgram: vi.fn(() => mockTsProgram),
92
- };
93
- });
94
-
95
- describe("output modes", () => {
96
- // Acceptance: Scenario "JS + DTS 모두 emit"
97
- it("output {js:true, dts:true} sets JS+DTS compilerOptions", async () => {
98
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
99
- const result = runTscPackageBuild({
100
- pkgDir: PKG_DIR,
101
- cwd: path.resolve("/"),
102
- output: { js: true, dts: true },
103
- });
104
-
105
- expect(result.success).toBe(true);
106
- expect(capturedOptions!.noEmit).toBe(false);
107
- expect(capturedOptions!.declaration).toBe(true);
108
- expect(capturedOptions!.declarationMap).toBe(true);
109
- expect(capturedOptions!.emitDeclarationOnly).toBe(false);
110
- expect(capturedOptions!.sourceMap).toBe(true);
111
- expect(capturedOptions!.outDir).toBe(path.join(PKG_DIR, "dist"));
112
- });
113
-
114
- // Acceptance: Scenario "JS만 emit"
115
- it("output {js:true, dts:false} sets JS-only compilerOptions", async () => {
116
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
117
- runTscPackageBuild({
118
- pkgDir: PKG_DIR,
119
- cwd: path.resolve("/"),
120
- output: { js: true, dts: false },
121
- });
122
-
123
- expect(capturedOptions!.noEmit).toBe(false);
124
- expect(capturedOptions!.declaration).toBe(false);
125
- expect(capturedOptions!.declarationMap).toBe(false);
126
- expect(capturedOptions!.emitDeclarationOnly).toBe(false);
127
- expect(capturedOptions!.sourceMap).toBe(true);
128
- expect(capturedOptions!.outDir).toBe(path.join(PKG_DIR, "dist"));
129
- });
130
-
131
- // Acceptance: Scenario "DTS만 emit"
132
- it("output {js:false, dts:true} sets DTS-only compilerOptions", async () => {
133
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
134
- runTscPackageBuild({
135
- pkgDir: PKG_DIR,
136
- cwd: path.resolve("/"),
137
- output: { js: false, dts: true },
138
- });
139
-
140
- expect(capturedOptions!.noEmit).toBe(false);
141
- expect(capturedOptions!.declaration).toBe(true);
142
- expect(capturedOptions!.declarationMap).toBe(true);
143
- expect(capturedOptions!.emitDeclarationOnly).toBe(true);
144
- expect(capturedOptions!.sourceMap).toBe(false);
145
- expect(capturedOptions!.outDir).toBe(path.join(PKG_DIR, "dist"));
146
- });
147
-
148
- // Acceptance: Scenario "typecheck만 실행 (emit 없음)"
149
- it("output {js:false, dts:false} sets noEmit compilerOptions", async () => {
150
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
151
- runTscPackageBuild({
152
- pkgDir: PKG_DIR,
153
- cwd: path.resolve("/"),
154
- output: { js: false, dts: false },
155
- });
156
-
157
- expect(capturedOptions!.noEmit).toBe(true);
158
- expect(capturedOptions!.declaration).toBe(false);
159
- expect(capturedOptions!.declarationMap).toBe(false);
160
- });
161
- });
162
-
163
- describe("file selection and build info", () => {
164
- // Unit: emit modes use src files, typecheck uses all files
165
- it("emit mode uses only source files as rootNames", async () => {
166
- const tsModule = await import("typescript");
167
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
168
-
169
- runTscPackageBuild({
170
- pkgDir: PKG_DIR,
171
- cwd: path.resolve("/"),
172
- output: { js: true, dts: true },
173
- });
174
-
175
- // createEmitAndSemanticDiagnosticsBuilderProgram(rootNames, options, host, oldBuilderProgram)
176
- expect(vi.mocked(tsModule.default.createEmitAndSemanticDiagnosticsBuilderProgram)).toHaveBeenCalledWith(
177
- [SRC_INDEX, SRC_UTIL],
178
- expect.any(Object),
179
- expect.any(Object),
180
- undefined,
181
- );
182
- });
183
-
184
- it("typecheck mode without includeTests uses only source files as rootNames", async () => {
185
- const tsModule = await import("typescript");
186
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
187
-
188
- runTscPackageBuild({
189
- pkgDir: PKG_DIR,
190
- cwd: path.resolve("/"),
191
- output: { js: false, dts: false },
192
- });
193
-
194
- expect(vi.mocked(tsModule.default.createEmitAndSemanticDiagnosticsBuilderProgram)).toHaveBeenCalledWith(
195
- [SRC_INDEX, SRC_UTIL],
196
- expect.any(Object),
197
- expect.any(Object),
198
- undefined,
199
- );
200
- });
201
-
202
- it("typecheck mode with includeTests uses all package files as rootNames", async () => {
203
- const tsModule = await import("typescript");
204
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
205
-
206
- runTscPackageBuild({
207
- pkgDir: PKG_DIR,
208
- cwd: path.resolve("/"),
209
- output: { js: false, dts: false },
210
- includeTests: true,
211
- });
212
-
213
- expect(vi.mocked(tsModule.default.createEmitAndSemanticDiagnosticsBuilderProgram)).toHaveBeenCalledWith(
214
- [SRC_INDEX, SRC_UTIL, TEST_INDEX],
215
- expect.any(Object),
216
- expect.any(Object),
217
- undefined,
218
- );
219
- });
220
-
221
- // Unit: tsBuildInfoFile path differs by emit vs typecheck
222
- it("emit mode uses build.tsbuildinfo", async () => {
223
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
224
- runTscPackageBuild({
225
- pkgDir: PKG_DIR,
226
- cwd: path.resolve("/"),
227
- output: { js: true, dts: true },
228
- });
229
- expect(capturedOptions!.tsBuildInfoFile).toBe(path.join(PKG_DIR, ".cache", "build.tsbuildinfo"));
230
- });
231
-
232
- it("typecheck mode uses typecheck.tsbuildinfo", async () => {
233
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
234
- runTscPackageBuild({
235
- pkgDir: PKG_DIR,
236
- cwd: path.resolve("/"),
237
- output: { js: false, dts: false },
238
- });
239
- expect(capturedOptions!.tsBuildInfoFile).toBe(path.join(PKG_DIR, ".cache", "typecheck.tsbuildinfo"));
240
- });
241
- });
242
-
243
- describe("path rewriting", () => {
244
- // Unit: path rewriter is applied in emit modes
245
- it("applies path rewriter in emit mode", async () => {
246
- const { createOutputPathRewriter } = await import("../../src/utils/output-path-rewriter");
247
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
248
-
249
- runTscPackageBuild({
250
- pkgDir: PKG_DIR,
251
- cwd: path.resolve("/"),
252
- output: { js: true, dts: true },
253
- });
254
- expect(createOutputPathRewriter).toHaveBeenCalledWith(PKG_DIR);
255
- });
256
-
257
- it("does not apply path rewriter in typecheck mode", async () => {
258
- const { createOutputPathRewriter } = await import("../../src/utils/output-path-rewriter");
259
- vi.mocked(createOutputPathRewriter).mockClear();
260
-
261
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
262
- runTscPackageBuild({
263
- pkgDir: PKG_DIR,
264
- cwd: path.resolve("/"),
265
- output: { js: false, dts: false },
266
- });
267
- expect(createOutputPathRewriter).not.toHaveBeenCalled();
268
- });
269
-
270
- // Unit: JS extension rewriter is applied to .js files in writeFile hook
271
- it("applies addJsExtensionToImports for .js files via writeFile hook", async () => {
272
- const { addJsExtensionToImports } = await import("../../src/utils/output-path-rewriter");
273
- vi.mocked(addJsExtensionToImports).mockClear();
274
- mockRewritePath.mockImplementation(
275
- (fileName: string, content: string) => [fileName, content] as [string, string],
276
- );
277
-
278
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
279
- runTscPackageBuild({
280
- pkgDir: PKG_DIR,
281
- cwd: path.resolve("/"),
282
- output: { js: true, dts: true },
283
- });
284
-
285
- // Simulate writeFile call with a .js file
286
- const hookedWriteFile = capturedHost.writeFile;
287
- hookedWriteFile("dist/index.js", 'import { x } from "./foo";', false);
288
-
289
- expect(addJsExtensionToImports).toHaveBeenCalledWith('import { x } from "./foo";');
290
- });
291
-
292
- it("does not apply addJsExtensionToImports for .d.ts files", async () => {
293
- const { addJsExtensionToImports } = await import("../../src/utils/output-path-rewriter");
294
- vi.mocked(addJsExtensionToImports).mockClear();
295
- mockRewritePath.mockImplementation(
296
- (fileName: string, content: string) => [fileName, content] as [string, string],
297
- );
298
-
299
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
300
- runTscPackageBuild({
301
- pkgDir: PKG_DIR,
302
- cwd: path.resolve("/"),
303
- output: { js: false, dts: true },
304
- });
305
-
306
- // Simulate writeFile call with a .d.ts file
307
- const hookedWriteFile = capturedHost.writeFile;
308
- hookedWriteFile("dist/index.d.ts", 'import type { x } from "./foo";', false);
309
-
310
- expect(addJsExtensionToImports).not.toHaveBeenCalled();
311
- });
312
- });
313
-
314
- describe("diagnostics", () => {
315
- // Unit: diagnostics are collected and returned
316
- it("collects error diagnostics and returns failure", async () => {
317
- const errorDiag: Partial<ts.Diagnostic> = {
318
- category: 1, // Error
319
- code: 2345,
320
- messageText: "Type 'string' is not assignable to type 'number'",
321
- file: { fileName: SRC_INDEX, getLineAndCharacterOfPosition: () => ({ line: 5, character: 10 }) } as any,
322
- start: 100,
323
- };
324
- mockProgram.getSemanticDiagnostics.mockReturnValue([errorDiag]);
325
-
326
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
327
- const result = runTscPackageBuild({
328
- pkgDir: PKG_DIR,
329
- cwd: path.resolve("/"),
330
- output: { js: true, dts: true },
331
- });
332
-
333
- expect(result.success).toBe(false);
334
- expect(result.errorCount).toBe(1);
335
- expect(result.errors![0]).toContain("TS2345");
336
- });
337
-
338
- // Unit: includes workspace diagnostics, excludes node_modules
339
- it("includes workspace diagnostics and excludes node_modules", async () => {
340
- const CWD = path.resolve("/");
341
- const ownDiag: Partial<ts.Diagnostic> = {
342
- category: 1,
343
- code: 1001,
344
- messageText: "own error",
345
- file: { fileName: SRC_INDEX, getLineAndCharacterOfPosition: () => ({ line: 0, character: 0 }) } as any,
346
- start: 0,
347
- };
348
- const depDiag: Partial<ts.Diagnostic> = {
349
- category: 1,
350
- code: 1003,
351
- messageText: "workspace dep error",
352
- file: { fileName: path.join(CWD, "other-pkg", "src", "index.ts"), getLineAndCharacterOfPosition: () => ({ line: 0, character: 0 }) } as any,
353
- start: 0,
354
- };
355
- const nodeModulesDiag: Partial<ts.Diagnostic> = {
356
- category: 1,
357
- code: 1002,
358
- messageText: "node_modules error",
359
- file: { fileName: path.join(CWD, "node_modules", "dep", "index.ts"), getLineAndCharacterOfPosition: () => ({ line: 0, character: 0 }) } as any,
360
- start: 0,
361
- };
362
- mockProgram.getSemanticDiagnostics.mockReturnValue([ownDiag, depDiag, nodeModulesDiag]);
363
-
364
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
365
- const result = runTscPackageBuild({
366
- pkgDir: PKG_DIR,
367
- cwd: CWD,
368
- output: { js: true, dts: true },
369
- });
370
-
371
- // Workspace diagnostics included (own + dep), node_modules excluded
372
- expect(result.errorCount).toBe(2);
373
- expect(result.errors![0]).toContain("TS1001");
374
- expect(result.errors![1]).toContain("TS1003");
375
- });
376
-
377
- // Unit: parsedConfig passed → skips parseTsconfig
378
- it("uses provided parsedConfig instead of calling parseTsconfig", async () => {
379
- const { parseTsconfig } = await import("../../src/utils/tsconfig");
380
- vi.mocked(parseTsconfig).mockClear();
381
-
382
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
383
- runTscPackageBuild({
384
- pkgDir: PKG_DIR,
385
- cwd: path.resolve("/"),
386
- output: { js: true, dts: true },
387
- parsedConfig: mockParsedConfig as any,
388
- });
389
-
390
- expect(parseTsconfig).not.toHaveBeenCalled();
391
- });
392
-
393
- // Unit: exception handling
394
- it("returns error result on exception", async () => {
395
- const { parseTsconfig } = await import("../../src/utils/tsconfig");
396
- vi.mocked(parseTsconfig).mockImplementationOnce(() => { throw new Error("tsconfig not found"); });
397
-
398
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
399
- const result = runTscPackageBuild({
400
- pkgDir: PKG_DIR,
401
- cwd: path.resolve("/"),
402
- output: { js: true, dts: true },
403
- });
404
-
405
- expect(result.success).toBe(false);
406
- expect(result.errorCount).toBe(1);
407
- expect(result.errors![0]).toBe("tsconfig not found");
408
- });
409
- });
410
-
411
- describe("env handling", () => {
412
- // Acceptance: Scenario "build 시 패키지 tsconfig의 lib/types 유지" (env 미설정)
413
- it("does not call getCompilerOptionsForEnv when env is not set", async () => {
414
- mockGetCompilerOptionsForEnv.mockClear();
415
-
416
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
417
- runTscPackageBuild({
418
- pkgDir: PKG_DIR,
419
- cwd: path.resolve("/"),
420
- output: { js: true, dts: true },
421
- });
422
-
423
- expect(mockGetCompilerOptionsForEnv).not.toHaveBeenCalled();
424
- });
425
-
426
- // Acceptance: Scenario "typecheck 명령에서만 env 조작"
427
- it("calls getCompilerOptionsForEnv when env is set", async () => {
428
- mockGetCompilerOptionsForEnv.mockClear();
429
-
430
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
431
- runTscPackageBuild({
432
- pkgDir: PKG_DIR,
433
- cwd: path.resolve("/"),
434
- output: { js: false, dts: false },
435
- env: "node",
436
- });
437
-
438
- expect(mockGetCompilerOptionsForEnv).toHaveBeenCalledWith(
439
- mockParsedConfig.options,
440
- "node",
441
- PKG_DIR,
442
- );
443
- });
444
-
445
- // Unit: env-adjusted options are used in compilerOptions
446
- it("uses env-adjusted options as base for compilerOptions", async () => {
447
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
448
- runTscPackageBuild({
449
- pkgDir: PKG_DIR,
450
- cwd: path.resolve("/"),
451
- output: { js: false, dts: false },
452
- env: "browser",
453
- });
454
-
455
- expect((capturedOptions as any).__envApplied).toBe(true);
456
- });
457
-
458
- // Unit: tsBuildInfoFile includes env suffix for typecheck mode
459
- it("uses typecheck-node.tsbuildinfo when env is node", async () => {
460
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
461
- runTscPackageBuild({
462
- pkgDir: PKG_DIR,
463
- cwd: path.resolve("/"),
464
- output: { js: false, dts: false },
465
- env: "node",
466
- });
467
- expect(capturedOptions!.tsBuildInfoFile).toBe(
468
- path.join(PKG_DIR, ".cache", "typecheck-node.tsbuildinfo"),
469
- );
470
- });
471
-
472
- it("uses typecheck-browser.tsbuildinfo when env is browser", async () => {
473
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
474
- runTscPackageBuild({
475
- pkgDir: PKG_DIR,
476
- cwd: path.resolve("/"),
477
- output: { js: false, dts: false },
478
- env: "browser",
479
- });
480
- expect(capturedOptions!.tsBuildInfoFile).toBe(
481
- path.join(PKG_DIR, ".cache", "typecheck-browser.tsbuildinfo"),
482
- );
483
- });
484
-
485
- // Unit: env suffix IS applied in emit mode (distinguishes build artifacts by env)
486
- it("adds env suffix to tsBuildInfoFile in emit mode", async () => {
487
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
488
- runTscPackageBuild({
489
- pkgDir: PKG_DIR,
490
- cwd: path.resolve("/"),
491
- output: { js: true, dts: true },
492
- env: "node",
493
- });
494
- expect(capturedOptions!.tsBuildInfoFile).toBe(
495
- path.join(PKG_DIR, ".cache", "build-node.tsbuildinfo"),
496
- );
497
- });
498
- });
499
-
500
- describe("affected files", () => {
501
- // Acceptance: Scenario "tsc-build exposes affected files for incremental lint"
502
- it("returns affectedFiles set from builder program diagnostics iteration", async () => {
503
- // Set up builder program mock to return affected files via getSemanticDiagnosticsOfNextAffectedFile
504
- const affectedFile1 = { fileName: SRC_INDEX } as any;
505
- const affectedFile2 = { fileName: SRC_UTIL } as any;
506
- let callCount = 0;
507
- mockProgram.getSemanticDiagnosticsOfNextAffectedFile = vi.fn(() => {
508
- callCount++;
509
- if (callCount === 1) return { affected: affectedFile1, result: [] };
510
- if (callCount === 2) return { affected: affectedFile2, result: [] };
511
- return undefined;
512
- });
513
-
514
- const { runTscPackageBuild } = await import("../../src/utils/tsc-build");
515
- const result = runTscPackageBuild({
516
- pkgDir: PKG_DIR,
517
- cwd: path.resolve("/"),
518
- output: { js: true, dts: true },
519
- });
520
-
521
- expect(result.affectedFiles).toBeDefined();
522
- expect(result.affectedFiles!.has(SRC_INDEX.replace(/\\/g, "/"))).toBe(true);
523
- expect(result.affectedFiles!.has(SRC_UTIL.replace(/\\/g, "/"))).toBe(true);
524
- });
525
- });
526
-
527
- });
@@ -1,141 +0,0 @@
1
- import { describe, it, expect, vi, beforeEach } from "vitest";
2
-
3
- // --- Mocks ---
4
-
5
- const { mockLintFn, MockLintWithProgramRunner } = vi.hoisted(() => {
6
- const lintFn = vi.fn().mockResolvedValue({
7
- success: true,
8
- errorCount: 0,
9
- warningCount: 0,
10
- formattedOutput: "",
11
- });
12
- const RunnerCls = vi.fn().mockImplementation(function () {
13
- return { lint: lintFn };
14
- });
15
- return { mockLintFn: lintFn, MockLintWithProgramRunner: RunnerCls };
16
- });
17
-
18
- vi.mock("../../src/lint/lint-with-program", () => ({
19
- LintWithProgramRunner: MockLintWithProgramRunner,
20
- }));
21
-
22
- const mockTsProgram = { getSourceFiles: () => [] };
23
-
24
- const mockPipelineInstance = {
25
- initialize: vi.fn().mockResolvedValue({
26
- affectedFiles: new Set(),
27
- diagnostics: { errors: [], warnings: [] },
28
- scssErrors: [],
29
- }),
30
- writeEmitResults: vi.fn(),
31
- collectRawDiagnostics: vi.fn().mockReturnValue([]),
32
- getDiagnostics: vi.fn().mockReturnValue({ errors: [], warnings: [] }),
33
- getScssErrors: vi.fn().mockReturnValue([]),
34
- getTsProgram: vi.fn().mockReturnValue(mockTsProgram),
35
- findAffectedByScss: vi.fn().mockReturnValue([]),
36
- clearScssDependencies: vi.fn(),
37
- update: vi.fn().mockResolvedValue({
38
- affectedFiles: new Set(),
39
- diagnostics: { errors: [], warnings: [] },
40
- scssErrors: [],
41
- }),
42
- };
43
-
44
- vi.mock("../../src/angular/angular-build-pipeline", () => ({
45
- AngularBuildPipeline: vi.fn().mockImplementation(function () {
46
- return mockPipelineInstance;
47
- }),
48
- }));
49
-
50
- vi.mock("../../src/angular/ngtsc-build-core", () => ({
51
- buildCompilerOptions: vi.fn(() => ({})),
52
- buildScssLoadPaths: vi.fn(() => []),
53
- compileSideEffectScss: vi.fn(),
54
- compileGlobalScss: vi.fn(() => []),
55
- }));
56
-
57
- vi.mock("../../src/utils/tsconfig", async (importOriginal) => {
58
- const original = await importOriginal<typeof import("../../src/utils/tsconfig")>();
59
- return {
60
- ...original,
61
- parseTsconfig: vi.fn(() => ({ options: {}, fileNames: [], errors: [] })),
62
- };
63
- });
64
-
65
- vi.mock("../../src/runtime/worker-utils", () => ({
66
- registerCleanupHandlers: vi.fn(),
67
- createOnceGuard: vi.fn(() => vi.fn()),
68
- setupWorkerConsola: vi.fn(),
69
- }));
70
-
71
- vi.mock("@simplysm/core-node", () => ({
72
- createWorker: vi.fn(
73
- (methods: Record<string, Function>) => {
74
- Object.assign(workerMethods, methods);
75
- return { send: vi.fn() };
76
- },
77
- ),
78
- FsWatcher: { watch: vi.fn() },
79
- pathx: {
80
- posix: vi.fn((p: string) => p.replace(/\\/g, "/")),
81
- posixResolve: vi.fn((...parts: string[]) => parts.join("/")),
82
- },
83
- }));
84
-
85
- const workerMethods: Record<string, Function> = {};
86
-
87
- await import("../../src/workers/ngtsc-build.worker");
88
-
89
- // --- Tests ---
90
-
91
- beforeEach(() => {
92
- vi.clearAllMocks();
93
- mockLintFn.mockResolvedValue({
94
- success: true,
95
- errorCount: 0,
96
- warningCount: 0,
97
- formattedOutput: "",
98
- });
99
- mockPipelineInstance.initialize.mockResolvedValue({
100
- affectedFiles: new Set(),
101
- diagnostics: { errors: [], warnings: [] },
102
- scssErrors: [],
103
- });
104
- mockPipelineInstance.collectRawDiagnostics.mockReturnValue([]);
105
- mockPipelineInstance.getDiagnostics.mockReturnValue({ errors: [], warnings: [] });
106
- mockPipelineInstance.getScssErrors.mockReturnValue([]);
107
- mockPipelineInstance.getTsProgram.mockReturnValue(mockTsProgram);
108
- });
109
-
110
- describe("ngtsc-build.worker lint integration (Slice 4)", () => {
111
- describe("Scenario: ngtsc-build.worker runs lint after typecheck (one-time build)", () => {
112
- it("returns lint result when lint is enabled", async () => {
113
- const result = await workerMethods["build"]({
114
- name: "my-angular-lib",
115
- cwd: "/workspace",
116
- pkgDir: "/workspace/packages/my-angular-lib",
117
- output: { js: true, dts: true, lint: true },
118
- });
119
-
120
- expect(result.lint).toEqual({
121
- success: true,
122
- errorCount: 0,
123
- warningCount: 0,
124
- formattedOutput: "",
125
- });
126
- });
127
- });
128
-
129
- describe("Scenario: lint disabled", () => {
130
- it("does not run lint when output.lint is not set", async () => {
131
- const result = await workerMethods["build"]({
132
- name: "my-angular-lib",
133
- cwd: "/workspace",
134
- pkgDir: "/workspace/packages/my-angular-lib",
135
- output: { js: true, dts: true },
136
- });
137
-
138
- expect(result.lint).toBeUndefined();
139
- });
140
- });
141
- });