Authoring and publishing ES6 modules today

Goals

npm publish es6-module

require('es6-module');

<script src="es6-module.js">

Writing an application in ES6

Easy, you own the environment

Writing a reusable module in ES6

Challenging, many environments

loaders and  transforms are bad for modules

they reduce portability

Data for November 2015

es6 support is not here, yet

Target: npm users

Solution: publish ES5 transpiled source code folders

file: index.js

file: package.json

file: build.sh

directory: dist-module/

Traps

  • npm link is broken
  • require('es6-module/file') is broken
  • JavaScript stack traces are weird

May or may not be a big deal

Target: <script> users

Solution: publish bundles

||

&&

file: webpack.config.dist.babel.js

file: build.sh

directory: dist/

Summary

We can't publish ES6 modules directly.

To author ES6 modules today,
publish ES5 transpiled source code in npm.

Push ES5 bundles to any cdn for <script> users.

Thx

Bonuses

Real world published ES6 module

Made with Slides.com