1
0
mirror of synced 2025-11-08 21:07:23 +00:00
Files
typescript-starter/examples/readme.md
Jason Dreyzehner 45d7dfad62 docs(examples): refactor examples to be more familiar to most users
use npm to install the library and run each example, remove yarn.lock files
2017-02-17 02:30:16 -05:00

1.8 KiB
Raw Blame History

Usage Examples

This directory (/examples) can be deleted when forking this project. It contains some simple examples of how forks of typescript-starter can be used by other projects. (Usually you'll want to provide these instructions in your root readme.md.)

Node (Vanilla)

This shows the simplest use case a quick, hacked-together Node.js project with no type safety, and no pre-processing. This is the way most of the Node.js ecosystem currently expects to import a node modules.

cd examples/node-vanilla

# install and run the example
npm install
npm run

Node (Typescript)

This is for larger and more established Node.js projects which use Typescript for type safety. You'll notice that the type declarations and inline documentation from typescript-starter are accessible to Typescript-compatible editors like vscode.

cd examples/node-typescript

 # install the dependencies
npm install
# type-check and build the example
npm run build
# run the example
npm start

Browser (tree-shaking with Rollup)

This project imports the power and asyncABC functions from the ES6 output of typescript-starter, without importing the double function. This allows for the double method to be completely excluded from output via Rollup's tree-shaking, making the final javascript bundle potentially much smaller, even before using a minifier like Uglify.

To demonstrate, this example doesn't minify or remove comments. You can see where some javascript has been excluded from the bundle.

cd examples/browser

# install the dependencies
npm install
# build the javascript bundle
npm run build
# start a server and open the test in a browser
npm start