chore(sfc-playground): handle ssr-only compile errors
This commit is contained in:
parent
62c1b2f7dc
commit
0245c98640
@ -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]
|
ssrCode += ssrScriptResult[0]
|
||||||
|
} else {
|
||||||
|
ssrCode = `/* SSR compile error: ${store.errors[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
|
ssrCode += ssrTemplateResult
|
||||||
|
} else {
|
||||||
|
ssrCode = `/* SSR compile error: ${store.errors[0]} */`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasScoped) {
|
if (hasScoped) {
|
||||||
|
Loading…
Reference in New Issue
Block a user