Skip to content

Commit f1d8b96

Browse files
committed
fix: only enable ast reuse for vue 3.4.3+
ref: vitejs/vite-plugin-vue@4a53b6f
1 parent 61410d6 commit f1d8b96

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/core/template.ts

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ export function resolveTemplateCompilerOptions(
191191
return {
192192
...options.template,
193193
id,
194-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
195-
// @ts-ignore TODO remove ignore when dep is updated to 3.4
196-
ast: descriptor.template?.ast,
194+
ast: canReuseAST(options.compiler.version)
195+
? descriptor.template?.ast
196+
: undefined,
197197
filename,
198198
scoped: hasScoped,
199199
slotted: descriptor.slotted,
@@ -213,3 +213,17 @@ export function resolveTemplateCompilerOptions(
213213
},
214214
}
215215
}
216+
217+
/**
218+
* Versions before 3.4.3 have issues when the user has passed additional
219+
* template parse options e.g. `isCustomElement`.
220+
*/
221+
function canReuseAST(version: string | undefined) {
222+
if (version) {
223+
const [, minor, patch] = version.split('.').map(Number)
224+
if (minor >= 4 && patch >= 3) {
225+
return true
226+
}
227+
}
228+
return false
229+
}

0 commit comments

Comments
 (0)