pmmmwh / react-refresh-webpack-plugin

A Webpack plugin to enable "Fast Refresh" (also previously known as Hot Reloading) for React components.
MIT License
3.15k stars 193 forks source link

There are some edge cases where we have to manually refresh the page to see the change. #806

Open nyngwang opened 8 months ago

nyngwang commented 8 months ago

I found some edge cases:

I'm not sure whether the two problems are by design. It will be great if we can work around them. The first case is usually caused by the auto-save feature of an editor. The second case is very common when one wants to keep the fast-refresh feature during refactoring.

Need some guidance. @pmmmwh Thank you!

browser

Version 121.0.2277.128 (Official build) (arm64)

package.json

"devDependencies": {
  "@babel/core": "^7.23.7",
  "@babel/plugin-transform-runtime": "^7.23.7",
  "@babel/preset-env": "^7.23.9",
  "@babel/preset-react": "^7.23.3",
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.11",
  "babel-loader": "^9.1.3",
  "css-loader": "^6.10.0",
  "css-minimizer-webpack-plugin": "^6.0.0",
  "html-webpack-plugin": "^5.6.0",
  "jsdoc": "^4.0.2",
  "mini-css-extract-plugin": "^2.8.0",
  "react-refresh": "^0.14.0",
  "style-loader": "^3.3.4",
  "webpack": "^5.90.3",
  "webpack-cli": "^5.1.4",
  "webpack-dev-server": "^5.0.2"
},

screenshots

In the first case, the error looks like this:

In the second case, the error looks like this:

pmmmwh commented 6 months ago

I think the first one ideally should be recoverable, but might be a design limitation.

The second one probably has something to do with CSS hot reloading from css-loader, might need to dig a bit more on how things interact ...