As of Babel version v6.13.0, babel-preset-es2015
supports modules
option.
Use preset options to disable transformation of the ES6 module syntax:
{
"presets": [
[
"es2015",
{
"modules": false
}
]
]
}
Babel preset for all es2015 plugins except babel-plugin-transform-es2015-modules-commonjs
.
This preset is used to enable ES2015 code compilation down to ES5. webpack 2 natively supports ES6 import
and export
statements. webpack 2 leverages the static structure of the ES6 modules to perform tree shaking.
For an introduction to tree shaking and webpack 2 see Tree-shaking with webpack 2 and Babel 6.
npm install babel-preset-es2015-webpack --save-dev
Add to .babelrc
:
{
"presets": [
"es2015-webpack"
]
}