diff --git a/docs/plugin-transform-react-jsx-development.md b/docs/plugin-transform-react-jsx-development.md index fc41977c9c..24e61407e7 100644 --- a/docs/plugin-transform-react-jsx-development.md +++ b/docs/plugin-transform-react-jsx-development.md @@ -119,4 +119,16 @@ require("@babel/core").transformSync("code", { ## Options +:::babel8 + +#### `developmentSourceSelf` + +`boolean`, defaults to `false`. + +When `true`, the plugin generates `__source` and `__self` arguments in `jsxDEV` calls. These were used by older versions of React for development warnings but have been removed since React 19.2. + +Set this to `true` if you are using a React version older than 19.2 or a custom JSX runtime that depends on these arguments. + +::: + It accepts the same options as [`@babel/plugin-transform-react-jsx`](./plugin-transform-react-jsx.md#options). diff --git a/docs/preset-react.md b/docs/preset-react.md index d468c61c67..81b6a87c9e 100644 --- a/docs/preset-react.md +++ b/docs/preset-react.md @@ -139,6 +139,18 @@ This toggles behavior specific to development, such as adding `__source` and `__ This is useful when combined with the [env option](options.md#env) configuration or [js config files](config-files.md#javascript). +:::babel8 + +#### `developmentSourceSelf` + +`boolean`, defaults to `false`. + +When `true`, the plugin generates `__source` and `__self` arguments in `jsxDEV` calls. These were used by older versions of React for development warnings but have been removed since React 19.2. + +Set this to `true` if you are using a React version older than 19.2 or a custom JSX runtime that depends on these arguments. + +::: + #### `throwIfNamespace` `boolean`, defaults to `true`. diff --git a/docs/v8-migration.md b/docs/v8-migration.md index 5908a811ec..17d8265292 100644 --- a/docs/v8-migration.md +++ b/docs/v8-migration.md @@ -441,6 +441,21 @@ The following syntax plugins are no longer needed, you can safely remove them fr **Migration**: The preset will also report invalid option names. Refer to the [docs](./preset-react.md#options) and ensure valid usage. +- Stop generating `__source` and `__self` in development mode by default ([#17571](https://github.com/babel/babel/issues/17571)) + + React 19.2 removed the `source` and `self` parameters from `jsxDEV`. Babel 8 no longer passes them when calling `jsxDEV` in development mode. + + **Migration**: If you are using React 19.2 or later you don't need to do anything. If you are using an older React version or a custom JSX runtime that still expects these arguments, set `developmentSourceSelf` to `true`: + + ```diff title="babel.config.json" + { + "presets": [ + - ["@babel/preset-react", { "development": true }] + + ["@babel/preset-react", { "development": true, "developmentSourceSelf": true }] + ] + } + ``` + ![low](https://img.shields.io/badge/risk%20of%20breakage%3F-low-yellowgreen.svg) - Disallow `filter` option in automatic runtime ([#15068](https://github.com/babel/babel/pull/15068/commits/e2dd3be6e38b0254bc69a8e52c265214235829c6))