Rollup based javascript library boilerplate featuring Babel 7, ESLint, flow, jest, JSDoc, Rollup, semantic-release and live debugginga.
This boilerplate including a basic code to start creating a js based library.
Start with cloning the project:
$ git clone --depth=1 git://github.com/wadehrarshpreet/js-library-boilerplate.git your-project-name
- Remove the .git directory (rm -rf your-project-name/.git).
- Edit package.json and change the name of the project to your project name.
- The boilerplate without any changes supporting creating a library for both CommonJS, es6 modules, amd and browser.
Now, create a new github project and do:
$ git init
$ git remote add origin https://github.com/your-name/your-project-name.git
$ git add -A
$ npm run commit
$ git push origin master
This project is using semantic-release to automatic handling of the version of your library. To be able to automatic release a new version you must configure Travis-CI to your new project:
- Go to https://travis-ci.org/ and either signup or signin.
- Select your new project and click setting.
- You MUST configure a token or semantic-release will not be able to commit changes:
- Create a new token (see here how to do it).
- Permissions needed in the github token:
- repo:
- repo:status
- repo_deployment
- public_repo
- admin:org:
- read:org
- admin:repo_hook:
- write:repo_hook
- user:
- user:email
- repo:
- In your Travis-CI project setting, go to the environment settings section and add a new environment variable with the name 'GH_TOKEN' and the generated token as the data.
- To test everything just push something into github and it should update everything automatic!
Allow doing npm publish automatically by semantic-release:
- You need a npm token (see here) and add it as the NPM_TOKEN environment variable to Travis-CI like you did with the GH_TOKEN for github.
- Update the release section in package.json and add '@semantic-release/npm' to both 'prepare', 'publish' and 'verifyConditions'.
This project is using the following awesome libraries/utilities/services:
via yarn:
$ yarn add your-library
via npm:
$ npm install your-library
To generate the library documentation using jsdocs:
$ yarn doc
or:
$ npm run doc
- your-library/lib/ - All the sources should be here.
- your-library/lib/types/ - All the flow type declarations.
- your-library/__tests__/ - All the unit tests.
- your-library/build-tool/rollup.config.js - The configuration for [rollup](https://rollupjs.org/).
- your-library/build-tool/build.js - Script to generate build ES, CJS(using babel), UMD, IIFE, AMD(using rollup).
- .editorconfig - The [coding style settings](https://editorconfig.org/) for this project.
- .prettierrc - Prettier configuration for this project.
When using with yarn then use the following syntax:
$ yarn name params
Or with just npm:
$ npm name params
- start - Run the code in development mode.
- build - Build the production mode.
- lint - Lint 👮 using ESLint.
- flow - Flow checks.
- test - Run tests using jest
- dev - Build development builds(no minify)
- dev:watch - watch dev build (no minify)
- commit - using commitzen wizard to make commit
- release - Using semantic-release to create new release