Closed unknownconstant closed 1 week ago
repro repo: https://github.com/unknownconstant/nx_28189 branch with fix https://github.com/unknownconstant/nx_28189/tree/fixed
I appreciate the scale of nx means keeping everything working perfectly is difficult and I've noticed it's definitely got more stable over the years. When it works it's great.
I'm relieved to have found a solution but unnerved that I don't know why it didn't work initially, and don't know why the additional explicit config helped.
I cloned your repo, https://github.com/unknownconstant/nx_28189 specifically main
without making any changes and HMR is enabled.
Can you check your browser console?
@ndcunningham thanks for taking the time to review this.
Yes, I see the same thing in the console, HMR is seemingly enabled. When you then make a code (well, any) change and the HMR triggers, the update fails to render in the browser and a full page refresh is triggered.
So the point is in main it appears that HMR is enabled, and everything looks good up until you actually make a change and it cannot apply the update.
I don't know what the difference is, but I've been able to replicate this across Mac & windows, different browsers, with new nx repos & old nx repos, and the repro I linked here.
Current Behavior
Following on from #22658 which I didn't provide a repro from, I've come back to re-try inference as there's been more time for things to mature and become more stable.
I got the same issue: new project but no HMR using webpack in a generated react project. I was able to fix it by adding 'hot: true' to the webpack devserver config. This isn't intuitive as webpack's devserver appears to use HMR anyway, I'm left unsure why adding this explicit flag changed anything.
Expected Behavior
HMR should work out of the box, OR, some obvious message which explains why its not working, or that the hot: true line needs to be manually added etc.
The fact it was a one-line fix is bittersweet because it's taken a significant amount of time to track down. Because it's so simple to fix I'm unsure if this is me missing something I should have known, or if this is a gap in nx's testing. HMR appears to work from the terminal.
GitHub Repo
No response
Steps to Reproduce
Create new project using generator
Call
npx create-nx-workspace
from parent dir:cd nx repro
yarn add -D @nx/react
Demo
Use
nx serve nx-repro
& open in browserWhen making any changes (even non-code changes like adding a comment or line break), observe the browser console reports error similar to
Aborted because 103 is not accepted
and reloads the page. Terminal console:Fix
add
hot: true,
towebpack.config.js
in devServer:Observe that HMR updates are applied
Nx Report
Failure Logs
No response
Package Manager Version
No response
Operating System
Additional Information
No response