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 triggers full reload unnecessarily in vite@2.6.0-beta.2 #5063

Closed
7 tasks done
fwouts opened this issue Sep 24, 2021 · 0 comments
Closed
7 tasks done

HMR triggers full reload unnecessarily in vite@2.6.0-beta.2 #5063

fwouts opened this issue Sep 24, 2021 · 0 comments
Labels
pending triage regression The issue only appears after a new release

Comments

@fwouts
Copy link
Contributor

fwouts commented Sep 24, 2021

Describe the bug

#5037 introduced a regression where, in very specific circumstances, the page is fully reloaded instead of a specific module being refreshed.

Using Vite 2.6.0-beta.0 (correct behaviour)

Screen.Recording.2021-09-24.at.12.51.12.pm.mov

Using Vite 2.6.0-beta.2 (incorrect behaviour)

Screen.Recording.2021-09-24.at.12.51.56.pm.mov

Reproduction

I tried very hard to reproduce this in a simple app, but I wasn't able to. It seems to be a particular pattern that React Preview exhibits, potentially because of its heavy usage of virtual files. Also, it uses a /preview/ prefix in its Vite configuration.

To reproduce:

"resolutions": {
    "vite": "2.6.0-beta.2"
  }
  • Install deps
  • Run yarn reactpreview -v and open http://localhost:8120/?p=src/screens/pick-restaurant/PickRestaurant.tsx:PickRestaurant then update SearchBar.tsx as shown in the video. Notice the full reload.

Potential cause

I noticed that #5037 removed some url.replace(base, '/') calls. I'm not sure what they were for, but reverting just these two lines seems to fix everything. I'll send a PR and we can discuss there?

System Info

System:
    OS: macOS 11.5.2
    CPU: (8) arm64 Apple M1
    Memory: 215.19 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.9.1 - ~/.nvm/versions/node/v16.9.1/bin/node
    Yarn: 1.22.11 - /usr/local/bin/yarn
    npm: 7.21.1 - ~/.nvm/versions/node/v16.9.1/bin/npm
  Browsers:
    Chrome: 93.0.4577.82
    Firefox: 92.0
    Safari: 14.1.2
  npmPackages:
    vite: 2.6.0-beta.2 => 2.6.0-beta.2

Used Package Manager

yarn

Logs

No response

Validations

@haoqunjiang haoqunjiang added the regression The issue only appears after a new release label Sep 24, 2021
fwouts added a commit to fwouts/vite that referenced this issue Sep 24, 2021
This fixes hot-reloading issues reported in vitejs#5063.
patak-dev pushed a commit that referenced this issue Sep 24, 2021
* fix: normalize away `base` in imported URLs

This fixes hot-reloading issues reported in #5063.

* Update importAnalysis.ts

Co-authored-by: Evan You <yyx990803@gmail.com>
@y1d7ng y1d7ng closed this as completed Sep 26, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pending triage regression The issue only appears after a new release
Projects
None yet
Development

No branches or pull requests

3 participants