6. Using a module
import {doIt, meaningOfLife}
from 'a-module';
export function doIt() {}
export var meaningOfLife = 42
function doThat() {}
a-module.js
13. Confusion will be my epitaph
export default
function doIt() {}
export default var
meaningOfLife = 42;✕
✓
14. default is just another import
import orOther, {something}
from 'a-module';
import {something}, orOther
from 'a-module';
import {something, default as orOther}
from 'a-module';
56. So forget about this
<module>
import {doIt} from 'a-module';
// …
</module>
<div onclick=doit>...</div>
57. Interoperability with AMD
● e.g. RequireJS?
● Maybe. There’s another spec, the Loader
spec, which is dealing with this
● Work in progress. Not yet close to ready.
● And has interoperability problems with Node
58. And how would this work
efficiently?
<module src= ></module>
65. We’ve already seen it (Babel)
export function
doIt() {}
exports.doIt =
function() {}
import {doIt}
from 'a-module'
var {doIt} =
require('a-module')
71. The Dragon of Syntax
The Node Dragon
Sonnet 130
The Browser Dragon
72.
73. Sonnet 130
My mistress’ eyes are nothing like the
sun;
Coral is far more red than her lips’
red;
If snow be white, why then her
breasts are dun;
If hairs be wires, black wires grow on
her head.
I have seen roses damasked, red
and white,
But no such roses see I in her
cheeks;
And in some perfumes is there more
delight
Than in the breath that from my
I grant I never saw a goddess go;
My mistress when she walks treads
on the ground.
And yet, by heaven, I think my
love as rare
As any she belied with false
compare.
74. So Go...
...and love ES6 modules like you love your
beloved:
it’s never perfect,
but it’s still wonderful,
and it gets better over time