babel / website

:globe_with_meridians: The Babel documentation website
https://babeljs.io/docs/en/index.html
MIT License
749 stars 1.3k forks source link

JSX DEV transform is undocumented #2845

Closed gaearon closed 8 months ago

gaearon commented 9 months ago

React has two entry points:

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:

JLHwung commented 9 months ago

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 commented 3 months ago
  • react/jsx-dev-runtime

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