Commit 748ff8a
authored
fix: Fix React source locations for Vite 8 compatibility (#24140)
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.1 parent 5bdf472 commit 748ff8a
4 files changed
Lines changed: 101 additions & 30 deletions
File tree
- flow-build-tools/src
- main/resources/plugins/react-function-location-plugin
- test/java/com/vaadin/flow/server/frontend
- flow-server/src/main/resources
- com/vaadin/flow/server/frontend/dependencies/vite
Lines changed: 73 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
9 | 68 | | |
10 | 69 | | |
11 | | - | |
| 70 | + | |
12 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
13 | 75 | | |
14 | | - | |
15 | | - | |
16 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
17 | 81 | | |
18 | 82 | | |
19 | 83 | | |
20 | | - | |
21 | | - | |
| 84 | + | |
| 85 | + | |
22 | 86 | | |
23 | 87 | | |
24 | 88 | | |
| |||
48 | 112 | | |
49 | 113 | | |
50 | 114 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 115 | + | |
54 | 116 | | |
55 | 117 | | |
56 | 118 | | |
57 | 119 | | |
58 | 120 | | |
59 | | - | |
| 121 | + | |
60 | 122 | | |
61 | 123 | | |
62 | 124 | | |
| |||
66 | 128 | | |
67 | 129 | | |
68 | 130 | | |
69 | | - | |
70 | | - | |
71 | | - | |
| 131 | + | |
72 | 132 | | |
73 | 133 | | |
74 | 134 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
173 | | - | |
174 | 173 | | |
175 | 174 | | |
176 | 175 | | |
| |||
Lines changed: 0 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
533 | 533 | | |
534 | 534 | | |
535 | 535 | | |
536 | | - | |
537 | | - | |
538 | | - | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
550 | 563 | | |
551 | 564 | | |
552 | 565 | | |
| |||
0 commit comments