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

fix(hmr): duplicated modules because of query params mismatch (fixes #2255) #9773

Merged
merged 6 commits into from Sep 1, 2022

Conversation

sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Aug 21, 2022

Description

This PR fixes #2255 by only appending ?import when it should be.
I passed explicitImportRequired property to do the check on server side, not to duplicate isExplicitImportRequired function to client/client.ts.

fixes #2255

Additional context

?import is used to differentiate import './foo.png' and fetch('./foo.png'). The ideal way is to use Accept header but unfortunately requests by import uses Accept: */* and cannot be used.


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.

@sapphi-red sapphi-red added feat: hmr p4-important Violate documented behavior or significantly improves performance (priority) labels Aug 21, 2022
bluwy
bluwy previously approved these changes Aug 23, 2022
@@ -431,7 +436,9 @@ async function fetchUpdate({ path, acceptedPath, timestamp }: Update) {
/* @vite-ignore */
base +
path.slice(1) +
`?import&t=${timestamp}${query ? `&${query}` : ''}`
`?${explicitImportRequired ? 'import&' : ''}t=${timestamp}${
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed this is not correct.
dep is always acceptedPath, not path.

@sapphi-red sapphi-red marked this pull request as ready for review September 1, 2022 05:17
@sapphi-red
Copy link
Member Author

I considered about including ?import in path property, but I didn't reach a conclusion.
One thing I can say is that introducing explicitImportRequired property has less implication to existing implementations than including ?import in path property.

@patak-dev
Copy link
Member

@sapphi-red lets mark the new field as @internal or @experimental so we can merge this fix in 3.1, and we can discuss later with more time in team meeting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: hmr p4-important Violate documented behavior or significantly improves performance (priority)
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

HMR duplicated modules because of query params mismatch
3 participants