@@ -269,19 +269,26 @@ export function validateComponentName(name: string, config: AppConfig) {
269
269
}
270
270
}
271
271
272
+ export let isInSSRComponentSetup = false
273
+
272
274
export function setupComponent (
273
275
instance : ComponentInternalInstance ,
274
- parentSuspense : SuspenseBoundary | null
276
+ parentSuspense : SuspenseBoundary | null ,
277
+ isSSR = false
275
278
) {
279
+ isInSSRComponentSetup = isSSR
276
280
const propsOptions = instance . type . props
277
281
const { props, children, shapeFlag } = instance . vnode
278
282
resolveProps ( instance , props , propsOptions )
279
283
resolveSlots ( instance , children )
280
284
281
285
// setup stateful logic
286
+ let setupResult
282
287
if ( shapeFlag & ShapeFlags . STATEFUL_COMPONENT ) {
283
- return setupStatefulComponent ( instance , parentSuspense )
288
+ setupResult = setupStatefulComponent ( instance , parentSuspense )
284
289
}
290
+ isInSSRComponentSetup = false
291
+ return setupResult
285
292
}
286
293
287
294
function setupStatefulComponent (
@@ -314,7 +321,7 @@ function setupStatefulComponent(
314
321
// 2. create props proxy
315
322
// the propsProxy is a reactive AND readonly proxy to the actual props.
316
323
// it will be updated in resolveProps() on updates before render
317
- const propsProxy = ( instance . propsProxy = __SSR__
324
+ const propsProxy = ( instance . propsProxy = isInSSRComponentSetup
318
325
? instance . props
319
326
: shallowReadonly ( instance . props ) )
320
327
// 3. call setup()
@@ -335,7 +342,7 @@ function setupStatefulComponent(
335
342
currentSuspense = null
336
343
337
344
if ( isPromise ( setupResult ) ) {
338
- if ( __SSR__ ) {
345
+ if ( isInSSRComponentSetup ) {
339
346
// return the promise so server-renderer can wait on it
340
347
return setupResult . then ( resolvedResult => {
341
348
handleSetupResult ( instance , resolvedResult , parentSuspense )
@@ -413,15 +420,15 @@ function finishComponentSetup(
413
420
; ( Component . render as RenderFunction ) . isRuntimeCompiled = true
414
421
}
415
422
416
- if ( __DEV__ && ! Component . render ) {
423
+ if ( __DEV__ && ! Component . render && ! Component . ssrRender ) {
417
424
/* istanbul ignore if */
418
425
if ( ! __RUNTIME_COMPILE__ && Component . template ) {
419
426
warn (
420
427
`Component provides template but the build of Vue you are running ` +
421
428
`does not support runtime template compilation. Either use the ` +
422
429
`full build or pre-compile the template using Vue CLI.`
423
430
)
424
- } else if ( ! __SSR__ || ! Component . ssrRender ) {
431
+ } else {
425
432
warn (
426
433
`Component is missing${
427
434
__RUNTIME_COMPILE__ ? ` template or` : ``
0 commit comments