Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(plugin-vue): invalidate script module cache when it changed in hot update #11059

Merged
merged 3 commits into from
Nov 25, 2022

Conversation

sun0day
Copy link
Member

@sun0day sun0day commented Nov 24, 2022

Description

fixes #11008

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.

@sun0day
Copy link
Member Author

sun0day commented Nov 25, 2022

@sapphi-red cc

Copy link
Member

@sapphi-red sapphi-red left a comment

Choose a reason for hiding this comment

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

Thanks! I think the code makes sense.
Would you add a test for this?

@@ -66,7 +66,7 @@ export async function handleHotUpdate(
// binding metadata. However, when reloading the template alone the binding
// metadata will not be available since the script part isn't loaded.
// in this case, reuse the compiled script from previous descriptor.
if (mainModule && !affectedModules.has(mainModule)) {
if (mainModule && !scriptChanged) {
Copy link
Member

Choose a reason for hiding this comment

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

For reviewers: In the past, this part was like:

  const scriptChanged = hasScriptChanged(prevDescriptor, descriptor)
  if (scriptChanged) {
    affectedModules.add(mainModule)
  }
  if (!isEqualBlock(descriptor.template, prevDescriptor.template)) {
    if (!scriptChanged) {

7883fb2#diff-9fd57831c2dc5be7b6feb11f8f80bfeca59da8226fac808425dd5460fce7e380R51-R65

@sapphi-red sapphi-red added feat: hmr plugin: vue p3-minor-bug An edge case that only affects very specific usage (priority) labels Nov 25, 2022
@sun0day
Copy link
Member Author

sun0day commented Nov 25, 2022

Thanks! I think the code makes sense. Would you add a test for this?

Done

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feat: hmr p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vue2 tsx (class component) hmr exception
3 participants