-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Add JSX source transform for better warnings #716
Conversation
babelLoader.query = babelLoader.query || {}; | ||
babelLoader.query.babelrc = false; | ||
// We embed the preset instead of referring to it because otherwise | ||
// `env` options in the preset do not get taken into account. |
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.
Is that so? I've seen some presets that use env
, e.g. babel-preset-react-native here. I wonder how that works?
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.
Can we open an issue in Babel, if this is broken? I think it would be best to keep the react-scripts/ejected configurations as similar as possible.
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.
Presets can use env
. I think it’s our peculiar way of using them (babelrc: false
) that might be breaking this. It would be amazing if you could investigate why this happens but I want to ship this today so going to leave it as is for now.
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.
Hmm. It seems like env
doesn’t work after ejecting 😢 . Then something must be wrong in how I’m using it, but I can’t figure out what.
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.
Created #720. I can take a look at it at some point. Another peculiarity that we have is the use of require.resolve()
instead of require()
as the presets usually do. (Not sure if it's related to the issue though.) I quickly tried changing the preset to use require()
, but then some plugins become undefined.
Anyway, happy to get this shipped as is, it's a good improvement to the error messages.
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.
Oh :( Then we need to figure out how to fix the ejected setup before merging, I think.
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.
Figured it out, it’s a Babel bug: babel/babel#4539. For now working around it in the preset. To be honest I don’t remember why we use require.resolve()
😄 . Maybe we don’t even need it.
Fixes #700. Read about it here: https://twitter.com/dan_abramov/status/779308833399332864.
579309f
to
402e3bb
Compare
Fixes #700.
Read about it here: https://twitter.com/dan_abramov/status/779308833399332864.
Test plan:
A. It shows up with
npm start
:B.
npm run build
output doesn’t include__source
.C. It shows up with
npm test
: