Skip to content
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

(core) - map old VNodes to new ones #236

Merged
merged 2 commits into from
Dec 11, 2020
Merged

(core) - map old VNodes to new ones #236

merged 2 commits into from
Dec 11, 2020

Conversation

JoviDeCroock
Copy link
Member

@JoviDeCroock JoviDeCroock commented Dec 11, 2020

This was kindly reported by @iFwu this is the second part of this bug-report https://github.com/iFwu/prefresh-bugs-reproduce

This mainly happens in esm-hmr, let's visualize what's happening here, information about esm-hmr can be found here.

When we update Counter.jsx, the child of Internal.jsx we do the following implicitly import Counter.jsx?mtime=Date.now() this will make our babel-functions re-run and register the new type for Counter.jsx. For in place updates this works great, but when we now update Internal.jsx we'll be importing the old variant of Counter.jsx since during esm-hmr we have no way to update this ModuleRecord in place, essentially the Counter.jsx?mtime=Date.now() is orphaned and disposed instantly.

internal.jsx updates with the old reference, without checking for a new one to exist (byte-cache), this makes it render with the initial code rather than the new.

We've solved this by keeping a mapping of old to new functional components, when we see a vnode created with a supposedly old reference we update it to the new one.

@changeset-bot
Copy link

changeset-bot bot commented Dec 11, 2020

🦋 Changeset detected

Latest commit: 3d4e12c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@prefresh/core Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants