ES6 module format
// Inline named exports
export const FOO = “foo";
// All at once named exports
export { FOO, bar };
// Default export (one per file)
export default class Bar {}
Slide 19
Slide 19 text
ES6 module format
// Named imports
import { FOO, bar } from ‘./utils.js’;
// Rename imports
import { FOO, bar as alias } from ‘./utils.js';
// Import everthing to a single object
import * as utils from ‘./utils.js';
// Import default
import Bar from './utils.js';
Slide 20
Slide 20 text
native ES6 modules
browser support is here
Slide 21
Slide 21 text
use script type=module
import { render } from './utils.js';
render('Hello World');
bundling is wasting bandwidth
native ES6 modules
dependencies via unpkg
∠
Slide 26
Slide 26 text
unpkg
the CDN for
everything
on NPM
Slide 27
Slide 27 text
the many faces of unpkg
https://unpkg.com/rxjs —> entry point of the latest version
https://unpkg.com/rxjs@5 —> entry point of a specific version
https://unpkg.com/rxjs/package.json —> a specific file
https://unpkg.com/rxjs/ —> directory listing
https://unpkg.com/rxjs?module —> es6 modules entry point
Slide 28
Slide 28 text
No content
Slide 29
Slide 29 text
load dependencies
as modules
import Vue from ‘https://unpkg.com/vue?module';
import { fromEvent } from ‘https://unpkg.com/rxjs?module';