File tree 2 files changed +14
-10
lines changed
2 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
10
10
} from './utils/descriptorCache'
11
11
import { PluginContext , SourceMap , TransformPluginContext } from 'rollup'
12
12
import { normalizePath } from '@rollup/pluginutils'
13
- import { resolveScript } from './script'
13
+ import { resolveScript , isUseInlineTemplate } from './script'
14
14
import { transformTemplateInMain } from './template'
15
15
import { isOnlyTemplateChanged , isEqualBlock } from './handleHotUpdate'
16
16
import { RawSourceMap , SourceMapConsumer , SourceMapGenerator } from 'source-map'
@@ -53,14 +53,7 @@ export async function transformMain(
53
53
)
54
54
55
55
// template
56
- // Check if we can use compile template as inlined render function
57
- // inside <script setup>. This can only be done for build because
58
- // inlined template cannot be individually hot updated.
59
- const useInlineTemplate =
60
- ! devServer &&
61
- descriptor . scriptSetup &&
62
- ! ( descriptor . template && descriptor . template . src )
63
- const hasTemplateImport = descriptor . template && ! useInlineTemplate
56
+ const hasTemplateImport = descriptor . template && ! isUseInlineTemplate ( descriptor , ! devServer )
64
57
65
58
let templateCode = ''
66
59
let templateMap : RawSourceMap | undefined
Original file line number Diff line number Diff line change @@ -22,6 +22,17 @@ export function setResolvedScript(
22
22
; ( ssr ? ssrCache : clientCache ) . set ( descriptor , script )
23
23
}
24
24
25
+ // Check if we can use compile template as inlined render function
26
+ // inside <script setup>. This can only be done for build because
27
+ // inlined template cannot be individually hot updated.
28
+ export function isUseInlineTemplate ( descriptor : SFCDescriptor , isProd : boolean ) : boolean {
29
+ return (
30
+ isProd &&
31
+ ! ! descriptor . scriptSetup &&
32
+ ! descriptor . template ?. src
33
+ )
34
+ }
35
+
25
36
export function resolveScript (
26
37
descriptor : SFCDescriptor ,
27
38
options : ResolvedOptions ,
@@ -43,7 +54,7 @@ export function resolveScript(
43
54
...options . script ,
44
55
id : descriptor . id ,
45
56
isProd : options . isProduction ,
46
- inlineTemplate : ! options . devServer ,
57
+ inlineTemplate : isUseInlineTemplate ( descriptor , ! options . devServer ) ,
47
58
refTransform : options . refTransform !== false ,
48
59
templateOptions : resolveTemplateCompilerOptions ( descriptor , options , ssr ) ,
49
60
// @ts -ignore TODO remove ignore when we support this in @vue/compiler-sfc
You can’t perform that action at this time.
0 commit comments