-
Notifications
You must be signed in to change notification settings - Fork 3
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
Overlay blocks hot-reload refreshing page #5
Comments
It seems that a work around for this problem is to import the overlay into your app (similar to
I'll update the When I get a chance I'll look into why this is happening, and how to solve it so users can switch back to including the overlay as an entry in their webpack config. |
…g entry This is b/c when included as an entry, the overlay prevents hot-reloading from refreshing the page for some reason, as documented in issue #5.
I think the importing solution above is actually the better way of using the overlay, as it sidesteps a lot of the problems that entry (& automatic entry insertion) brings. I'm keeping this issue open for now, as I'm still interested in figuring out why it breaks the hot-reloading, and what the proper steps to make it play nice, just for any future development in this area. |
@G-Rath I think it would be good to move the conditional With that built-in, I believe that the This would also make it easier to show any errors that may pop up before the |
@agilgur5 I do like the The whole idea with the check is that it's not actually part of the library itself: How you use the overlay is up to you. If you want to include the library in production, so be it. The example with the I've already seen one library that includes the overlay without any conditional checks, along with another that does their conditional checks seperately. I love the idea of only having to use a single It could be a matter of adding another env variable as an override, something like I'll definitely keep this in the back of my mind for when me & @shellscape look to add new features, as that may lead to us splitting the package up into a couple of files, allowing you in turn to import different files depending on what you wanted (i.e the @jxnblk & @pedronauck if you don't mind me roping you guys into this, I'd be interested in hearing your thoughts (if any), as while this change makes sense for the majority of app-focused projects, your projects seem to be more for assisting in developing apps themselves, and so represent the most common "edge" case use of the overlay that this change would have an impact on. |
Thanks for the detailed response @G-Rath !
I suppose that's reasonable, it just wouldn't be a best practice to use
It will still be axed from the bundle if using
Not something I thought of either until webpack/webpack#2776 haha. Based on my usage, it seemed like this library will not overlay an error if it occurred on the very first build before the
I think having a separate entry file here that includes the check makes sense and is the simplest option that doesn't change other behavior (as opposed to within the file). |
Thanks for getting involved, and bring some interesting points to the table @agilgur5 !
That depends on your definition of "production" - case & point is the two packages that I referenced: They have a legitimate use case for using the overlay in production, as their production is as a development app for other devs to work with.
Totally absolutely definitely make a new issue for this - please & thank you! I'll say that for now it's undecided behaviour, until I've had a chance to check it out myself, but ideally it shouldn't crash everything if a hot-client isn't running. This could just result in "don't use it without a hot-client", but still merits investigation so I at least know whats actually happening.
I know that's the theory, but I've read some interesting things of late (that I've not had a chance to properly investigate) about that while Webpack in theory should be able to chuck out a lot of code, it seems that in practice it doesn't always throw out what you think it would. It's by far not the biggest deal, but just something I want to have a play around with myself to get some clarity on what sort of code Webpack can & can't deal with. I won't block any changes b/c of this point, and mention it just to indicate what my (current) understanding is.
I agree - for the time being I think I'll make up just a simple 'onlyIfProduction.js' file that has the check, and release that. Then when time permits, look into the other suggestions we've talked about.
That's what I was thinking, but it'd be dependent on some of the new ideas & features shellscape has in mind, as like you said adding it now would just introduce unnecessary complexity for something that's of little gain. Along with that, I did initially look into using a middleware, but don't think it'll actually work:
I'm not entirely sure what you mean by this, but I think I know what you're getting at - I've not done anything with the However, at the very least, you should be able to do the check in the I'm a little overworked right now, so forgive me if I've missed a point or anything, but I'm very excited - this is some great stuff 😃 |
Ah, I didn't look at those links besides the lines you referenced. The term "best practice" effectively means the "best option for the most often used scenario", but maybe we have different interpretations of that term. Indeed, those two packages aren't the "wrong" way of doing it, they just serve different means / purposes and therefore deviate from the common usage. 👍
Done, see #8 . Not a big error as it's just because
Can't really tell what you're talking about without a link, but yea tree shaking (usually part of the bundler, i.e. Webpack, Rollup, etc) and dead code analysis (usually part of the minifier, i.e. Uglify, etc don't work in all cases as they might not know enough to guarantee the code is unused. Tree shaking specifically relies on ESM imports and asks for you to label code as with or without side-effects. It's probably best to trial-and-error with some minification options turned off (i.e. no mangling and such so it's still readable). Could potentially add a diff test if that were important enough though I've never had to deal with the topic to such an extent to really give good advice on it.
Done, see #9 .
Makes sense to me 👍 . Those are more complicated and all of the above are just to enhance usability, so probably an nbd for most people
Yea I was thinking a middleware could just inject a script tag if any HTML is being returned in the most naive case, which should simplify things quite a bit. idk what types of edge cases one might want to handle in more complex cases, but that's what issues and iteration are for.
I meant if someone were still going to import this into their code, as opposed to adding it as an entry. I think if one added
Yea of course that's another option available. |
Just an update here, similar to my edit above, that the ideal usage in my opinion is to use with
which would obviate the need for |
For some reason the presents of the overlay entry results in hot-reload not refreshing the page when it needs to:
This is what a normal hot-reload looks like in the console:
But with the overlay:
I suspect that the hot-reload system works by having a global try/catch that the overlay bundle isn't included in, so it doesn't think the hot-reload errored out like normal.
The text was updated successfully, but these errors were encountered: