From b2d4c7125e171c421c77bfa110bdb21bd7f1bb65 Mon Sep 17 00:00:00 2001 From: Haksung Jang Date: Sat, 13 Jun 2026 00:41:44 +0900 Subject: [PATCH] fix(frontend): stop type-checking tests in the production image build The v0.11.0 trusca-frontend image build failed: Dockerfile.prod runs `npm run build` (`tsc -b`), tsconfig.app.json included `tests`, and the catalog-mirror contract test imports the shared catalog JSON from the REPO ROOT (../../tests/contracts/), which does not exist inside the image build context (apps/frontend only) -> TS2307. First image build since the validation-campaign contract tests landed, so first exposure. Split the projects: tsconfig.app.json now covers src only (and drops the test-only ambient types); a new tsconfig.spec.json owns src+tests and is referenced from tsconfig.json, so CI's `npm run typecheck` (`tsc -b`) still type-checks tests exactly as before. `npm run build` builds only the app+node projects, which is all the production bundle needs. Verified: full typecheck clean, app-only tsc clean (the Docker path), contract vitest 12/12. --- apps/frontend/package.json | 2 +- apps/frontend/tsconfig.app.json | 4 ++-- apps/frontend/tsconfig.json | 3 ++- apps/frontend/tsconfig.spec.json | 36 ++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 apps/frontend/tsconfig.spec.json diff --git a/apps/frontend/package.json b/apps/frontend/package.json index ae5f90e7..080f0624 100644 --- a/apps/frontend/package.json +++ b/apps/frontend/package.json @@ -7,7 +7,7 @@ "type": "module", "scripts": { "dev": "vite", - "build": "tsc -b && vite build", + "build": "tsc -b tsconfig.app.json tsconfig.node.json && vite build", "preview": "vite preview", "lint": "eslint .", "typecheck": "tsc -b --noEmit", diff --git a/apps/frontend/tsconfig.app.json b/apps/frontend/tsconfig.app.json index 45567d14..7a1854d3 100644 --- a/apps/frontend/tsconfig.app.json +++ b/apps/frontend/tsconfig.app.json @@ -23,7 +23,7 @@ "paths": { "@/*": ["./src/*"] }, - "types": ["vite/client", "vitest/globals", "@testing-library/jest-dom"] + "types": ["vite/client"] }, - "include": ["src", "tests"] + "include": ["src"] } diff --git a/apps/frontend/tsconfig.json b/apps/frontend/tsconfig.json index 1ffef600..32fef050 100644 --- a/apps/frontend/tsconfig.json +++ b/apps/frontend/tsconfig.json @@ -2,6 +2,7 @@ "files": [], "references": [ { "path": "./tsconfig.app.json" }, - { "path": "./tsconfig.node.json" } + { "path": "./tsconfig.node.json" }, + { "path": "./tsconfig.spec.json" } ] } diff --git a/apps/frontend/tsconfig.spec.json b/apps/frontend/tsconfig.spec.json new file mode 100644 index 00000000..418d3582 --- /dev/null +++ b/apps/frontend/tsconfig.spec.json @@ -0,0 +1,36 @@ +{ + // Test-only TypeScript project. Split out of tsconfig.app.json so the + // PRODUCTION image build (`npm run build` -> `tsc -b tsconfig.app.json ...`) + // never type-checks tests: the contract tests import shared catalogs from + // the REPO ROOT (e.g. ../../tests/contracts/*.json), which does not exist + // inside the Docker build context (apps/frontend only) and broke the + // v0.11.0 trusca-frontend image build. CI's `npm run typecheck` + // (`tsc -b --noEmit`) still builds every referenced project, tests included. + "compilerOptions": { + "composite": true, + "tsBuildInfoFile": "./node_modules/.tmp/tsconfig.spec.tsbuildinfo", + "target": "ES2022", + "useDefineForClassFields": true, + "lib": ["ES2022", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "moduleDetection": "force", + "noEmit": true, + "jsx": "react-jsx", + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true, + "noUncheckedSideEffectImports": true, + "baseUrl": ".", + "paths": { + "@/*": ["./src/*"] + }, + "types": ["vite/client", "vitest/globals", "@testing-library/jest-dom"] + }, + "include": ["src", "tests"] +}