diff --git a/.gitignore b/.gitignore index 5de02dd..24c2607 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ node_modules build -*.js +src/**.js coverage .nyc_output diff --git a/README.md b/README.md index 9867f27..3c3ca6d 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ An es7/typescript starter for building javascript libraries: * 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) -* Use optional typescript typings to improve tooling, linting, and documentation generation -* 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/)) +* [Optionally use typescript](https://basarat.gitbooks.io/typescript/content/docs/why-typescript.html) to improve tooling, linting, and documentation generation +* 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/)) * Export typescript declarations to improve your downstream development experience -* Backwards compatibility for Node.js CommonJS imports (v4 or greater) +* Backwards compatibility for Node.js-style (CommonJS) imports (v4 or greater) * Both [strict](config/tsconfig.strict.json) and [flexible](config/tsconfig.flexible.json) typing configurations available So we can have nice things: * Generate API documentation (HTML or JSON) [without a mess of JSDoc tags](https://blog.cloudflare.com/generating-documentation-for-typescript-projects/) to maintain -* Co-located, atomic, concurrent tests with [AVA](https://github.com/avajs/ava) +* Collocated, atomic, concurrent unit tests with [AVA](https://github.com/avajs/ava) * Source-mapped code coverage reports with [nyc](https://github.com/istanbuljs/nyc) * Configurable code coverage testing (for continuous integration) @@ -18,6 +18,8 @@ So we can have nice things: Before you start, consider configuring or switching to an [editor with good typescript support](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Editor-Support). +To see how this starter can be used, check out the [`examples`](./examples) folder. + ## Development zen @@ -71,6 +73,19 @@ For more advanced documentation generation, you can provide your own [typedoc th $ yarn docs:json ``` +## Generate Changelog & Release + +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. + +```bash +# bump package.json version, update CHANGELOG.md, git tag the release +$ yarn release +# Release without bumping package.json version +$ yarn release -- --first-release +# PGP sign the release +$ yarn release -- --sign +``` + ## All package scripts You can run the `info` script for information on each available package script. @@ -102,6 +117,8 @@ docs: Generate API documentation and open it in a browser docs:json: Generate API documentation in typedoc JSON format +release: + Bump package.json version, update CHANGELOG.md, tag a release ``` ## Notes diff --git a/config/tsconfig-module.json b/config/tsconfig-module.json new file mode 100644 index 0000000..1853415 --- /dev/null +++ b/config/tsconfig-module.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig", + "compilerOptions": { + "outDir": "../build/module", + "module": "es6", + "declaration": false + }, + "exclude": [ + "../node_modules/**", + "../src/**/*.spec.ts" + ] +} diff --git a/config/tsconfig-node.json b/config/tsconfig-node.json deleted file mode 100644 index 7d976bd..0000000 --- a/config/tsconfig-node.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "compilerOptions": { - "strictNullChecks": true, - "forceConsistentCasingInFileNames": true, - "noFallthroughCasesInSwitch": true, - "noImplicitAny" : true, - "noImplicitReturns": true, - "noImplicitThis": true, - "noUnusedLocals": true, - "noUnusedParameters": true - } -} diff --git a/examples/browser/package.json b/examples/browser/package.json new file mode 100644 index 0000000..9d53a1e --- /dev/null +++ b/examples/browser/package.json @@ -0,0 +1,17 @@ +{ + "name": "es7-typescript-starter-example-browser", + "version": "1.0.0", + "license": "MIT", + "scripts": { + "start": "http-server ./build/ -o", + "build": "rollup -c && cpy src/index.html build/" + }, + "devDependencies": { + "cpy-cli": "^1.0.1", + "http-server": "^0.9.0", + "rollup": "^0.41.4", + "rollup-plugin-node-resolve": "^2.0.0", + "rollup-plugin-typescript": "^0.8.1", + "typescript": "^2.2.0" + } +} diff --git a/examples/browser/rollup.config.js b/examples/browser/rollup.config.js new file mode 100644 index 0000000..e955042 --- /dev/null +++ b/examples/browser/rollup.config.js @@ -0,0 +1,27 @@ +// rollup.config.js +import typescript from 'rollup-plugin-typescript'; +import nodeResolve from 'rollup-plugin-node-resolve'; + +const pkg = require('./package'); + +export default { + entry: 'src/test.ts', + moduleId: pkg.name, + moduleName: 'BrowserTest', + // entry: 'dist/es/index.js', + dest: 'build/test.js', + format: 'iife', + sourceMap: true, + plugins: [ + typescript({ + typescript: require('typescript') // use local version + }), + nodeResolve({ + module: true, + jsnext: true, + browser: true, + extensions: [ '.js', '.json' ], + preferBuiltins: false + }) + ] +} diff --git a/examples/browser/src/index.html b/examples/browser/src/index.html new file mode 100644 index 0000000..d39bce9 --- /dev/null +++ b/examples/browser/src/index.html @@ -0,0 +1,3 @@ + +