next.js
next.js copied to clipboard
Turbopack HMR does not work when using ternaries and JSX together.
Link to the code that reproduces this issue
https://github.com/heyitsarpit/turbo-hmr-bug
To Reproduce
- Clone the repo provided
- run
pnpm dev - go to localhost:3000
- increment the counter on the screen
- edit text in
HMR_Works.tsx - edit text in
HMR_Error.tsx - observe the counter state after editing both files.
Current vs. Expected behavior
Expected behaviour: React state should not be reset after editing either HMR_Works.tsx or HMR_Error.tsx
Current behaviour: Editing HMR_Error.tsx causes a full page reload and the react state resets.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.5.0: Wed May 1 20:16:51 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T8103
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 20.17.0
npm: 10.8.2
Yarn: 1.22.19
pnpm: 9.1.3
Relevant Packages:
next: 14.2.6 // Latest available version is detected (14.2.6).
eslint-config-next: N/A
react: 18.3.1
react-dom: 18.3.1
typescript: 5.5.4
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Performance, Turbopack
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
I did not observe this behaviour with webpack. Also HMR keeps failing even if I comment out the ternary + JSX code.