Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

247
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda