Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
luokebi opened this issue Jun 18, 2021 · 5 comments
Open

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

luokebi opened this issue Jun 18, 2021 · 5 comments

Comments

@luokebi
Copy link

luokebi commented Jun 18, 2021

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.

@pmmmwh
Copy link
Owner

pmmmwh commented Jun 27, 2021

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.

@SebastienGllmt
Copy link

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.

@pmmmwh
Copy link
Owner

pmmmwh commented Dec 12, 2021

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.

@igorMIA
Copy link

igorMIA commented Jan 17, 2023

@pmmmwh Any news about it? Thanks!

@maapteh
Copy link

maapteh commented Mar 8, 2023

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants