collaboration Drawing app
 
 
 
Go to file
Steve Ruiz 0c02401a5e v0.0.36 2021-08-10 11:42:27 +01:00
.github Roll back bug report form 2021-07-13 20:46:21 +01:00
.vscode
packages homegrown monorepo 2021-08-10 11:39:47 +01:00
.eslintrc.js homegrown monorepo 2021-08-10 11:39:47 +01:00
.gitattributes 11.38.37 homegrown monorepo 2021-08-10 11:39:47 +01:00
.gitignore homegrown monorepo 2021-08-10 11:39:47 +01:00
.npmignore homegrown monorepo 2021-08-10 11:39:47 +01:00
LICENSE homegrown monorepo 2021-08-10 11:39:47 +01:00
README.md homegrown monorepo 2021-08-10 11:39:47 +01:00
jest.config.js homegrown monorepo 2021-08-10 11:39:47 +01:00
lerna.json homegrown monorepo 2021-08-10 11:39:47 +01:00
package.json v0.0.36 2021-08-10 11:42:27 +01:00
tsconfig.json homegrown monorepo 2021-08-10 11:39:47 +01:00
yarn.lock homegrown monorepo 2021-08-10 11:39:47 +01:00

README.md

TypeScript Boilerplate for 2021

Build and test status

TypeScript project boilerplate with modern tooling, for Node.js programs, libraries and browser modules. Get started quickly and right-footed 🚀

See also the introduction blog post: Starting a TypeScript Project in 2021.

Getting Started

# Clone the repository (you can also click "Use this template")
git clone https://github.com/tldraw/tldraw.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
...
  • Take a look at all the scripts in package.json
  • For publishing to npm, use yarn publish (or npm publish)

esbuild

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 if you want).

# 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 here
  • esbuild 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.
  • Read more about the esbuild setup here.
  • esbuild for the browser uses the IIFE (immediately-invoked function expression) format, which executes the bundled code on load (see also https://github.com/evanw/esbuild/issues/29)

Tests with Jest

You can write Jest tests like this:

import { greet } from "./main";

test("the data is peanut butter", () => {
  expect(1).toBe(1);
});

test("greeting", () => {
  expect(greet("Foo")).toBe("Hello Foo");
});

Run the tests with yarn test, no separate compile step is necessary.

Documentation, published with CI

You can auto-generate API documentation from the TyoeScript source files using TypeDoc. The generated documentation can be published to GitHub / GitLab 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:

This is the documentation for this boilerplate project: https://metachris.github.io/typescript-boilerplate/

References

Feedback

Reach out with feedback and ideas: