Skip to content
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

JSX DEV transform is undocumented #2845

Closed
gaearon opened this issue Oct 30, 2023 · 2 comments · Fixed by #2846
Closed

JSX DEV transform is undocumented #2845

gaearon opened this issue Oct 30, 2023 · 2 comments · Fixed by #2846
Assignees

Comments

@gaearon
Copy link
Member

gaearon commented Oct 30, 2023

React has two entry points:

  • react/jsx-runtime
  • react/jsx-dev-runtime

What I didn't realize is that the JSX Babel plugin does not automatically emit the correct one based on environment — and also does not provide an option to switch between them. Instead, the DEV transform is implemented as a completely separate plugin called @babel/plugin-transform-react-jsx-development.

Ideally we need to:

  • Document the fact that two plugins exist
  • Have a page for @babel/plugin-transform-react-jsx-development on the site (currently it's 404)
  • Have @babel/plugin-transform-react-jsx link to it and have a prominent notice that you should use the other one for dev
@JLHwung JLHwung self-assigned this Nov 7, 2023
@JLHwung
Copy link
Contributor

JLHwung commented Nov 7, 2023

The preset-react does offer a development option to toggle between the DEV transform and the vanilla transform.

The DEV transform has been merged to the JSX plugin in 2020, so the DEV plugin @babel/plugin-transform-react-jsx-development is merely a reexport of the DEV transform in JSX plugin now. We can consider add a development option to the JSX plugin @babel/plugin-transform-react.

What do you think we start to deprecate the DEV plugin from the next minor release, in favor of the JSX plugin with the {development: NODE_ENV==="development" } option? We can also make that as the defaults of the JSX plugin and preset-react in Babel 8.

As for now I will add a document for the DEV plugin. Once the development option of the JSX plugin is ready, we will put a note for people to migrate to that option instead of having two JSX plugins in the package.json.

@dante01yoon
Copy link

  • react/jsx-dev-runtime

@gaearon does react/jsx-dev-runtime use @babel/plugin-transform-react-jsx-development default?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants