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
fix(gatsby): improve hot-reloading for hooks #16146
Conversation
Awesome! I do have question tho. Using Now this change doesn't really break it, as it would be broken before and we don't officially support PnP for now (it mostly works, but we do break it occasionally and don't have automated tests to catch regressions). Do you feel like using a bit different rule that doesn't have notion of That's absolutely not blocker for PR - I'll try to merge this in tomorrow . |
I reckon this question should be answered by PnP itself. Many projects are expecting to find your |
@pieh we could go for Thanks @theKashey for making gatsby a little bit faster |
I'm getting Will try suggestion from @wardpeet |
Nope, same warning shows up. Now I'm not sure if this is perhaps false warning - didn't try any "16.6+" features. I added some debug logs in https://github.com/gaearon/react-hot-loader/blob/master/src/webpack/patch.js#L120-L140 And in all cases |
Interesting: And this is after applying either change from PR or suggestion from @wardpeet Seems like |
Ok. I know that it is - this is module execution order. Before
Now
SolutionIt's actually quite simple - load RHL before React or React-Dom. Easy to say, not so easy to do.
Sorry, mate, feeling very guilty. You were lucky to detect the problem, in my case (not sure why) RHL is loading before React-Dom. |
Another (and quite good) solution here would be detangling |
We can definitely try forcing to load RHL before Just gonna try |
Just prepending entry with this is or importing it early is causing error in gatsby:
But we do have some weird thing: gatsby/packages/gatsby/src/utils/webpack.config.js Lines 383 to 385 in 02f576e
https://github.com/gatsbyjs/gatsby/blob/c19a9c7c45c404b9008dba7e5bb33a25aff0ccaf/packages/gatsby/cache-dir/react-lifecycles-compat.js That was added in #7214 Removing that alias, fixes it, but I lack context on that. I'm weary of just removing it, so probably I would try to see if I can make it work with adding more "passthrough" stuff to our custom |
This is where it crashes ( trying to access I guess this happens because RHL itself imports |
Blacklisting |
You are the real Sherlock, and look like I have think a bit harder about module resolution order.
It should be or more resilient, or ignore all own dependencies. I would try to reproduce the worst scenario and make it work without any extra configuration. Honestly - it should not require any extra integration steps. Let's take a pause and not make it worse 😅 |
After few more tests I can answer this at least - when not using alias, our webpack config doesn't use
Yeah, I agree - we can make it work, but amount of hackiness we'd have to do make me pause. It's also interesting how accidentally current setup workarounds circular imports issue right now ;) |
So - I've failed to solve the problem with
|
Thank you so much for working on this @theKashey This indeed does seem to be a little tricky and since it appears that we need to rethink how to approach this/discuss some more, I think we should close this for the moment. I've opened an issue in #16534 to track this! Shall we continue the discussion there? Thank you so much once again for your work on this! We really appreciate it and would love to have you as a contributor so we're looking forward to receiving more PRs from you 💜 |
So actually all changes for this issue, including support for React 16.9, were merged tomorrow. I am doing last manual checks with a few selected projects, and releasing a new version today. Then this PR, amended with a version bump, should work almost out of the box (at last!) |
@theKashey Awesome! Feel free to reopen this with the version bump when you're ready |
The PR has been updated, however I could not reopen this one without your help, and it would not reflect the changes made while closed. |
It says the master branch was force pushed or re created so it won't let me re open either! 😅 Let's open a new one and get it in? 💃 Thank you! |
Description
This is a follow up for #13713(RHL+Hooks), and gaearon/react-hot-loader#1309 (RHL + Gatsby)
The problem: application breaking if
node_modules
exists in thesrc
dir. There is no question "why", the question is "why".Fix
In short - there is no need to apply
react-hot-loader/webpack
for allnode_modules
, only forreact-dom
to land the patch, and that's all the change.Outcome:
The problem is fixed and everything is a bit faster.
Related Issues
react-hot-loader/webpack