More than you want to know...
Kent C. Dodds
Utah
1 wife, 3 kids
PayPal, Inc.
@kentcdodds
It's like a chapter in a book.
// globals: please load the add script first 🙏
;(function(global) {
global.subtract = (a, b) => global.add(a, -b)
})(this)
// AMD: I explicitly depend on './add' 👍
define(['./add'], function(add) {
return (a, b) => add(a, -b)
});
// CommonJS: I can't do async, but you can bundle me 😀
var add = require('./add')
module.exports = (a, b) => add(a, -b)
I accept the risks...
with aliases
"run this code"
(import all the things)
(export all the things from this other thing)
(thing babel does to make it work with CommonJS modules)
import {baz} from './foo'
// foo.js
const foo = {baz: 42, bar: false}
export default foo
Babel v5
Babel v6
import foo from './foo'
const {baz} = foo