Skip to content

fix(hmr): load the correct URL for virtual modules#10313

Closed
Akryum wants to merge 2 commits intovitejs:mainfrom
Akryum:patch-1
Closed

fix(hmr): load the correct URL for virtual modules#10313
Akryum wants to merge 2 commits intovitejs:mainfrom
Akryum:patch-1

Conversation

@Akryum
Copy link
Contributor

@Akryum Akryum commented Oct 2, 2022

Description

Currently the HMR client doesn't understand virtual module and tries to load them as /<moduleId>, but they should be loaded as /@id/__x00__<moduleId>.

image

Actual:
image

Causing HMR errors:
image

Expected:
image

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@patak-cat
Copy link
Member

Thanks for the PR @Akryum, we should go with #10324 so the client only sees URLs in the browser URL space (without \0 and wrapped with /@id/ when needed).

@patak-cat patak-cat closed this Oct 3, 2022
@Akryum Akryum deleted the patch-1 branch October 3, 2022 09:29
@Akryum
Copy link
Contributor Author

Akryum commented Feb 10, 2023

@patak-dev This issue is still present in vite 4.1.0

If I switch to \0 here https://github.com/histoire-dev/histoire/blob/c161d15e2d1fb03e5f865d33a18f82336b9f8e45/packages/histoire/src/node/virtual/index.ts HMR of the virtual files will stop working

@patak-cat
Copy link
Member

Let's reopen the PR to track this. If you find a smaller repro, lets us know @Akryum

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.

2 participants