Commit 4f2cd08
committed
FIX: Add React preset to Babel config for JSX support
Critical Bug Found:
When disable_lwc_base_config: true, the smart parser selection used Babel
from LWC config but WITHOUT the @babel/preset-react preset. This caused
React .jsx files to fail parsing with error:
'Parsing error: This experimental syntax requires enabling one of the
following parser plugin(s): "jsx", "flow", "typescript"'
Root Cause:
- createJavascriptConfigArray() extracts Babel parser from LWC config
- LWC Babel config only has presets for LWC/decorators, not React JSX
- .jsx files require @babel/preset-react to parse JSX syntax
- Without it, Babel fails to recognize JSX tags like <div>
Solution:
Add @babel/preset-react to the Babel options when using smart selection:
- Maintains LWC decorator support
- Adds React JSX support
- Consistent with createJavascriptPlusLwcConfigArray() behavior
Testing:
✅ LWC .js files with decorators: Parse correctly
✅ React .jsx files with JSX: Parse correctly (was failing before)
✅ React .tsx files: Parse correctly
✅ No parsing errors in dreamhouse project
Impact:
- Fixes regression where React files broke with disable_lwc_base_config: true
- Maintains all decorator support for LWC
- Ensures both LWC and React work together1 parent 4474516 commit 4f2cd08
1 file changed
Lines changed: 14 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
161 | 173 | | |
162 | 174 | | |
163 | 175 | | |
164 | 176 | | |
165 | 177 | | |
166 | 178 | | |
167 | | - | |
| 179 | + | |
168 | 180 | | |
169 | 181 | | |
170 | 182 | | |
| |||
0 commit comments