ES2015 Javascript starter kit for library project with code coverage (nyc), linting (eslint with air-bnb
settings), CI (travis-ci), test (mocha), coverage (nyc and coveralls).
nodejs and browser library starter kit with babel (ES2015 and beyond... add your favorite babel loaders).
It is NOT an express, koa nor react starter kit... It is a javascript library starter kit.
- git clone
&& cd
npm install
- edit
package.json
: name, description, tags, repo url, licenses... - edit
README.md
- edit
src/index.js
and create corresponding tests intest/
... Create all the files/directories you need insidesrc/
. Note that if you rename or deletesrc/index.js
file, you will have to adjustmain
property inpackage.json
npm build
: this will build your code indist/
directory (UMD)- ... commit your stuff...
- when ready to release a new version:
// check `npm version` doc: https://docs.npmjs.com/cli/version
npm version [major | minor | patch]
This will:
- update
package.json
version - commit the
package.json
change - create the corresponding git tag (vM.m.p)
- (via
npm postversion
script) push current branch (usually master) and the created git tag
Check package.json
for a complete list of commands.
Notes
- after running
npm cov
, you can opencoverage/index.html
. - to use the generated package (assuming that you named your package
my-lib
):
//commonjs: using "regular" node (no ES2015 `import` support)
const myPackage = require('my-lib');
// ES2015 import, if you want to use transpiled version..
import myPackage from 'my-lib';
// ES2015 import, if you want to use the ES2015 version
import myPackage from 'my-lib/src';
// AMD... I think it looks like this.
// It's been so long...
require(..., 'path/to/dist/my-lib', ... function (...) {...});
// browser
<src src="./path/to/dist/my-lib"></script>
-
edit
main
property inpackage.json
to change which directory (src
ordist
) is the defaultexport
ed one. -
If you don't care about UMD/AMD/browser support and want to stick with common.js and ES2015 export, just edit
[.babelrc](./.babelrc)
and removetransform-es2015-modules-umd
plugin. -
If you do not need commonJS... then why are you reading this? Oh, for code coverage and test setup? Ok. Then you can remove the
npm compile
task from package.json I guess...
Travis-CI Integration & Coveralls.io
- Make sure you have the proper command(s) in .travis.yml
This repository uses husky
npm package to configure git hooks. The 2 configured hooks are pre-commit
and pre-push
. Check in package.json
the scripts
section.
- remove
.travis.yml
- remove in
package.json
npm scriptcoveralls
andtravis