Skip to content

fix: Fix React source locations for Vite 8 compatibility#24140

Merged
Artur- merged 3 commits intomainfrom
feature/reactsource
Apr 18, 2026
Merged

fix: Fix React source locations for Vite 8 compatibility#24140
Artur- merged 3 commits intomainfrom
feature/reactsource

Conversation

@Artur-
Copy link
Copy Markdown
Member

@Artur- Artur- commented Apr 17, 2026

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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 17, 2026

Test Results

 1 391 files  ±0   1 391 suites  ±0   1h 13m 11s ⏱️ -5s
 9 997 tests ±0   9 926 ✅ ±0  71 💤 ±0  0 ❌ ±0 
10 472 runs  ±0  10 392 ✅ ±0  80 💤 ±0  0 ❌ ±0 

Results for commit a6cada1. ± Comparison against base commit 5bdf472.

♻️ This comment has been updated with latest results.

@Artur- Artur- force-pushed the feature/reactsource branch 3 times, most recently from b092880 to b057afe Compare April 17, 2026 11:44
@Artur- Artur- changed the title fix: Run Babel after OXC to fix React source locations fix: Fix React source locations for Vite 8 compatibility Apr 17, 2026
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.
@Artur- Artur- force-pushed the feature/reactsource branch from b057afe to 033262a Compare April 17, 2026 11:48
…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
@Artur- Artur- requested a review from platosha April 17, 2026 13:27
@Artur- Artur- marked this pull request as ready for review April 17, 2026 13:27
@sonarqubecloud
Copy link
Copy Markdown

@Artur- Artur- enabled auto-merge April 18, 2026 14:56
@Artur- Artur- added this pull request to the merge queue Apr 18, 2026
Merged via the queue into main with commit 748ff8a Apr 18, 2026
50 of 51 checks passed
@Artur- Artur- deleted the feature/reactsource branch April 18, 2026 15:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants