Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ export async function compileFile(
const [clientScript, bindings] = clientScriptResult
clientCode += clientScript

// script ssr only needs to be performed if using <script setup> where
// the render fn is inlined.
if (descriptor.scriptSetup) {
// script ssr needs to be performed if :
// 1.using <script setup> where the render fn is inlined.
// 2.using cssVars, as it do not need to be injected during SSR.
if (descriptor.scriptSetup || descriptor.cssVars.length > 0) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If cssVars is used,clientScript is not the same as ssrScript because we do not inject useCssVars into ssr.

const ssrScriptResult = await doCompileScript(
store,
descriptor,
Expand All @@ -118,7 +119,7 @@ export async function compileFile(
ssrCode = `/* SSR compile error: ${store.state.errors[0]} */`
}
} else {
// when no <script setup> is used, the script result will be identical.
// the script result will be identical.
ssrCode += clientScript
}

Expand Down Expand Up @@ -276,6 +277,7 @@ async function doCompileTemplate(
isTS: boolean
) {
const templateResult = store.compiler.compileTemplate({
isProd: false,
...store.options?.template,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idProd may be defined in store.options?.template

source: descriptor.template!.content,
filename: descriptor.filename,
Expand All @@ -284,7 +286,6 @@ async function doCompileTemplate(
slotted: descriptor.slotted,
ssr,
ssrCssVars: descriptor.cssVars,
isProd: false,
compilerOptions: {
...store.options?.template?.compilerOptions,
bindingMetadata,
Expand Down