react-refresh-webpack-plugin icon indicating copy to clipboard operation
react-refresh-webpack-plugin copied to clipboard

Is there a way to disable this plugin on a specific entry?

Open luokebi opened this issue 4 years ago • 5 comments

I have mutiple entries, such as pageA and pageB. They render in different html. So I don't want to pageB get refresh when I was edit components used in pageA.

luokebi avatar Jun 18 '21 05:06 luokebi

If they both run in the same Webpack instance there are no safe way to disable it because the runtime is injected globally and any HMR to any entry would propagete.

pmmmwh avatar Jun 27 '21 23:06 pmmmwh

I have a similar issue where my browser extension has a full-page mode and also injects code into websites. Notably, there are two issues when code is injected into websites:

  1. Any call to localhost for hot reloading such as webpack-hot-middleware fails (but I think nothing can be done about this because as you mentioned in your comment)
  2. If the website throws an error ReactRefreshWebpackPlugin will cause an error overlay to appear

I think point (2) should be addressable similar to what was done in #146 (do not inject the overlay for excluded entries). I tried to use the existing exclude argument to do this, but I couldn't manage to get it to give the desired result.

SebastienGllmt avatar Nov 22 '21 13:11 SebastienGllmt

I think point (2) should be addressable similar to what was done in #146 (do not inject the overlay for excluded entries). I tried to use the existing exclude argument to do this, but I couldn't manage to get it to give the desired result.

Hey, sorry I totally missed this comment.

In short, currently this is impossible due to how error overlays work: we listen on the global error and unhandled rejection events. React (nor do Webpack) does not expose "where" some error is originated, so it is complicated to filter out errors from "excluded" entries. In theory this could work, but would be very unreliable when things are transpired, mini died or uglified.

pmmmwh avatar Dec 12 '21 22:12 pmmmwh

@pmmmwh Any news about it? Thanks!

igorMIA avatar Jan 17 '23 16:01 igorMIA

@pmmmwh im also interested in this feature. I split some analytics code and when i have two webpack entries i get weird errors when updating a component which is just in the main app. For example

Uncaught TypeError: Cannot set properties of undefined (setting './src/components/Page/Header.tsx')
    at globalThis.webpackHotUpdate_snip_app (jsonp chunk loading:45:1)
    at app.fc9470d69894923203c7.hot-update.js:2:59
globalThis.webpackHotUpdate_snip_app @ jsonp chunk loading:45
(anonymous) @ app.fc9470d69894923203c7.hot-update.js:2

while with a single entry i do not have this. So if i could exclude one that would help. I didnt look that much deeper into why this is hapening.

maapteh avatar Mar 08 '23 13:03 maapteh