fix: Fix React source locations for Vite 8 compatibility#24140
Merged
Conversation
b092880 to
b057afe
Compare
Two changes to fix source location tracking when using Vite 8/Rolldown: 1. Replace @rolldown/plugin-babel with a custom Vite plugin using @babel/core directly. The @rolldown/plugin-babel hardcodes enforce:'pre', making Babel run before @vitejs/plugin-react (OXC). This caused OXC to see Babel-modified code and produce wrong line numbers in jsxDEV() source info. The custom plugin uses enforce:'post' so Babel runs after OXC. 2. Update addFunctionComponentSourceLocationBabel to read the original source file from disk instead of using Babel AST positions. When running after OXC, Babel's AST loc values refer to the transformed code, not the original. Reading the file directly ensures __debugSourceDefine always contains correct original line numbers.
b057afe to
033262a
Compare
…bel from test
- Handle arrow functions with JSX body directly after => (e.g.
const Foo = () => <div>) instead of only { or (
- Remove @rolldown/plugin-babel from NodeUpdaterTest expected
dependencies since it was replaced by direct @babel/core usage
|
platosha
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Two changes to fix source location tracking when using Vite 8/Rolldown:
Replace @rolldown/plugin-babel with a custom Vite plugin using
@babel/core directly. The @rolldown/plugin-babel hardcodes
enforce:'pre', making Babel run before @vitejs/plugin-react (OXC).
This caused OXC to see Babel-modified code and produce wrong line
numbers in jsxDEV() source info. The custom plugin uses
enforce:'post' so Babel runs after OXC.
Update addFunctionComponentSourceLocationBabel to read the original
source file from disk instead of using Babel AST positions. When
running after OXC, Babel's AST loc values refer to the transformed
code, not the original. Reading the file directly ensures
__debugSourceDefine always contains correct original line numbers.