Skip to content

Commit b783190

Browse files
authored
fix: enable retainLines to get correct line numbers for jsxDev (#246)
1 parent 05ef392 commit b783190

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

packages/plugin-react/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Enable retainLines to get correct line numbers for jsxDev (fix [#235](https://github.com/vitejs/vite-plugin-react/issues/235))
6+
57
## 4.1.0 (2023-09-24)
68

79
- Add `@types/babel__cores` to dependencies (fix [#211](https://github.com/vitejs/vite-plugin-react/issues/211))

packages/plugin-react/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ export default function viteReact(opts: Options = {}): PluginOption[] {
235235
root: projectRoot,
236236
filename: id,
237237
sourceFileName: filepath,
238+
// Required for esbuild.jsxDev to provide correct line numbers
239+
retainLines: !isProduction && isJSX && opts.jsxRuntime !== 'classic',
238240
parserOpts: {
239241
...babelOptions.parserOpts,
240242
sourceType: 'module',

0 commit comments

Comments
 (0)