-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby): Add preliminary fast-refresh integration #26664
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Gatsby Cloud Build Reportgatsby 🎉 Your build was successful! See the Deploy preview here. Build Details🕐 Build time: 5m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one question, otherwise LGTM.
This comment has been minimized.
This comment has been minimized.
cbc6227
to
274c377
Compare
Not sure how to move forward with this now. The tests won't pass while multiple versions of React are installed (e.g., installing React 16.9+ for the e2e tests to use fast refresh while gatsby-cli installs 16.8). We need to find a way to decouple the react version from gatsby-cli. I'm afraid we're only going to run into more and more of these problems as we work to support React 17. is this now proving to be a requirement for Gatsby v3? |
I just opened #26887 that removes |
@pieh awesome! Ping me when it goes through and I'll update this branch and hopefully the tests pass then! |
69d5922
to
f01cccc
Compare
857459b
to
fd25b48
Compare
This reverts commit 66c6400
…if-react-supports
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! 🎉
We still have to make decision on enabling by default for react@17, but we shouldn't block all the improvements done here on that.
Description
TL;DR: Custom overlay, removing page query export, adding some tests
Fast Refresh is supported with React 16.8+. Previously we've only been using FastRefresh if users specifically set
GATSBY_HOT_LOADER=fast-refresh
. The problem here is that React 17 does not work withreact-hot-loader
and so the better option here is to detect if the react version supports fast refresh.This PR is to sniff into react's version and detect if fast refresh is usable. The user is still able to override it withGATSBY_HOT_LOADER=react-hot-loader
.We'll revisit this in another PR.
This PR also ensures that page queries are removed via babel because with FastRefresh, updates scan upwards through their module tree to scan for usages to know what modules all need updating. With page queries there is a big problem because they are never imported, the end effect is then that the FastRefresh can't know if it's safe to update and will reject the update requiring the user to reload. This is bad because page queries are quite common.
This is potentially problematic with #20672, so we might need to address that before this can be merged.nvmThis PR/implementation is not perfect and most likely will be refactored when we release it for everyone, until then this is good enough. Some TODOs were left in the code on purpose, not needed to be addressed in this PR.
Documentation
Only when Fast Refresh is available for everyone (as we e.g. bump the minimum React version) we need to change docs.
Related Issues
[ch19063]