Skip to content

Commit

Permalink
🔧 Type-check tests in CI pipeline
Browse files Browse the repository at this point in the history
By excluding test files in the `tsconfig.json` file, the TypeScript
compiler did not check these files. Consequently, issues in the tests
only showed up in the editor, but not in the CI build.

This commit removes the patterns for test files from the `exclude`
section in the `tsconfig.json` file. To ensure that only relevant files
end up in the `dist` directory, we let the TypeScript compiler write to
a `build/` directory and then copy the necessary files to `dist/`.
  • Loading branch information
ralfstx committed Oct 3, 2024
1 parent 52a8f04 commit 8d060fc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules/

# build output
dist/
build/
out/
coverage/
*.tgz
Expand Down
6 changes: 1 addition & 5 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,4 @@
!LICENSE.*
!CHANGELOG.*
!README.*

!dist/*.js
!dist/*.js.map
!dist/index.d.ts
!dist/api/*.d.ts
!dist/**/*
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"npm": ">=8"
},
"scripts": {
"build": "rm -rf dist/ && tsc && esbuild src/index.ts --bundle --sourcemap --platform=node --target=es2021,node18 --outdir=dist --format=esm --external:pdf-lib --external:@pdf-lib/fontkit",
"build": "rm -rf build/ dist/ && tsc && esbuild src/index.ts --bundle --sourcemap --platform=node --target=es2021,node18 --outdir=dist --format=esm --external:pdf-lib --external:@pdf-lib/fontkit && cp -a build/index.d.ts build/api/ dist/",
"lint": "eslint '{src,test}/**/*.{js,ts}' --max-warnings 0 && prettier --check .",
"test": "vitest run test",
"fix": "eslint '{src,test}/**/*.{js,ts}' --fix && prettier -w ."
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"module": "NodeNext",
"target": "ES6",
"lib": ["ES2021", "DOM"],
"outDir": "dist",
"outDir": "build",
"paths": {
"src/*": ["./src/*"]
},
Expand All @@ -20,5 +20,5 @@
"stripInternal": true
},
"include": ["src/**/*.ts", "src/**/*.d.ts"],
"exclude": ["node_modules", "dist", "src/**/test/", "src/**/*.test.ts"]
"exclude": ["node_modules", "dist"]
}

0 comments on commit 8d060fc

Please sign in to comment.