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 update doing nothing #9290

Open
mischnic opened this issue Oct 4, 2023 · 1 comment
Open

HMR update doing nothing #9290

mischnic opened this issue Oct 4, 2023 · 1 comment
Labels
🐛 Bug HMR Hot Module Reloading

Comments

@mischnic
Copy link
Member

mischnic commented Oct 4, 2023

Here's a github repo with a super simple node web app using TypeScript that reproduces the issue:
https://github.com/programmist/parcel-hmr-issue-repro

I created this project by initializing TS and Node projects in a new directory...

mkdir hello-web
cd hello-web
tsc --init
npm init -y

...and then adding an index.html file which references index.ts. The TS file adds text to an empty <h1> element when it is loaded.

To Reproduce the Issue:

(Using Parcel 2.9.3)

  • Clone this repo, cd into the parcel-hmr-issue-repro directory, and run npx parcel index.html
  • Open http://localhost:1234 in your browser
  • You should see a page with an <h1> element containing the text "Hello World"
  • With the Parcel server still running, change title.textContent in index.ts to something different and save the file.

At this point I would have expected to see the text on the page update, but it doesn't. All I see is a "console was cleared" message in the JS console. In order to see an update I must manually refresh the browser page.

Incidentally, I went to the line of code which clears the console and set a breakpoint a few lines earlier in the onmessage handler, just below where the HMRMessage is being parsed. Then I made another update to my index.ts file. When inspecting the data, I can see the TS changes I made in data.assets[0].output.

image

Originally posted by @programmist in #6685 (comment)

@mischnic
Copy link
Member Author

mischnic commented Oct 4, 2023

The problem is that for some reason, the env hashes don't match up in this line

let assets = data.assets.filter(asset => asset.envHash === HMR_ENV_HASH);

causing the updated JS asset to be filtered out and not be applied.

@mischnic mischnic added 🐛 Bug HMR Hot Module Reloading labels Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug HMR Hot Module Reloading
Projects
None yet
Development

No branches or pull requests

1 participant