chore(sfc-playground): handle ssr-only compile errors

This commit is contained in:
Evan You 2021-06-28 17:34:52 -04:00
parent 62c1b2f7dc
commit 0245c98640

View File

@ -97,10 +97,11 @@ export async function compileFile({ filename, code, compiled }: File) {
// the render fn is inlined. // the render fn is inlined.
if (descriptor.scriptSetup) { if (descriptor.scriptSetup) {
const ssrScriptResult = await doCompileScript(descriptor, id, true) const ssrScriptResult = await doCompileScript(descriptor, id, true)
if (!ssrScriptResult) { if (ssrScriptResult) {
return ssrCode += ssrScriptResult[0]
} else {
ssrCode = `/* SSR compile error: ${store.errors[0]} */`
} }
ssrCode += ssrScriptResult[0]
} else { } else {
// when no <script setup> is used, the script result will be identical. // when no <script setup> is used, the script result will be identical.
ssrCode += clientScript ssrCode += clientScript
@ -121,10 +122,12 @@ export async function compileFile({ filename, code, compiled }: File) {
clientCode += clientTemplateResult clientCode += clientTemplateResult
const ssrTemplateResult = doCompileTemplate(descriptor, id, bindings, true) const ssrTemplateResult = doCompileTemplate(descriptor, id, bindings, true)
if (!ssrTemplateResult) { if (ssrTemplateResult) {
return // ssr compile failure is fine
ssrCode += ssrTemplateResult
} else {
ssrCode = `/* SSR compile error: ${store.errors[0]} */`
} }
ssrCode += ssrTemplateResult
} }
if (hasScoped) { if (hasScoped) {