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

Authoring and publishing ES6 modules today

By Vincent Voyer

Authoring and publishing ES6 modules today

You want to do some ES 2015 before its 2016 but you are afraid: will this run on the many existing JavaScript environments? What about node.js, 0.10 0.12 4 5, browsers like IE 11, module loaders, script users.. How do you write and release reusable Modules using a syntax that is not yet implemented everywhere? We'll see how

  • 5,101