@@ -4,17 +4,15 @@ import { Options } from '.'
4
4
import { getTemplateCompilerOptions } from './template'
5
5
import { createRollupError } from './utils/error'
6
6
7
- // since we generate different output based on whether the template is inlined
8
- // or not, we need to cache the results separately
9
- const inlinedCache = new WeakMap < SFCDescriptor , SFCScriptBlock | null > ( )
10
- const normalCache = new WeakMap < SFCDescriptor , SFCScriptBlock | null > ( )
7
+ // ssr and non ssr builds would output different script content
8
+ const clientCache = new WeakMap < SFCDescriptor , SFCScriptBlock | null > ( )
9
+ const serverCache = new WeakMap < SFCDescriptor , SFCScriptBlock | null > ( )
11
10
12
11
export function getResolvedScript (
13
12
descriptor : SFCDescriptor ,
14
- enableInline : boolean
13
+ isServer : boolean
15
14
) : SFCScriptBlock | null | undefined {
16
- const cacheToUse = enableInline ? inlinedCache : normalCache
17
- return cacheToUse . get ( descriptor )
15
+ return ( isServer ? serverCache : clientCache ) . get ( descriptor )
18
16
}
19
17
20
18
export function resolveScript (
@@ -29,8 +27,7 @@ export function resolveScript(
29
27
return null
30
28
}
31
29
32
- const enableInline = ! isServer
33
- const cacheToUse = enableInline ? inlinedCache : normalCache
30
+ const cacheToUse = isServer ? serverCache : clientCache
34
31
const cached = cacheToUse . get ( descriptor )
35
32
if ( cached ) {
36
33
return cached
@@ -41,12 +38,14 @@ export function resolveScript(
41
38
if ( compileScript ) {
42
39
try {
43
40
resolved = compileScript ( descriptor , {
44
- scopeId,
41
+ id : scopeId ,
45
42
isProd,
46
- inlineTemplate : enableInline ,
47
- templateOptions : enableInline
48
- ? getTemplateCompilerOptions ( options , descriptor , scopeId )
49
- : undefined ,
43
+ inlineTemplate : true ,
44
+ templateOptions : getTemplateCompilerOptions (
45
+ options ,
46
+ descriptor ,
47
+ scopeId
48
+ ) ,
50
49
} )
51
50
} catch ( e ) {
52
51
pluginContext . error ( createRollupError ( descriptor . filename , e ) )
0 commit comments