Skip to content

Commit

Permalink
fix: only enable ast reuse for vue 3.4.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 30, 2023
1 parent d94a704 commit 4a53b6f
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/plugin-vue/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,9 @@ export function resolveTemplateCompilerOptions(
return {
...options.template,
id,
ast: descriptor.template?.ast,
ast: canReuseAST(options.compiler.version)
? descriptor.template?.ast
: undefined,
filename,
scoped: hasScoped,
slotted: descriptor.slotted,
Expand All @@ -206,3 +208,17 @@ export function resolveTemplateCompilerOptions(
},
}
}

/**
* Versions before 3.4.3 have issues when the user has passed additional
* tempalte parse options e.g. `isCustomElement`.
*/
function canReuseAST(version: string | undefined) {
if (version) {
const [_, minor, patch] = version.split('.').map(Number)
if (minor >= 4 && patch >= 3) {
return true
}
}
return false
}

0 comments on commit 4a53b6f

Please sign in to comment.