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(plugin-vue): invalidate script module cache when it changed in hot update #11059

Merged
merged 3 commits into from
Nov 25, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export async function handleHotUpdate(
return m1.url.length - m2.url.length
})[0]
const templateModule = modules.find((m) => /type=template/.test(m.url))

if (hasScriptChanged(prevDescriptor, descriptor)) {
const scriptChanged = hasScriptChanged(prevDescriptor, descriptor)
if (scriptChanged) {
sun0day marked this conversation as resolved.
Show resolved Hide resolved
let scriptModule: ModuleNode | undefined
if (
(descriptor.scriptSetup?.lang && !descriptor.scriptSetup.src) ||
Expand All @@ -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) {
sun0day marked this conversation as resolved.
Show resolved Hide resolved
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

setResolvedScript(
descriptor,
getResolvedScript(prevDescriptor, false)!,
Expand Down