-
Notifications
You must be signed in to change notification settings - Fork 17
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 error with hot module replacement #264
base: main
Are you sure you want to change the base?
fix error with hot module replacement #264
Conversation
libs/isograph-react-disposable-state/src/useCachedResponsivePrecommitValue.ts
Show resolved
Hide resolved
Now |
This is not erroring, but the environment cache will indeed produce stale components PS. so if we fix component cache we will receive fresh components, and it shouldn't cause these errors PPS. the issue seems to be components get hot reloaded, but somehow |
It's interesting that |
If you place |
weird |
…ePathToSourceFile - These aren't relative, yet! But they will be after a future commit.
Note that this currently doesn't match the description. But this is in the interest of breaking up the commit into smaller chunks. Future commits will align the behavior and the description.
This post from Dan Abramov explains pretty much exactly how HMR works. The identity of function rendered - readerWithRefetchQueries.readerArtifact.resolver(firstParam, additionalRuntimeProps)
+ <readerWithRefetchQueries.readerArtifact.resolver {...firstParameter} /> We can't do that because we will lose the second parameter. Solutions:
|
Great find. The gist describes several possible approaches. Do you know which one is actually used by HMR? Is the HMR code adding
What I seeOn
Random thoughts about two params
Our own integration with HMR
|
bdd06db
to
c8d6a76
Compare
…PatrykWalach/isograph into bandaid-error-on-hot-module-replacement
We see that Okay, just noticing that. I don't know what that implies |
Keeping stale references to resolvers is not an issue.
The way HMR works is every component refers to By calling as a function |
This means you probably didn't run |
Oh sorry, I was on main. Maybe that's why we were seeing different errors |
Ohhh sorry. I hadn't read the latest changes in your PR. That's a helpful description. So HMR is "working", and that's re-running the effect, and the effect is being run despite the component returning early, so we throw in an effect. That makes sense. Can you explain why I'll try to re-review holistically. Great work!!! And great detective work!!! |
HMR seems to work with |
- Follows the logic of the AbsoluteEmbeddedLocation struct, namely that it will require an absolute path to Isograph config's project root for std::fmt::Display
For no babel transform HMR will revalidate all the files upwards, but we will still rerender with stale components from the cache. To cover this case, We can add the If the users don't want to use babel transform but want HMR, splitting const isoFoo = iso(`field Foo ...`)
export const Foo = isoFoo(function Foo(){/* ... */}) The reason this works is because react has to support builtin |
I don't think we need to extensively support the non-babel transform case |
Can they do
? |
They can't because this double function call is not recognized as |
If someone doesn't use |
When hot module replacement happens the
parentCache
doesn't change butuseEffect
is rerun (don't know what the exact cause of this is), whenuseEffect
is rerun it crashes, because it can't accesscacheItem
anymore.The extra check makes sure effect is run once per
parentCache
(maybe we are compatible withStrictMode
now?)