Skip to content

Commit

Permalink
fix: invalidate script module cache when it changed in hot update (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
sun0day committed Nov 29, 2022
1 parent eaa7886 commit b8e6133
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/handleHotUpdate.ts
Expand Up @@ -35,7 +35,8 @@ export async function handleHotUpdate(
)
const templateModule = modules.find((m) => /type=template/.test(m.url))

if (hasScriptChanged(prevDescriptor, descriptor)) {
const scriptChanged = hasScriptChanged(prevDescriptor, descriptor)
if (scriptChanged) {
let scriptModule: ModuleNode | undefined
if (
(descriptor.scriptSetup?.lang && !descriptor.scriptSetup.src) ||
Expand All @@ -56,7 +57,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 (!scriptChanged) {
setResolvedScript(
descriptor,
getResolvedScript(prevDescriptor, false)!,
Expand Down

0 comments on commit b8e6133

Please sign in to comment.