TypeScript project boilerplate with modern tooling, for Node.js programs, libraries and browser modules. Get started quickly and right-footed ๐
# Clone the repository (you can also click "Use this template")
git clone https://github.com/majdibo/typescript-boilerplate.git your_project_name
cd your_project_name
# Edit `package.json` and `tsconfig.json` to your liking
...
# Install dependencies
yarn install
# Now you can run various yarn commands:
yarn cli
yarn lint
yarn test
yarn build-all
yarn ts-node <filename>
yarn esbuild-browser
...
package.json
yarn publish
(or npm publish
)esbuild is an extremely fast bundler that supports a large part of the TypeScript syntax. This project uses it to bundle for browsers and Node.js.
# Build for browsers
yarn esbuild-browser:dev
yarn esbuild-browser:watch
# Build the cli for node
yarn esbuild-node:dev
yarn esbuild-node:watch
You can generate a full clean build with yarn build-all
(which uses both tsc
and esbuild
).
package.json
includes scripts
for various esbuild commands: see hereesbuild
has a --global-name=xyz
flag, to store the exports from the entry point in a global variable. See also the esbuild "Global name" docs.You can write Jest tests :
test('๐ came before ๐ฅ', () => {
expect("๐" < "๐ฅ").toBe(true)
expect("๐" > "๐ฅ").toBe(false)
});
Run the tests with yarn test
, no separate compile step is necessary.
.github/workflows/lint-and-test.yml
You can auto-generate API documentation from the TypeScript source files using TypeDoc. The generated documentation can be published to GitHub pages through the CI.
Generate the documentation, using src/main.ts
as entrypoint (configured in package.json):
yarn docs
The resulting HTML is saved in docs/
.
You can publish the documentation through CI as GitHub pages: See .github/workflows/deploy-gh-pages.yml
This is the documentation for this boilerplate project: https://majdibo.github.io/typescript-boilerplate/
Generated using TypeDoc