Skip to content

Commit 5f18048

Browse files
committed
feat(starter): add changelogs and examples
1 parent 7304e24 commit 5f18048

File tree

19 files changed

+1121
-42
lines changed

19 files changed

+1121
-42
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
node_modules
22
build
3-
*.js
3+
src/**.js
44
coverage
55
.nyc_output

README.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
22
An es7/typescript starter for building javascript libraries:
33

44
* Write **standard, future javascript** – with stable es7 features – today ([stage 3](https://github.com/tc39/proposals) or [finished](https://github.com/tc39/proposals/blob/master/finished-proposals.md) features)
5-
* Use optional typescript typings to improve tooling, linting, and documentation generation
6-
* Export as an [es module](https://github.com/rollup/rollup/wiki/pkg.module), making your work **fully tree-shakable** for consumers using es imports (like [Rollup](http://rollupjs.org/) or [Webpack 2](https://webpack.js.org/))
5+
* [Optionally use typescript](https://basarat.gitbooks.io/typescript/content/docs/why-typescript.html) to improve tooling, linting, and documentation generation
6+
* Export as a [javascript module](http://jsmodules.io/), making your work **fully tree-shakable** for consumers using [es6 imports](https://github.com/rollup/rollup/wiki/pkg.module) (like [Rollup](http://rollupjs.org/) or [Webpack 2](https://webpack.js.org/))
77
* Export typescript declarations to improve your downstream development experience
8-
* Backwards compatibility for Node.js CommonJS imports (v4 or greater)
8+
* Backwards compatibility for Node.js-style (CommonJS) imports (v4 or greater)
99
* Both [strict](config/tsconfig.strict.json) and [flexible](config/tsconfig.flexible.json) typing configurations available
1010

1111
So we can have nice things:
1212
* Generate API documentation (HTML or JSON) [without a mess of JSDoc tags](https://blog.cloudflare.com/generating-documentation-for-typescript-projects/) to maintain
13-
* Co-located, atomic, concurrent tests with [AVA](https://github.com/avajs/ava)
13+
* Collocated, atomic, concurrent unit tests with [AVA](https://github.com/avajs/ava)
1414
* Source-mapped code coverage reports with [nyc](https://github.com/istanbuljs/nyc)
1515
* Configurable code coverage testing (for continuous integration)
1616

1717
## Get started
1818

1919
Before you start, consider configuring or switching to an [editor with good typescript support](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Editor-Support).
2020

21+
To see how this starter can be used, check out the [`examples`](./examples) folder.
22+
2123
## Development zen
2224

2325

@@ -71,6 +73,19 @@ For more advanced documentation generation, you can provide your own [typedoc th
7173
$ yarn docs:json
7274
```
7375

76+
## Generate Changelog & Release
77+
78+
This project is tooled for [Conventional Changelog](https://github.com/conventional-changelog/conventional-changelog) to make managing releases easier. See the [standard-version](https://github.com/conventional-changelog/standard-version) documentation for more information on the workflow.
79+
80+
```bash
81+
# bump package.json version, update CHANGELOG.md, git tag the release
82+
$ yarn release
83+
# Release without bumping package.json version
84+
$ yarn release -- --first-release
85+
# PGP sign the release
86+
$ yarn release -- --sign
87+
```
88+
7489
## All package scripts
7590

7691
You can run the `info` script for information on each available package script.
@@ -102,6 +117,8 @@ docs:
102117
Generate API documentation and open it in a browser
103118
docs:json:
104119
Generate API documentation in typedoc JSON format
120+
release:
121+
Bump package.json version, update CHANGELOG.md, tag a release
105122
```
106123
## Notes
107124

config/tsconfig-module.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../tsconfig",
3+
"compilerOptions": {
4+
"outDir": "../build/module",
5+
"module": "es6",
6+
"declaration": false
7+
},
8+
"exclude": [
9+
"../node_modules/**",
10+
"../src/**/*.spec.ts"
11+
]
12+
}

config/tsconfig-node.json

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/browser/package.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "es7-typescript-starter-example-browser",
3+
"version": "1.0.0",
4+
"license": "MIT",
5+
"scripts": {
6+
"start": "http-server ./build/ -o",
7+
"build": "rollup -c && cpy src/index.html build/"
8+
},
9+
"devDependencies": {
10+
"cpy-cli": "^1.0.1",
11+
"http-server": "^0.9.0",
12+
"rollup": "^0.41.4",
13+
"rollup-plugin-node-resolve": "^2.0.0",
14+
"rollup-plugin-typescript": "^0.8.1",
15+
"typescript": "^2.2.0"
16+
}
17+
}

examples/browser/rollup.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// rollup.config.js
2+
import typescript from 'rollup-plugin-typescript';
3+
import nodeResolve from 'rollup-plugin-node-resolve';
4+
5+
const pkg = require('./package');
6+
7+
export default {
8+
entry: 'src/test.ts',
9+
moduleId: pkg.name,
10+
moduleName: 'BrowserTest',
11+
// entry: 'dist/es/index.js',
12+
dest: 'build/test.js',
13+
format: 'iife',
14+
sourceMap: true,
15+
plugins: [
16+
typescript({
17+
typescript: require('typescript') // use local version
18+
}),
19+
nodeResolve({
20+
module: true,
21+
jsnext: true,
22+
browser: true,
23+
extensions: [ '.js', '.json' ],
24+
preferBuiltins: false
25+
})
26+
]
27+
}

examples/browser/src/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<html><body>
2+
<script src="test.js" />
3+
</body></html>

examples/browser/src/test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Note: we're not using the double method, so it should be excluded from the bundle
2+
import { power, asyncABC } from '../../../'
3+
4+
if (power(3,4) === 81) {
5+
console.log('✔ power(3,4) === 81')
6+
} else {
7+
console.error('The "power" method seems to be broken.')
8+
}
9+
10+
asyncABC().then( abc => console.log('✔ asyncABC returned:', abc) )

examples/browser/tsconfig.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": "../../tsconfig",
3+
"compilerOptions": {
4+
"outDir": "build",
5+
"module": "ES6",
6+
"declaration": false,
7+
"removeComments": true
8+
},
9+
"include": [
10+
"src/*.ts"
11+
]
12+
}

0 commit comments

Comments
 (0)