From 36351fafb69020ec18301bd7ae3cd3f15c422f31 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 30 Dec 2023 20:04:28 +0800 Subject: [PATCH] fix: ensure consistent user template options when reusing AST Note: requires vue 3.4.1 proper fix for #322 --- packages/plugin-vue/src/template.ts | 1 + packages/plugin-vue/src/utils/descriptorCache.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue/src/template.ts b/packages/plugin-vue/src/template.ts index aee99a74..b2c00f69 100644 --- a/packages/plugin-vue/src/template.ts +++ b/packages/plugin-vue/src/template.ts @@ -186,6 +186,7 @@ export function resolveTemplateCompilerOptions( return { ...options.template, id, + ast: descriptor.template?.ast, filename, scoped: hasScoped, slotted: descriptor.slotted, diff --git a/packages/plugin-vue/src/utils/descriptorCache.ts b/packages/plugin-vue/src/utils/descriptorCache.ts index 584adb39..8637430b 100644 --- a/packages/plugin-vue/src/utils/descriptorCache.ts +++ b/packages/plugin-vue/src/utils/descriptorCache.ts @@ -22,12 +22,13 @@ const prevCache = new Map() export function createDescriptor( filename: string, source: string, - { root, isProduction, sourceMap, compiler }: ResolvedOptions, + { root, isProduction, sourceMap, compiler, template }: ResolvedOptions, hmr = false, ): SFCParseResult { const { descriptor, errors } = compiler.parse(source, { filename, sourceMap, + templateParseOptions: template?.compilerOptions, }) // ensure the path is normalized in a way that is consistent inside