wip: suspense feature flag
This commit is contained in:
parent
7e70acf9c2
commit
d5e9682040
@ -4,7 +4,8 @@ module.exports = {
|
|||||||
__DEV__: true,
|
__DEV__: true,
|
||||||
__JSDOM__: true,
|
__JSDOM__: true,
|
||||||
__FEATURE_OPTIONS__: true,
|
__FEATURE_OPTIONS__: true,
|
||||||
__FEATURE_PRODUCTION_TIP__: false
|
__FEATURE_PRODUCTION_TIP__: false,
|
||||||
|
__FEATURE_SUSPENSE__: true
|
||||||
},
|
},
|
||||||
coverageDirectory: 'coverage',
|
coverageDirectory: 'coverage',
|
||||||
coverageReporters: ['html', 'lcov', 'text'],
|
coverageReporters: ['html', 'lcov', 'text'],
|
||||||
|
1
packages/global.d.ts
vendored
1
packages/global.d.ts
vendored
@ -5,3 +5,4 @@ declare var __JSDOM__: boolean
|
|||||||
// Feature flags
|
// Feature flags
|
||||||
declare var __FEATURE_OPTIONS__: boolean
|
declare var __FEATURE_OPTIONS__: boolean
|
||||||
declare var __FEATURE_PRODUCTION_TIP__: boolean
|
declare var __FEATURE_PRODUCTION_TIP__: boolean
|
||||||
|
declare var __FEATURE_SUSPENSE__: boolean
|
||||||
|
@ -242,9 +242,16 @@ export function setupStatefulComponent(instance: ComponentInternalInstance) {
|
|||||||
isFunction(setupResult.then) &&
|
isFunction(setupResult.then) &&
|
||||||
isFunction(setupResult.catch)
|
isFunction(setupResult.catch)
|
||||||
) {
|
) {
|
||||||
// async setup returned Promise.
|
if (__FEATURE_SUSPENSE__) {
|
||||||
// bail here and wait for re-entry.
|
// async setup returned Promise.
|
||||||
instance.asyncDep = setupResult as Promise<any>
|
// bail here and wait for re-entry.
|
||||||
|
instance.asyncDep = setupResult as Promise<any>
|
||||||
|
} else if (__DEV__) {
|
||||||
|
warn(
|
||||||
|
`setup() returned a Promise, but the version of Vue you are using ` +
|
||||||
|
`does not support it yet.`
|
||||||
|
)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
handleSetupResult(instance, setupResult)
|
handleSetupResult(instance, setupResult)
|
||||||
|
@ -194,15 +194,19 @@ export function createRenderer<
|
|||||||
)
|
)
|
||||||
break
|
break
|
||||||
case Suspense:
|
case Suspense:
|
||||||
processSuspense(
|
if (__FEATURE_SUSPENSE__) {
|
||||||
n1,
|
processSuspense(
|
||||||
n2,
|
n1,
|
||||||
container,
|
n2,
|
||||||
anchor,
|
container,
|
||||||
parentComponent,
|
anchor,
|
||||||
isSVG,
|
parentComponent,
|
||||||
optimized
|
isSVG,
|
||||||
)
|
optimized
|
||||||
|
)
|
||||||
|
} else if (__DEV__) {
|
||||||
|
warn(`Suspense is not enabled in the version of Vue you are using.`)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
if (shapeFlag & ShapeFlags.ELEMENT) {
|
if (shapeFlag & ShapeFlags.ELEMENT) {
|
||||||
@ -730,10 +734,16 @@ export function createRenderer<
|
|||||||
} else {
|
} else {
|
||||||
const instance = (n2.component =
|
const instance = (n2.component =
|
||||||
n1.component) as ComponentInternalInstance
|
n1.component) as ComponentInternalInstance
|
||||||
|
|
||||||
// async still pending
|
// async still pending
|
||||||
if (instance.asyncDep && !instance.asyncResolved) {
|
if (
|
||||||
|
__FEATURE_SUSPENSE__ &&
|
||||||
|
instance.asyncDep &&
|
||||||
|
!instance.asyncResolved
|
||||||
|
) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// a resolved async component, on successful re-entry.
|
// a resolved async component, on successful re-entry.
|
||||||
// pickup the mounting process and setup render effect
|
// pickup the mounting process and setup render effect
|
||||||
if (!instance.update) {
|
if (!instance.update) {
|
||||||
@ -741,7 +751,8 @@ export function createRenderer<
|
|||||||
} else if (
|
} else if (
|
||||||
shouldUpdateComponent(n1, n2, optimized) ||
|
shouldUpdateComponent(n1, n2, optimized) ||
|
||||||
// TODO use context suspense
|
// TODO use context suspense
|
||||||
(instance.provides.suspense &&
|
(__FEATURE_SUSPENSE__ &&
|
||||||
|
instance.provides.suspense &&
|
||||||
!(instance.provides.suspense as any).isResolved)
|
!(instance.provides.suspense as any).isResolved)
|
||||||
) {
|
) {
|
||||||
// normal update
|
// normal update
|
||||||
@ -791,7 +802,7 @@ export function createRenderer<
|
|||||||
|
|
||||||
// setup() is async. This component relies on async logic to be resolved
|
// setup() is async. This component relies on async logic to be resolved
|
||||||
// before proceeding
|
// before proceeding
|
||||||
if (instance.asyncDep) {
|
if (__FEATURE_SUSPENSE__ && instance.asyncDep) {
|
||||||
// TODO use context suspense
|
// TODO use context suspense
|
||||||
const suspense = (instance as any).provides.suspense
|
const suspense = (instance as any).provides.suspense
|
||||||
if (!suspense) {
|
if (!suspense) {
|
||||||
|
@ -140,6 +140,7 @@ function createReplacePlugin(isProduction, isBunlderESMBuild, isBrowserBuild) {
|
|||||||
// support options?
|
// support options?
|
||||||
// the lean build drops options related code with buildOptions.lean: true
|
// the lean build drops options related code with buildOptions.lean: true
|
||||||
__FEATURE_OPTIONS__: !packageOptions.lean,
|
__FEATURE_OPTIONS__: !packageOptions.lean,
|
||||||
|
__FEATURE_SUSPENSE__: true,
|
||||||
// this is only used during tests
|
// this is only used during tests
|
||||||
__JSDOM__: false
|
__JSDOM__: false
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user