Can I use Webpack in ES6 without using Babel? Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Can I use Webpack in ES6 without using Babel? without wasting too much if your time.

The question is published on by Tutorial Guruji team.

Node now gives us the option of using .mjs files or setting "type": "module". I would like to do that because it’s 2021, ES6 is widespread and I’m writing my server-side code using ES6 modules.

But that means I can’t use require() like we always did before. Ok then, I’ll just use ES6’s import.

Well nope, it doesn’t seem that is officially supported for Webpack’s config. All the old answers on StackOverflow are telling me I’ve got to use Babel for backwards compatibility. It seems like there should be a better solution by now.

Is there one?


I found the problem on my own! It was my fault. In 2021, Webpack can totally use ES6 for config and it can bundle up ES6 JS just fine as long as all your dependencies are cool with ES6, like @bigless said.

I just made an error in the config file. With node modules, we’d say something like module.exports = { ... }. The ES6 equivalent is just export default { ... }. I simply forgot to change it over.

We are here to answer your question about Can I use Webpack in ES6 without using Babel? - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji