Skip to content
Advertisement

Babel not transpiling arrow functions (Webpack)

When running webpack, and babel, the resulting bundle.js still contains arrow functions. This gives me a Syntax Error when running in Internet Explorer 10. I would like babel to replace the arrow functions with normal functions that IE can run.

My package.json has the following devDependencies:

JavaScript

My webpack.config.js looks like this:

JavaScript

My .babelrc looks like this:

JavaScript

To transpile, I run the command:

npm run build –production

And I get the following output in the console:

JavaScript

The transform-es2015-arrow-functions is listed as included, but when I open the generated bundle.js I can, for instance, see the following:

JavaScript

The above makes use of an arrow function, and produces a syntax error in Internet Explorer. Other ES6 stuff like ‘…’ gets transpiled.

What am I doing wrong?

Advertisement

Answer

I think an issue is related to query-string because it’s written in ES6 and not transpiled to ES5. Try to downgrade version from 6 to 5.

JavaScript
Advertisement