Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added developmentSourceSelfoption to gatesource/self in jsxDEV#17845

Open
rootvector2 wants to merge 3 commits intobabel:mainfrom
rootvector2:jsx-dev-remove-source-self-default
Open

Added developmentSourceSelfoption to gatesource/self in jsxDEV#17845
rootvector2 wants to merge 3 commits intobabel:mainfrom
rootvector2:jsx-dev-remove-source-self-default

Conversation

@rootvector2
Copy link

Q A
Fixed Issues? Fixes #17571
Patch: Bug Fix?
Major: Breaking Change? 👍
Minor: New Feature? 👍
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

React 19.2 removed the source and self parameters from jsxDEV. Babel still unconditionally generates them in development mode which causes unnecessary overhead.

This PR adds a developmentSourceSelf option to @babel/plugin-transform-react-jsx and @babel/preset-react. When set to true the plugin generates __source and __self as before. The default is false in Babel 8 so the output aligns with the current React runtime.

Users who still need these arguments (e.g. older React versions or custom runtimes) can opt back in:

{
  "presets": [
    ["@babel/preset-react", { "development": true, "developmentSourceSelf": true }]
  ]
}

@babel-bot
Copy link
Collaborator

babel-bot commented Mar 1, 2026

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/61093

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 1, 2026

Open in StackBlitz

commit: 6b7b62d

@rootvector2
Copy link
Author

HI @JLHwung
i have set the default value to false instead of undefined

@JLHwung JLHwung added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: Needs Docs labels Mar 2, 2026
JLHwung
JLHwung previously approved these changes Mar 2, 2026
Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this PR looks good to me.

I marked this PR as a breaking change because we will not release new minor for Babel 7 and the new output may not work with old React versions.

Could you also prepare a docs update to the babel-website? Specifically, we will need a migration note mentioning this change in https://github.com/babel/website/blob/main/docs/v8-migration.md

@JLHwung
Copy link
Contributor

JLHwung commented Mar 2, 2026

The CI error is not related and has been fixed on main. I will rebase this branch to make the CI green.

@rootvector2
Copy link
Author

Thank you, this PR looks good to me.

I marked this PR as a breaking change because we will not release new minor for Babel 7 and the new output may not work with old React versions.

Could you also prepare a docs update to the babel-website? Specifically, we will need a migration note mentioning this change in https://github.com/babel/website/blob/main/docs/v8-migration.md

Done i have prepare a docs update to the babel-website...
babel/website#3185

Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks good to me and I agree with the new default.

I don't know if we'll have another Babel 7 minor release, but if we do, do you think we should backport this PR (with the default value flipped to true)?

@rootvector2
Copy link
Author

yeah I think backporting makes sense. with the default set to true there's no breaking change for babel 7 users, and it gives people on react 19.2+ a way to opt out early. also makes the babel 8 migration smoother since they can set the option explicitly before upgrading.

pragma: PRAGMA_DEFAULT = DEFAULT.pragma,
pragmaFrag: PRAGMA_FRAG_DEFAULT = DEFAULT.pragmaFrag,

developmentSourceSelf: DEVELOPMENT_SOURCE_SELF = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This option should be passed from createPlugin, rather than the returned plugin callback. The main plugin should not be aware of the developmentSourceSelf option.

@JLHwung JLHwung dismissed their stale review March 3, 2026 15:17

pending option passing changes.

…tions

Move developmentSourceSelf from the Options interface (user-facing plugin
options) to the createPlugin factory parameter. This ensures the main
plugin is not aware of the developmentSourceSelf option.

The preset-react now imports createPlugin directly and passes
developmentSourceSelf when creating the development plugin instance.
@rootvector2 rootvector2 force-pushed the jsx-dev-remove-source-self-default branch from 9fa3a62 to 6b7b62d Compare March 3, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: Needs Docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@babel/plugin-transform-react-jsx-development still generates source and self arguments for jsxDEV, which were removed in React 19.2

4 participants