|
1 |
| -# `es7-typescript-starter` Usage Examples |
| 1 | +# Usage Examples |
2 | 2 |
|
3 |
| -This directory (`/examples`) can be deleted when forking this project. It contains some simple examples of how forks of this starter can be used by other projects. (Usually you'll want to provide these instructions in your root `readme.md`.) |
| 3 | +This directory (`/examples`) can be deleted when forking this project. It contains some simple examples of how forks of `es7-typescript-starter` can be used by other projects. (Usually you'll want to provide these instructions in your root `readme.md`.) |
4 | 4 |
|
5 | 5 | ## Node (Vanilla)
|
6 | 6 |
|
| 7 | +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. |
| 8 | + |
7 | 9 | ```bash
|
| 10 | +# build es7-typescript-starter first |
8 | 11 | yarn build
|
| 12 | + |
9 | 13 | cd examples/node-vanilla
|
10 |
| -node test.js |
| 14 | + |
| 15 | +# run the example |
| 16 | +node test.js |
11 | 17 | ```
|
12 | 18 |
|
13 | 19 | ## Node (Typescript)
|
14 | 20 |
|
| 21 | +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 `es7-typescript-starter` are accessible to [Typescript-compatible editors](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Editor-Support) like [vscode](https://code.visualstudio.com/). |
| 22 | + |
15 | 23 | ```bash
|
| 24 | +# build es7-typescript-starter first |
16 | 25 | yarn build
|
| 26 | + |
17 | 27 | cd examples/node-typescript
|
18 |
| -yarn && yarn build && yarn start |
| 28 | + |
| 29 | + # install the dependencies |
| 30 | +yarn |
| 31 | +# type-check and build the example |
| 32 | +yarn build |
| 33 | +# run the example |
| 34 | +yarn start |
19 | 35 | ```
|
20 | 36 |
|
21 |
| -## Browser (Rollup, Tree-shaking) |
| 37 | +## Browser (tree-shaking with Rollup) |
| 38 | + |
| 39 | +This project imports the `power` and `asyncABC` functions from the ES6 output of `es7-typescript-starter`, without importing the `double` function. This allows for the `double` method to be completely excluded from output via [Rollup's tree-shaking](http://rollupjs.org/), making the final javascript bundle potentially much smaller, even before using a minifier like [Uglify](https://github.com/mishoo/UglifyJS2). |
| 40 | + |
| 41 | +To demonstrate, this example doesn't minify or remove comments. You can see where some javascript has been excluded from the bundle. |
22 | 42 |
|
23 | 43 | ```bash
|
| 44 | +# build es7-typescript-starter first |
24 | 45 | yarn build
|
| 46 | + |
25 | 47 | cd examples/browser
|
26 |
| -yarn && yarn build && yarn start |
| 48 | + |
| 49 | +# install the dependencies |
| 50 | +yarn |
| 51 | +# build the javascript bundle |
| 52 | +yarn build |
| 53 | +# start a server and open the test in a browser |
| 54 | +yarn start |
27 | 55 | ```
|
0 commit comments