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