`@babel/plugin-transform-react-jsx-development` still generates `source` and `self` arguments for `jsxDEV`, which were removed in React 19.2
💻
- [x] Would you like to work on a fix?
How are you using Babel?
@babel/cli
Input code
<div className="box">Hello</div>;
Configuration file name
babel.config.json
Configuration
{
"presets": [["@babel/preset-react", {
"runtime": "automatic",
"development": true
}]]
}
Current and expected behavior
It appears that jsxDEV no longer includes the last two parameters — source and self — as of the React 19.2 release.
According to this commit, these parameters have been removed from the React source.
However, the @babel/plugin-transform-react-jsx-development plugin still generates these arguments when transpiling JSX.
For example, the following JSX:
<div className="box">Hello</div>;
is transformed into:
var _jsxFileName = "<absolute-path-to-my-jsx-file>";
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
/*#__PURE__*/_jsxDEV("div", {
className: "box",
children: "Hello"
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 1,
columnNumber: 1
}, this);
Since the jsxDEV signature no longer accepts the source and self parameters, I wonder if the plugin should stop generating these arguments when creating calls to jsxDEV.
Environment
System: OS: macOS 26.0.1 Binaries: Node: 22.2.0 npm: 10.7.0 pnpm: 10.18.0 npmPackages: @babel/cli: ^7.28.3 => 7.28.3 @babel/core: ^7.28.5 => 7.28.5 @babel/preset-env: ^7.28.5 => 7.28.5 @babel/preset-react: ^7.28.5 => 7.28.5
Possible solution
Update @babel/plugin-transform-react-jsx-development to stop generating the source and self arguments in calls to jsxDEV, aligning with the React 19.2+ API.
Therefore, the previous snippet would instead compile to the following in development mode:
import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
/*#__PURE__*/_jsxDEV("div", {
className: "box",
children: "Hello"
}, void 0, false);
Additional context
No response
Hey @SoheilSalmani! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.
If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite.
how fix it?
Thank you for opening this issue, it is detailed and very helpful.
The babel-preset-react is designed to work with most React versions, if we remove source and self from the output, it would be a breaking change for those users with React < 19.2.
I suggest we add a new boolean option developmentSourceSelf (alternative namings are welcome) to preset-react and the underlying transform-react-jsx-development. When this option is true, Babel will generate the source and self argument in jsxDEV. When it is false, those arguments will be omitted.
To preserve compatibility, this option will default to true in Babel 7. In Babel 8, this option will default to false to align with modern React versions.