ES2015 boilerplate for creating libraries with Rollup, JS, TS, and Babel
The next generation Boily ES2015 boilerplate
- ES6 with Babel for ES6 and ES7
- Rollup for bundling and unit tests
- Chai as Promised extends Chai with a fluent language for asserting facts about promises.
- Eslint to maintain a consistent code style
- Karma as the test runner
- Universal Module Definition (UMD) API , which provides compatibility with the most popular script loaders, to the output.
- Sinon.JS with examples for test doubles
- Gulp as the streaming build system.
- Livereload an implementation of the LiveReload server in Node.js.
- Unit tests written with ES2015 get transpiled on the fly
- Browser tests in the browser
- Node >= 6.x
The only development dependency of this project is Node.js . So just make sure you have it installed. Then type few commands known to every Node developer…
$ git clone https://github.com/kflash/spiky.git $ cd spiky $ npm install # Install Node modules listed in ./package.json $ npm run build # Build a minified and a non-minified version of the library
… and boom! You have it all setup for you!
npm run dependencies– List installed packages
npm run dependencies:purge– Remove all dependencies
npm run dependencies:reinstall– Reinstall all dependencies
npm run dependencies:check– shows a list over dependencies with a higher version number then the current one – if any
npm run dependencies:upgrade– automatically upgrade all devDependencies & dependencies, and update package.json
gulp build– build task that generates both minified and non-minified scripts
gulp build:dev– build task that generate a non-minified script
gulp build:prod– build task that generate a minified script
gulp build:common– Build task that generate a CommonJS bundle
gulp build:ts– Build task that generate a ES5 bundle from TypeScript
gulp lint:src– lint the source
gulp lint:ts– lint the TypeScript source files
gulp lint:tests– lint the unit tests
gulp clean– remove the coverage report – and the dist folder
gulp node:cov– run Isparta, a code coverage tool
gulp test– runs unit tests for the browser and the
gulp test:browser– runs the unit tests for browser
gulp test:chrome– runs the unit tests for browser with Chrome
gulp test:phantom– runs the unit tests for browser with PhantomJS
gulp test:node– runs the unit tests in a
gulp watch:node– run all unit tests in the node environemnt, and watch files for changes
gulp watch:browser– run all unit tests for browser and watch files for changes
gulp watch:chrome– run all unit tests for browser with Chrome and watch files for changes
gulp watch:phantom– run all unit tests for browser with PhantomJS and watch files for changes
gulp prepare:ts– grab all TypeScript test files and bundle them down to ES5 for use with unit tests
This boilerplate can be extended to support various features such as Flow and Typescript.
Spiky has a couple of built-in tools that allow you to bundle different packages at once. E.g. take a look at the
./config/gulp/build-common.js file as a good example.
All you need to do is to import the bundle from the
util folder , and call it with two arguments – format and the entry point. E.g.
There is also a tool to run the build process in sequence. Study the
This project uses
Mocha to run your unit tests, it uses
Karma as the test runner, it enables the feature that you are able to render your tests to the browser (e.g: Firefox, Chrome etc.).
To add a unit test, simply create a
.spec.browser.js or a
.spec.node.js file inside the
~../test/specs/ folder. Karma will pick up on these files automatically, and Mocha and Chai will be available within your unit tests without the need to import them.
To keep watching the common test suites that you are working on, simply do
gulp watch:browser or
gulp watch:node .
The browser spec runner –
./config.runner.html – can be opened in a browser to run your tests. For it to work, you must first run
gulp browser . This will set up a watch task that will automatically refresh the tests when your scripts, or the tests, change.
Spiky has build-in some nice features to always make sure your dependency tree are up to date.
To check for the latest dependencies, simply run
npm run dependencies:check .
If you want to update your packages, you can simply do npm run
Note!Your package.json will be automatically updated so make sure you have saved your changes before running this.
To reinstall all packages, do npm run
dependencies:reinstall , and to remove all packages npm run package:purge.
Spiky is set up to bundle Typescript down to ES5. You only have to change the file extension from
The MIT License (MIT)
Copyright (c) 2016 KFlash
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.