Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
Babel-loader: Preset that contains other presets is not being loaded correctly

I have a Babel config, that (roughly) looks like the following:

module.exports = function () {
  return {
    presets: [
      [
        require.resolve('@babel/preset-env'),
        { /* options */ },
      ]
    ],
    plugins: [ /* misc plugins */ ], 
  }
}

This is well and fine, and works great when used on it's own.

However, what I'd like to do is be able to use this as a preset, and add in additional plugins or presets on top. For example:

.babelrc

{
  presets: ['my-preset'],
  plugins: [ /* additional plugins */ ], 
}

The issue that I'm running into is that babel-loader seemingly doesn't resolve these "nested" presets. Syntax that should be transformed by @babel/preset-env no longer does, leading me to believe it's never used, though it should be transitively included.

If the lack of require.resolve in the .babelrc looks concerning, my Webpack config handles this automatically. Using that .babelrc, my Babel loader options looks like:

{
  presets: [ '/home/user/Projects/project/node_modules/my-preset/index.js' ]
}

According to the Babel docs, presets absolutely can include other presets so I'm not sure what the issue is here, or even how to debug. A console.log in my babel config before the return does show up in the build logs, so it is loaded to some degree, but why @babel/preset-env doesn't then work is beyond me.

Using Webpack v4.38.0, babel-loader v8.2.2

about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!