0.0.2 • Published 7 years ago

sample-es6-library v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

sample-es6-library

This shows how to distribute an ES6 library using Babel and rollup.

  • package.json#module points to the raw ES6 code for modern browser consumption
  • package.json#main points to legacy browser/node support and CommonJS modules.

Under the hood, it uses Babel and babel-runtime for legacy browser/Node.js support. babel-runtime (actually the transform-runtime plugin) polyfills only what the library uses and does so in a way that doesn't conflict with other versions of Babel. This is perfect for libraries.

We use rollup only to create the UMD bundle for JSFiddle consumption.

Installation

npm install sample-es6-library

Consumption

// Web, webpack consumption, modern browsers only
import foo from 'sample-es6-library'
// Web, webpack consumption, legacy browser support
import foo from 'sample-es6-library/dist/legacy/index'
// Node.js
const foo = require('sample-es6-library')

JSFiddle support: dist/legacy-umd/index.js is a UMD bundle that can be put behind a CDN and loaded via a <script> tag. For example, here it is loaded via jsdelivr.com.

0.0.2

7 years ago

0.0.1

7 years ago

0.0.0

7 years ago