Add a separate tsconfig for excluding tests/mocks from builds, while leaving them for type checks

This commit is contained in:
2025-11-20 16:52:56 -08:00
parent a9db9b5d5c
commit 22322e5f0a
3 changed files with 18 additions and 3 deletions

View File

@@ -4,8 +4,8 @@
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"build:dev": "npm install --include=dev && npm run generate && tsc", "build:dev": "npm install --include=dev && npm run generate && tsc --project tsconfig.build.json",
"build": "npm install --include=dev && npm run generate && tsc && npm prune --omit=dev", "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:dev": "npm run build:dev && node ./dist/index.js",
"start": "npm run build && node ./dist/index.js", "start": "npm run build && node ./dist/index.js",
"generate": "graphql-codegen --config codegen.ts", "generate": "graphql-codegen --config codegen.ts",

15
tsconfig.build.json Normal file
View File

@@ -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__/*/**"]
}

View File

@@ -1,3 +1,4 @@
// For type-checking, includes tests and mocks
{ {
"compilerOptions": { "compilerOptions": {
"target": "es2016", "target": "es2016",
@@ -10,5 +11,4 @@
"sourceMap": true "sourceMap": true
}, },
"include": ["src"], "include": ["src"],
"exclude": ["**/__tests__/*/**", "**/__mocks__/*/**"]
} }