Skip to content

saadtazi/js-lib-starter-kit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

About

nodejs and browser library starter kit with babel (ES2015 and beyond... add your favorite babel loaders).

Disclaimer

It is NOT an express, koa nor react starter kit... It is a javascript library starter kit.

Instruction

  • 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 in test/... Create all the files/directories you need inside src/. Note that if you rename or delete src/index.js file, you will have to adjust main property in package.json
  • npm build: this will build your code in dist/ 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

Commands

Check package.json for a complete list of commands.

Notes

  • after running npm cov, you can open coverage/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 in package.json to change which directory (src or dist) is the default exported 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 remove transform-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

GIT Integration

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.

How to remove Travis and Coveralls.io Integration

  • remove .travis.yml
  • remove in package.json npm script coveralls and travis

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published