ES6 library starter
A boilerplate for a universal (Node, web, UMD) ES6 library.
Quick usage
- Clone this repo.
- Change all relevant entries in
package.json
andREADME.md
, so they match your new shiny library. - Run
npm install
to install dev dependencies. - Write your ES6 code in
src
folder. - Write your ES6 tests in
test
folder. - Run
npm run build
to build for node. This will compile to ES5, minify, and output the result tolib
folder. - Run
npm run build-web
to build and pack the files for the web. This will output the result todist
folder. - Run
npm publish
to pulish to the world.
Detailed overview
Installation
After cloning this repository, make sure to change all the relevant entries in package.json
so they match your library.
npm install
Build for npm
npm run build
This will:
- Run Webpack starting from the entry point file (
src/library.js
, can be configured) - Convert all files in
src
folder from ES6 to ES5 - According to the
bundle-node
flag inpackage.json
, it will either: - Leave them as separate files, or -
- Minify and bundle them using Webpack, without their
node_modules
dependencies - Output the result to the
lib
folder
Build for web
npm run build-web
This will:
- Run Webpack starting from the entry point file (
src/library.js
, can be configured) - Convert all files from ES6 to ES5
- Minify them, including all of their module dependencies, as a UMD module (so the file will be self-contained)
- Output the file to the
dist
folder
Test
npm run test
Configuration
In package.json
, change all the relevant entries so they match your library.
Under the section library
, you can configure:
- Library name (defaults to
"Library"
) - Webpack entry point (defaults to
library.js
) - Dist folder for Node (defaults to
lib
) - Dist folder for Web (defaults to
dist
) - Choose whether to bundle for Node (defaults to
true
)
License
MIT