Clearing up the Babel 6 Ecosystem

npm install babel

npm install babel-core

{
"presets": ["es2015"]
}

npm install babel-cli

npm install babel-register

npm install babel-polyfill / npm install babel-runtime

// this will not be transformed by babel-runtime because it's
// ambiguous. However, since babel-polyfill assigns methods directly
// on the String prototype, it will work:
"!!!".repeat(3)

Practically speaking, what does this mean?

  • Provide your code with an emulated ES2015 environment by either requiring babel-polyfill, or requiring the babel-runtime module plus the babel-plugin-transform-runtime transform:
// for babel-polyfill, either add:require('babel-polyfill');// ... at the top of your root script, or, if on node >= 4,
// you can call your script with the --require flag to include it
// like so:
node --require babel-polyfill myApp.js// for babel-runtime, install the module, then use the
// babel-plugin-transform-runtime transform by including it in
// your .babelrc file or declaring it when compiling:
babel --plugins transform-runtime myApp.js
  • Run a series of transforms over your code with either the babel cli (provided by babel-cli), the .transform api (provided by babel-core), or implicitly when required (via babel-register)

--

--

--

I punch keys in Boston. Most of those keys relate to JavaScript (and many to kraken-js). Previously @PayPal, @WHERE.

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jean-Charles Sisk

Jean-Charles Sisk

I punch keys in Boston. Most of those keys relate to JavaScript (and many to kraken-js). Previously @PayPal, @WHERE.

More from Medium

Play External Sound with Flash

Babel: How to use Babel once your project is built

What is JavaScript ES6?

Dom Manipulation-Selecting Elements