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
.babelrcfile - now my testing breaks (and , of course, the
.babelrcfile could be for my main app too/instead, which would be meant for transpilation to the browser)
- Rename the
.babelrcfile 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
.babelrcfile 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-lambdaand somehow configure the
babel-loaderto not look at the
.babelrcfile in the root (I imagine I’d still have to make a
.babelrcfile just for
netlify-lambdaand 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
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.