From a016d95c9266b91c2a86a7b2a97ffb11d3898559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hu=C3=A1ng=20J=C3=B9nli=C3=A0ng?= Date: Wed, 29 Jul 2026 11:35:29 -0400 Subject: [PATCH] update sourceSelf change docs --- docs/preset-react.md | 2 +- docs/v8-migration.md | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/docs/preset-react.md b/docs/preset-react.md index 1bfa5aa6ff..a24549bee2 100644 --- a/docs/preset-react.md +++ b/docs/preset-react.md @@ -102,7 +102,7 @@ This is useful when combined with the [env option](options.md#env) configuration 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. +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, such as `preact`. #### `throwIfNamespace` diff --git a/docs/v8-migration.md b/docs/v8-migration.md index 66f001f8ce..af6c7932a2 100644 --- a/docs/v8-migration.md +++ b/docs/v8-migration.md @@ -487,7 +487,34 @@ The following syntax plugins are no longer needed, you can safely remove them fr 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` in the preset, or `sourceSelf` to `true` in `@babel/plugin-transform-react-jsx-development`: + ```jsx title="in.jsx" + function Example () { + return Foo + } + ``` + + ```js title="out.js" + // Babel 8 + function Example() { + return /*#__PURE__*/_jsxDEV("span", { + children: "Foo" + }, void 0, false); + } + + // Babel 7 + var _jsxFileName = "..." + function Example() { + return /*#__PURE__*/_jsxDEV("span", { + children: "Foo" + }, void 0, false, { + fileName: _jsxFileName, + lineNumber: 2, + columnNumber: 10 + }, this); + } + ``` + + **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, such as `preact`, set `developmentSourceSelf` to `true` in the preset, or `sourceSelf` to `true` in `@babel/plugin-transform-react-jsx-development`: ```diff title="babel.config.json" { @@ -497,7 +524,8 @@ The following syntax plugins are no longer needed, you can safely remove them fr ] } ``` - ```diff title="babel.config.json" + + ```diff title="babel.config.json" { "plugins": [ - "@babel/plugin-transform-react-jsx-development",