From 518da447e573b6f6ec5e2b1ca837332e0e230c14 Mon Sep 17 00:00:00 2001 From: OneNail <31649110+OneNail@users.noreply.github.com> Date: Tue, 2 Nov 2021 09:06:54 +0800 Subject: [PATCH] fix(plugin-vue): template src isn't working when script setup (#5418) --- packages/playground/vue/Main.vue | 2 ++ packages/playground/vue/__tests__/vue.spec.ts | 8 ++++++++ .../setup-import-template/SetupImportTemplate.vue | 5 +++++ .../vue/setup-import-template/template.html | 2 ++ packages/plugin-vue/src/main.ts | 11 ++--------- packages/plugin-vue/src/script.ts | 13 ++++++++++++- 6 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 packages/playground/vue/setup-import-template/SetupImportTemplate.vue create mode 100644 packages/playground/vue/setup-import-template/template.html diff --git a/packages/playground/vue/Main.vue b/packages/playground/vue/Main.vue index bf491f9a71e9af..a65c9d7480920e 100644 --- a/packages/playground/vue/Main.vue +++ b/packages/playground/vue/Main.vue @@ -19,6 +19,7 @@ + diff --git a/packages/playground/vue/setup-import-template/template.html b/packages/playground/vue/setup-import-template/template.html new file mode 100644 index 00000000000000..414069f2e9e929 --- /dev/null +++ b/packages/playground/vue/setup-import-template/template.html @@ -0,0 +1,2 @@ +

Setup Import Template

+ diff --git a/packages/plugin-vue/src/main.ts b/packages/plugin-vue/src/main.ts index 9ddb73ea61c078..ef82b3a05551d2 100644 --- a/packages/plugin-vue/src/main.ts +++ b/packages/plugin-vue/src/main.ts @@ -10,7 +10,7 @@ import { } from './utils/descriptorCache' import { PluginContext, SourceMap, TransformPluginContext } from 'rollup' import { normalizePath } from '@rollup/pluginutils' -import { resolveScript } from './script' +import { resolveScript, isUseInlineTemplate } from './script' import { transformTemplateInMain } from './template' import { isOnlyTemplateChanged, isEqualBlock } from './handleHotUpdate' import { RawSourceMap, SourceMapConsumer, SourceMapGenerator } from 'source-map' @@ -53,14 +53,7 @@ export async function transformMain( ) // template - // Check if we can use compile template as inlined render function - // inside