-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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: add metadata to jsx when using @vite/plugin-react-refresh #1933
Conversation
37b7bb3
to
788c457
Compare
I might need some help here. I've got the test I added passing locally, but seeing different flaky failures across runs here in CI. Any pointers? Thank you! |
Using enforce pre will pass typescript code directly to the Babel react refresh plugin, I am not sure this is supported by the react refresh plugin |
That's a good point. I did try it and I thought it worked, maybe I was mistaken. I'll investigate later. (That's not related to the failing test tho :( ) |
c1b4b8b
to
a67c641
Compare
I'm a bit confused by why the tests are failing, and would appreciate someone explaining it to me?
I'm clearly missing some context haha. Could someone explain the spookiness to me? And should I just skip my tests when |
61e7f9d
to
688a23c
Compare
@threepointone ah yes, to make HMR tests eaiser, Yes you should just skip your test for build. |
This PR is derived from the work at https://github.com/threepointone/vite-plugin-react-jsx. It has 2 specific changes: - It adds `enforce: 'pre'` to the plugin, so that it gets called before it gets passed through `esbuild` (i.e. before it loses jsx tags). It modifies the parserOpts passed to babel to account for this. - It adds 2 babel plugins (`transform-react-jsx-self`, `transform-react-jsx-source`) which adds metadata on to jsx tags, allowing tools like React Devtools to show filename and line number information for an element. There's a separate conversation to have about providing support for React's new jsx transform, and potentially renaming the plugin (if at all), but we can talk about that later. There's value in just landing this separately right now imo.
688a23c
to
324eade
Compare
Aha, I missed that |
I'm getting this error after upgrade to 1.3, any ideas how to solve it?
|
Could you file a new issue with more details and a minimal repro? |
This PR is derived from the work at https://github.com/threepointone/vite-plugin-react-jsx. It has 2 specific changes:
enforce: 'pre'
to the plugin, so that it gets called before it gets passed throughesbuild
(i.e. before it loses jsx tags). It modifies the parserOpts passed to babel to account for this.transform-react-jsx-self
,transform-react-jsx-source
) which adds metadata on to jsx tags, allowing tools like React Devtools to show filename and line number information for an element.There's a separate conversation to have about providing support for React's new jsx transform, and potentially renaming this plugin (if at all), but we can talk about that later. There's value in just landing this separately right now imo.