From 22322e5f0a3952339ac9cf01c5b9a3d5e9fe70c8 Mon Sep 17 00:00:00 2001 From: Brendan Chen Date: Thu, 20 Nov 2025 16:52:56 -0800 Subject: [PATCH] Add a separate tsconfig for excluding tests/mocks from builds, while leaving them for type checks --- package.json | 4 ++-- tsconfig.build.json | 15 +++++++++++++++ tsconfig.json | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 tsconfig.build.json diff --git a/package.json b/package.json index f0a7798..bd558b4 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "", "main": "dist/index.js", "scripts": { - "build:dev": "npm install --include=dev && npm run generate && tsc", - "build": "npm install --include=dev && npm run generate && tsc && npm prune --omit=dev", + "build:dev": "npm install --include=dev && npm run generate && tsc --project tsconfig.build.json", + "build": "npm install --include=dev && npm run generate && tsc --project tsconfig.build.json && npm prune --omit=dev", "start:dev": "npm run build:dev && node ./dist/index.js", "start": "npm run build && node ./dist/index.js", "generate": "graphql-codegen --config codegen.ts", diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..37ac446 --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,15 @@ +// For builds, excludes tests and mocks +{ + "compilerOptions": { + "target": "es2016", + "module": "commonjs", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "outDir": "dist", + "sourceMap": true + }, + "include": ["src"], + "exclude": ["**/__tests__/*/**", "**/__mocks__/*/**"] +} diff --git a/tsconfig.json b/tsconfig.json index dfc1303..57e4d7f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,3 +1,4 @@ +// For type-checking, includes tests and mocks { "compilerOptions": { "target": "es2016", @@ -10,5 +11,4 @@ "sourceMap": true }, "include": ["src"], - "exclude": ["**/__tests__/*/**", "**/__mocks__/*/**"] }