next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Turbopack HMR does not work when using ternaries and JSX together.

Open heyitsarpit opened this issue 1 year ago • 0 comments

Link to the code that reproduces this issue

https://github.com/heyitsarpit/turbo-hmr-bug

To Reproduce

  1. Clone the repo provided
  2. run pnpm dev
  3. go to localhost:3000
  4. increment the counter on the screen
  5. edit text inHMR_Works.tsx
  6. edit text in HMR_Error.tsx
  7. 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.

heyitsarpit avatar Aug 27 '24 10:08 heyitsarpit