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

HMR Issue with Parcel 2.0.0 release #693

Closed
lucaseverett opened this issue Oct 23, 2021 · 7 comments
Closed

HMR Issue with Parcel 2.0.0 release #693

lucaseverett opened this issue Oct 23, 2021 · 7 comments
Labels
downstream issue related tools that would use Solid

Comments

@lucaseverett
Copy link

lucaseverett commented Oct 23, 2021

Describe the bug
When using Parcel 2.0.0 final release, the root node is duplicated upon saving a file, rather than replacing it. For example, when using the Solid Parcel Starter, you'll see the following after saving a file.

Solid Parcel Starter

Solid Parcel Starter

To Reproduce

  1. Download Solid Parcel Starter from https://gitlab.com/enom/solid-parcel-starter
  2. npm i and npm run dev
  3. Make a change to index.js and observe that the page refreshes in the browser as expected.
  4. Stop server, then update parcel in package.json from "next" to "2.0.0."
  5. npm i and npm run dev
  6. Make a change to index.js and observe that the root node is duplicated rather than replaced

Expected behavior
Upon saving a file the page content should be replaced rather than duplicated.

Additional context
I'm not sure if this is a Parcel bug or something within Solid. It doesn't happen when using Parcel 2.0.0-rc.0. The default behavior of Parcel is to simply reload a page if HMR isn't explicitly called.

@ryansolid
Copy link
Member

This starter doesn't seem to be even using Solid's HMR library Solid Refresh (or any custom one for that matter). I think Parcel's default behavior must be just re-run the JavaScript again without cleaning up after itself? Since this isn't using Solid's method of HMR I'm sort of leaning towards this being a Parcel thing. But maybe that is their intended functionality. You can't really do a reload without them literally reloading the browser page and if they aren't doing that well that's the problem.

@lucaseverett
Copy link
Author

Thank you for the response. The default behavior of Parcel, according to docs and to discussions I found in their old GitHub Issues, is to do a window.location.reload unless module.hot is explicitly called. That was the behavior up until the 2.0.0 release, so there must have been some regression. I'm going to file an issue on the Parcel repo.

@ryansolid
Copy link
Member

@lucaseverett Did this ever go anywhere? Did you create the issue with Parcel?

@lucaseverett
Copy link
Author

I created an issue for it, but there hasn't been any action on it yet.

parcel-bundler/parcel#7171

@ryansolid ryansolid added the downstream issue related tools that would use Solid label Nov 11, 2021
@lxsmnsyc
Copy link
Member

lxsmnsyc commented Dec 7, 2021

Must be an upstream issue. I tested the latest Parcel 2 with solid and solid-refresh@^0.3.0 and there shouldn't be any issues.

@lucaseverett
Copy link
Author

Yes, it's a Parcel bug, and it was caused by a commit made on September 25. There are several open issues that all seem to be related to this bug.

I edited the hmr-runtime.js file and removed return true from the code in the commit referenced above, and that indeed fixed the issue. I don't know enough about how the hmr-runtime works to know what needs to be rewritten. At least the cause is known, though.

parcel-bundler/parcel#7307

@lucaseverett
Copy link
Author

A PR was merged today to fix this issue. I tested the latest nightly and the issue no longer happens.

parcel-bundler/parcel#7514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
downstream issue related tools that would use Solid
Projects
None yet
Development

No branches or pull requests

3 participants