I have read on the docs for netlify-lambda
that the package uses your .babelrc
file if it exists (or indeed one exists in any parent dir!). If not, it creates it own minimal Babel config.
I don’t actually need to provide any babel config to netlify-lambda
but I do have a .babelrc
file (for Jest tests), which actually seems to break my Lambda if I allow netlify-lambda
to read it. What’s the most correct/supported way to handle this situation?
I can’t think of any great solutions:
- Delete the
.babelrc
file - now my testing breaks (and , of course, the.babelrc
file could be for my main app too/instead, which would be meant for transpilation to the browser) - Rename the
.babelrc
file and update my non-Lambda build scripts to use that (if I can) - Move the babel config to
package.json
- this might actually be the best one, as long as the config isn’t too big - Dig out
netlify-lambda
’s generated config and hardcode that in my.babelrc
file if it can go alongside whatever’s in there - I don’t like this as it can end up going stale - Make a webpack config just for
netlify-lambda
and somehow configure thebabel-loader
to not look at the.babelrc
file in the root (I imagine I’d still have to make a.babelrc
file just fornetlify-lambda
and have to hardcode the current config (see last item for my issues with this). This is a solution I have seen mentioned around the internet.
Is there some other way to “turn off” just .babelrc
detection and make netlify-lambda
otherwise just use its default config.
The docs seem to suggest it can be turned off by passing --babelrc false
, but it looks like doing so turns off the auto generation of the Babel config too (looking at the code certainly seems to suggests such: regardless of --babelrc
value, it only generates the minimum sensible config iff no .babelrc
exists).
I’d be willing to have a go at a PR on netlfiy-lambda
to make the code mentioned above also generate the minimal config if --babelrc false
as long as it’s seen that this is indeed supposed to happen.