Adoption of Babel 6 is widespread, with more than 1,450 Babel plugins and 800 presets registered on npm today. But, as with all good things, progress is coming and Babel 7 will be released soon.
I'm going to start with Babel 7 changes explanation. Then, let's meet our most powerful and flexible preset - babel-preset-env aka autoprefixer for Babel. I'll show how to decrease compilation time for development environment. How to compile for production with safety and get the lowest possible bundle size at the same time. I'll work through some gotchas like dealing with ES2015 code and UglifyJS. I will try to explain why you don't need to support Chrome 45 and Safari 6. And for an extra treat, I'll show how to build and serve user agent-specific bundles.
Oh, and I'll have plenty of Babel stickers too!
10. • classes
• a module system
• optional type annotations, static typing
• generators and iterators
• destructuring assignment
• algebraic data types.
October 2008
11. • classes
• a module system
• optional type annotations, static typing
• generators and iterators
• destructuring assignment
• algebraic data types.
October 2008
🚫
42. export default function ({ types }) {
return {
pre() { … },
visitor: {
BinaryExpression(path) {
// Transform your code
}
},
post() { … },
}
}
Based on the visitor pattern
43. PLUGINS
Syntax Transform
Don’t change the code
Teach Babel to read code
syntax-flow
syntax-jsx
syntax-object-rest-spread
Teach Babel to transpile code
Code transformation as a result
transform-flow-strip-types
transform-es2015-classes
transform-es2015-for-of
79. Firefox, Chrome, Safari and IE10 browsers all have the
ability to update themselves.
You can be pretty confident that if your code runs on your
browser, it's going to run on your customer's browser too.
Rob Eisenberg, 2014