-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gatsby): add stage to nested babel-preset-gatsby #36249
base: master
Are you sure you want to change the base?
Conversation
I will say that I didn't really test So we should be able to remove the note about passing those from packages/babel-preset-gatsby/README.md - at least once that is shipped |
7bbdafd
to
215cd98
Compare
If you set iirc that's how you reproduce that |
Tried it - with The issue with this and the note that we already have is that if user only set those After thinking a bit more on it - I do think those options need to stay in babel-preset-gatsby README, because user might be using babel config for other tools ( jest, storybook ) - and this is the only way for them to work correctly. But I would edit the note a little bit - say "from gatsby@x we will automatically inject jsxRuntime options in Gatsby context, but if you use additional tools that use your babel config, you will need to set them in your babel config for them to work . |
…ons over gatsby-config
Added the preference on options provided by babelrc to ensure behaviour won't change for people already passing those. In actual practice it seems like user does need those settings in gatsby-config (the gatsby/packages/gatsby/src/utils/eslint-config.ts Lines 74 to 80 in abc65a6
So more than likely users already have them duplicated in config and in custom babelrc. This change most likely will only impact users that will try to use those in the future, and not ones that are already using it (as they won't have to add options to custom babelrc unless they use additional 3rd party tools) |
(Side note, today I wasn't entirely certain how Babel configurations were being consumed, especially in a monorepo, and then I got seriously confused by what turned out to be #35435.) My two cents: If I specified JSX import source in a Babel config, preferably that would win. IMHO the Gatsby option could even be deprecated; it's not too much to ask a user to create a short Babel config. If this gets us a step closer to that, great! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge please? 😔
@pieh
Description
Our code that ensures
stage
is added to babel-preset-gatsby options was only working when local babelrc (or other config file) was adding our preset. If user is using custom preset that adds our preset it wasn't working anymore.This PR will resolve presets other than ours to be able to recursively check for babel-preset-gatsby and add
stage
to options.This PR is also making sure that
reactRuntime
andreactImportSource
are passed as well, as we do that for our default -gatsby/packages/gatsby/src/utils/babel-loader-helpers.js
Lines 122 to 136 in 5a5f5b9
Related Issues
Fixes #35731