Skip to content

Commit 3a9d6f7

Browse files
committed
fix(vapor): properly handle return when compiling vapor component for ssr
1 parent 9ff6177 commit 3a9d6f7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/compiler-sfc/src/compileScript.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export function compileScript(
175175
const scriptLang = script && script.lang
176176
const scriptSetupLang = scriptSetup && scriptSetup.lang
177177
const vapor = sfc.vapor || options.vapor
178+
const ssr = options.templateOptions?.ssr
178179

179180
if (!scriptSetup) {
180181
if (!script) {
@@ -749,7 +750,7 @@ export function compileScript(
749750
if (
750751
sfc.cssVars.length &&
751752
// no need to do this when targeting SSR
752-
!options.templateOptions?.ssr
753+
!ssr
753754
) {
754755
ctx.helperImports.add(CSS_VARS_HELPER)
755756
ctx.helperImports.add('unref')
@@ -859,7 +860,7 @@ export function compileScript(
859860
} else {
860861
// inline mode
861862
if (sfc.template && !sfc.template.src) {
862-
if (options.templateOptions && options.templateOptions.ssr) {
863+
if (ssr) {
863864
hasInlinedSsrRenderFn = true
864865
}
865866
// inline render function mode - we are going to compile the template and
@@ -933,7 +934,7 @@ export function compileScript(
933934
ctx.s.appendRight(
934935
endOffset,
935936
// vapor mode generates its own return when inlined
936-
`\n${vapor ? `` : `return `}${returned}\n}\n\n`,
937+
`\n${vapor && !ssr ? `` : `return `}${returned}\n}\n\n`,
937938
)
938939
}
939940

0 commit comments

Comments
 (0)