Search code examples
javascriptwebpackbabeljsbabel-loader

Is babel-loader still required with webpack 4.7.x?


I wanted to understand if I need to add babel-loader, babel-core if my project has webpack version 4.7.0?

Initially I did not add babel-loader, and my code which contained ES6 compiled just fine and browsers got ES5.

If I do add babel-loader, I see the following warning in my npm or yarn tool install commands:

warning " > babel-loader@7.1.4" has unmet peer dependency "babel-core@6".

Hence I ask this question if I still need to add it as a devDependencies and configure it in the webpack configuration file to pre-process my .js files. I did not find documentation very clear about this.


Solution

  • Yes. It is still required as devDependency. You will need babel-loader, babel-core and babel-preset-env. Webpack 4 (or for that matter v4.7.0 which released today) essentially changes nothing.

    As far as your webpack's behavior is concerned, it is rather strange. Can you share your config which I can replicate at my end?