From: Evan You Date: Tue, 11 Mar 2025 11:05:46 +0000 (+0800) Subject: fix(vapor): properly handle return when compiling vapor component for ssr X-Git-Tag: v3.6.0-alpha.1~16^2~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a9d6f781cd13b42181ab64d7261c8c083da435a;p=thirdparty%2Fvuejs%2Fcore.git fix(vapor): properly handle return when compiling vapor component for ssr --- diff --git a/packages/compiler-sfc/src/compileScript.ts b/packages/compiler-sfc/src/compileScript.ts index 15219ec092..7fbb0b115c 100644 --- a/packages/compiler-sfc/src/compileScript.ts +++ b/packages/compiler-sfc/src/compileScript.ts @@ -175,6 +175,7 @@ export function compileScript( const scriptLang = script && script.lang const scriptSetupLang = scriptSetup && scriptSetup.lang const vapor = sfc.vapor || options.vapor + const ssr = options.templateOptions?.ssr if (!scriptSetup) { if (!script) { @@ -749,7 +750,7 @@ export function compileScript( if ( sfc.cssVars.length && // no need to do this when targeting SSR - !options.templateOptions?.ssr + !ssr ) { ctx.helperImports.add(CSS_VARS_HELPER) ctx.helperImports.add('unref') @@ -859,7 +860,7 @@ export function compileScript( } else { // inline mode if (sfc.template && !sfc.template.src) { - if (options.templateOptions && options.templateOptions.ssr) { + if (ssr) { hasInlinedSsrRenderFn = true } // inline render function mode - we are going to compile the template and @@ -933,7 +934,7 @@ export function compileScript( ctx.s.appendRight( endOffset, // vapor mode generates its own return when inlined - `\n${vapor ? `` : `return `}${returned}\n}\n\n`, + `\n${vapor && !ssr ? `` : `return `}${returned}\n}\n\n`, ) }