Webpack 2 – Using removed Babel 5 option: foreign.modules
Hello all,
You can find this issue while migrating a project with a .babelrc
file to Webpack 2.
In my case it was a React/ES6 project.
My .babelrc
contained:
{
"presets": ["es2015", "react"]
}
and I had to change it as follows:
{
"presets": [
"react",
[ "es2015", { "modules": false } ]
]
}
Webpack 1 wasn’t able to parse ES2015 modules, so Babel would convert them into CommonJS. Now Webpack 2 can parse ES2015 modules, and is able to eliminate dead code based on which modules are used. With [ "es2015", { "modules": false } ]
you tell Babel to stop compiling ES2015 modules.
Enjoy!
thanks a lot, it worked for me !