A template project for javascript library (for browsers or Node.js) and/or executable for Node.js.
- Static analysis of code with ESLint
- Code format checking with Prettier
- Type checking of TypeScript with tsc
- Credential checking with secretlint
(if modifiable) Code fixes by ESLint and Prettier
- Build library entry points for both ESM and CJS by tsup
- Build an executable that runs in ESM mode by tsup
Testing by Vitest
Watching mode of build
Sometimes the test hangs due to problems outside of Vitest. In that case, it can be fixed by vitest.config.ts with pool: "forks"
.
There are scripts in the `scripts' directory to customize a new project.
Once the project is started, these scripts should be deleted.
This template is almost ready for using changesets. To enable changesets for releasing to npm registry:
- add
NPM_TOKEN
to Actions secrets of the repository - modify
.github/workflows/release.yml
to enable the release workflow - modify
.github/workflows/build-test.yml
- modify
.changeset/config.json
if you are using a default branch name other thanmain
. - modify
.prettierignore
to ignoreCHANGELOG.md
andpre.json
with prettier - allow GitHub Actions to create Pull Request. See this image.
- (Optional) install changeset-bot
This template does not mention ts-node, esbuild-register, tsx or other similar software.
The current versions of them do not act in the same way as the official TypeScript compiler.
ts-node and esbuild-register have a different import resolution mechanism from the tsc and will not run if you use .js
extension in the import statement.
tsx is somewhat better than these, but I saw that it does not work well when importing CommonJs from ESM.