@@ -4,17 +4,15 @@ import { Options } from '.'
44import { getTemplateCompilerOptions } from './template'
55import { createRollupError } from './utils/error'
66
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 > ( )
1110
1211export function getResolvedScript (
1312 descriptor : SFCDescriptor ,
14- enableInline : boolean
13+ isServer : boolean
1514) : SFCScriptBlock | null | undefined {
16- const cacheToUse = enableInline ? inlinedCache : normalCache
17- return cacheToUse . get ( descriptor )
15+ return ( isServer ? serverCache : clientCache ) . get ( descriptor )
1816}
1917
2018export function resolveScript (
@@ -29,8 +27,7 @@ export function resolveScript(
2927 return null
3028 }
3129
32- const enableInline = ! isServer
33- const cacheToUse = enableInline ? inlinedCache : normalCache
30+ const cacheToUse = isServer ? serverCache : clientCache
3431 const cached = cacheToUse . get ( descriptor )
3532 if ( cached ) {
3633 return cached
@@ -41,12 +38,14 @@ export function resolveScript(
4138 if ( compileScript ) {
4239 try {
4340 resolved = compileScript ( descriptor , {
44- scopeId,
41+ id : scopeId ,
4542 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+ ) ,
5049 } )
5150 } catch ( e ) {
5251 pluginContext . error ( createRollupError ( descriptor . filename , e ) )
0 commit comments