-
Notifications
You must be signed in to change notification settings - Fork 194
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
[Meta] Releasing this Plugin as "Fast Refresh" capable #1
Comments
@pmmmwh What needs to happen in order to get this working with webpack 5? I haven't spent much time looking into the changelog there. |
@maisano
In fact - I have already implemented these changes, locally. But because webpack 5 is still in alpha, I am not sure if releasing them at this stage is a good move. Speaking of versions, I am still debating on the proper range of webpack versions to support. It would be easiest to only support webpack 4+, but I do understand that webpack 3 is still being used by a lot of people. |
@gaearon
|
Do you two wanna do a video call next week with me? Might be easier to talk through all issues. |
Sounds good. I'm on EST (GMT-4) and generally pretty flexible, so let me know what works for you all. |
Sounds good to me too. I am on GMT+8 and also pretty flexible. What time will work for you Dan? |
My progress is tracked on this branch. It is pretty rough though. |
Did the three of you ever end up talking? If I was looking to lend a hand here, what would be the most impactful thing to look into? Maybe it would be helpful for two or three of us to chat? (Assuming you'd like a hand.) |
Hi 👋 I am located in California, so yeah PST. Happy to chat for a bit to ramp up context if that would be helpful. |
Nope - we haven't talked yet. I definitely would like a hand 😃 . It would be great if you can provide more context on the error-box experience @bvaughn .
@maisano Yep that's my long abandoned Twitter account - I have opened my DMs. |
@maisano Want to start a thread between the three of us on Twitter? |
Just wanted to say that I started testing it our setup here: Seems to be working better than react-hot-loader ever did. Mainly because we mount a few different page (many of which are named export making manually wrapping them in Has there been any further discussion about implementing the error overlay? The discussion kind of trailed off. I'm available to help with that if you want assistance. |
Hey! Thanks for trying out the plugin. I'm happy that it worked well! Regarding the error overlay, we did start a conversation on Twitter on that (it is technically also tracking the progress). I haven't got all the missing pieces - yet, but here are some things that have to be addressed:
Oh, and to address your fears from your PR - the public facing API of the plugin/loader probably wouldn't have breaking changes. I try to be careful with the internals, but to handle error box I believe we might have to dig into more webpack hooks, and that might cause some change in behaviour. |
For an error experience, I'd be ok if:
Makes sense? |
Hey Dan! Thanks for the prompt reply - that is definitely going to help. I think I can also track an issue on the error overlay in the CRA repo later after I'm done with the base case - and see what needs be done (both sides) to integrate with the implementation. |
Sure I'd be happy to review. In fact let me know when you think this is ready for a DX review pass. I can write some notes on what works well and what seems missing. |
Going back on the error overlay:
I'm not 100% convinced that an error overlay needs to be part of the fast refresh implementation, especially if it would require using wrapping components in some sort of wrapper like |
To my understanding, there are 3 types of errors: build time (i.e. compilation), run time (i.e. JS/React, not caught with Error Boundaries) and integration (e.g. HMR, socket integration, dev server) error. The error integration would have to render the first 2 types gracefully for it to pass - the third type we can either fail and force page reload, or just stop propagation. Based on this assumption, we wouldn't need to wrap components like For a baseline zero-configuration setup, I argue that having the error integration would be a plus - it makes the error obvious for the user, instead of having a "blank screen of death". It provides insight on at least which part of the app is broken and places to search for in order to fix that. However, for advanced users, I think an option to disable the error integration would be something worth looking into - like if someone is force enabling this plugin in a production build. Does that make sense to you? @charrondev |
Thanks for the clarification. I took a quick look trying to find existing integrations w/ I'm not going to have any more time today to dive into it, but trying to get your error overlay branch also isn't working in our project, does it work at all on your end? |
If you add |
Can we start with just build errors for V1? |
@gaearon Consider the following example: import React from 'react';
function ComponentA() {
return <span>Component A</span>;
}
function ComponentB() {
return <span>Component B</span>;
}
export default ComponentA; If I update the last line from |
Actually, I just (few hours ago) pushed some changes to the If you don't mind - @gaearon can you can clone it and do a DX review? I still need to work on swapping out the error overlay, which probably will take me a few days, but will probably keep somewhat API-compliant to the current approach to ease integration with CRA. |
I think we should just force a full page reload for now. It would indeed be nice if webpack provided a way to do this but I don't think it's currently possible. We can definitely detect it, see the "is boundary invalidated" code in Metro. |
Another case you'll notice affected by this is changing component from exporting a class to a function. |
Regarding |
I did reference that, and have already implemented the check/bail out for full refresh 😺 .
Yes, basically any combinations of prev/next with a function would hit that.
I think it works with multiple entry points. The main assumptions to me that would fail in any projects not from CRA would be the custom dev server middlewares and |
I'll give the branch another test tomorrow now that it's updated. I'm using it multi-compiler setup w/ multiple entrypoints per compiler.
I'll double check again as well, but that seemed to be working form my testing as well, and was respecting the |
Hey all - Thanks for participating in the conversation 😺! |
Hi @pmmmwh, Thank you for your awesome work here. I would like to integrate this with https://wpack.io (https://github.com/swashata/wp-webpack-script) (A CRA like tooling for WordPress) and there I am proxying WordPress site through browser-sync with Webpack Dev Middleware and Webpack hot middleware. I see in your todo list that we need to have express like middleware to cater advance WDM users. Since I am one of those users, I would like help in anyway I can to make this possible. Any tips on where to get started? |
You can checkout #23 - the solution shown there is not perfect (because of entrypoint ordering issues). I was thinking to draft an API to allow custom entry ordering, but afaik WHM seems to be the only know hot client using |
@pmmmwh So, a solution for this, i.e support for hot middleware, is or will on its way? ps: Happy 2k20! |
Really appreciate the work you're doing here and looking forward to using this. I was looking at #36 and was also wondering if things like server-side rendering support will be included in this becoming officially "fast refresh" capable? I'd be happy to help with this, so far I've been trying to use this with Next.js but after trying to configure it for a few hours I can't get state in hooks to persist between renders, even though it's using webpack and HMR on the client side. I do have it ignoring webpack compiles on the server side, since otherwise it tries to access |
SSR support will probably be something that have to be case by case unfortunately. I don't have a lot of knowledge on specifically how SSRed components are being hydrated, so any insights will help.
For Next.js it's difficult because their Webpack setup is indeed very complicated. Next's maintainers have shown interest in adding this, so hopefully after we tackle all the prerequisites it can be available to everyone in that ecosystem. |
I wouldn't expect any differences when SSR is on. |
Initially I was expecting some difference because I wasn't sure how SSR build setups work, and the implementation here was quite rough too. With the latest iteration I think there shouldn't be any difference in Fast Refresh compatibility, but there might still be some difference in the experience due to the libraries are being used (e.g. React.lazy v.s. loadable-components) and how builds are being set up (custom SSR setups will require more config). |
This comment has been minimized.
This comment has been minimized.
@bdanzer Please see #226 (comment) |
Post here for attention: I believe error recovery is now completely broken with |
Ref: facebook/react#16604
This issues tracks what is missing before this plugin attains "feature-parity" with the RN implementation and is representative of the "fast-refresh" branding.
Tasks
iframe
) feat: error integration #3console
injection)window
)__resourceQuery
(wait for WDS v4) Add custom sockHost/sockPort/sockPath #52transportMode
or a plugin option with a similar footprint) feat: allow socket runtime to be configurable #64Express-like middleware to cater advanced WDM userscontext.hot
Detects and support multi-compilers and child-compilers (Obsolete for now, this plugin won't break in those scenarios)beta
stage (0.4.0-beta.6+
)The text was updated successfully, but these errors were encountered: