Skip to content

Commit

Permalink
chore(sfc-playground): handle ssr-only compile errors
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 28, 2021
1 parent 62c1b2f commit 0245c98
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/sfc-playground/src/sfcCompiler.ts
Expand Up @@ -97,10 +97,11 @@ export async function compileFile({ filename, code, compiled }: File) {
// the render fn is inlined.
if (descriptor.scriptSetup) {
const ssrScriptResult = await doCompileScript(descriptor, id, true)
if (!ssrScriptResult) {
return
if (ssrScriptResult) {
ssrCode += ssrScriptResult[0]
} else {
ssrCode = `/* SSR compile error: ${store.errors[0]} */`
}
ssrCode += ssrScriptResult[0]
} else {
// when no <script setup> is used, the script result will be identical.
ssrCode += clientScript
Expand All @@ -121,10 +122,12 @@ export async function compileFile({ filename, code, compiled }: File) {
clientCode += clientTemplateResult

const ssrTemplateResult = doCompileTemplate(descriptor, id, bindings, true)
if (!ssrTemplateResult) {
return
if (ssrTemplateResult) {
// ssr compile failure is fine
ssrCode += ssrTemplateResult
} else {
ssrCode = `/* SSR compile error: ${store.errors[0]} */`
}
ssrCode += ssrTemplateResult
}

if (hasScoped) {
Expand Down

0 comments on commit 0245c98

Please sign in to comment.