diff --git a/packages/compiler-core/src/ast.ts b/packages/compiler-core/src/ast.ts index 0ca3e2c9..b2e127c0 100644 --- a/packages/compiler-core/src/ast.ts +++ b/packages/compiler-core/src/ast.ts @@ -50,7 +50,8 @@ export const enum ElementTypes { COMPONENT, SLOT, TEMPLATE, - PORTAL + PORTAL, + SUSPENSE } export interface Node { @@ -101,6 +102,7 @@ export type ElementNode = | SlotOutletNode | TemplateNode | PortalNode + | SuspenseNode export interface BaseElementNode extends Node { type: NodeTypes.ELEMENT @@ -141,6 +143,11 @@ export interface PortalNode extends BaseElementNode { codegenNode: ElementCodegenNode | undefined } +export interface SuspenseNode extends BaseElementNode { + tagType: ElementTypes.SUSPENSE + codegenNode: ElementCodegenNode | undefined +} + export interface TextNode extends Node { type: NodeTypes.TEXT content: string diff --git a/packages/compiler-core/src/parse.ts b/packages/compiler-core/src/parse.ts index 64029818..138fd2c5 100644 --- a/packages/compiler-core/src/parse.ts +++ b/packages/compiler-core/src/parse.ts @@ -445,6 +445,8 @@ function parseTag( if (tag === 'slot') tagType = ElementTypes.SLOT else if (tag === 'template') tagType = ElementTypes.TEMPLATE else if (tag === 'portal' || tag === 'Portal') tagType = ElementTypes.PORTAL + else if (tag === 'suspense' || tag === 'Suspense') + tagType = ElementTypes.SUSPENSE } return { diff --git a/packages/compiler-core/src/transforms/transformElement.ts b/packages/compiler-core/src/transforms/transformElement.ts index 183a1f98..74ef7f55 100644 --- a/packages/compiler-core/src/transforms/transformElement.ts +++ b/packages/compiler-core/src/transforms/transformElement.ts @@ -24,7 +24,8 @@ import { RESOLVE_COMPONENT, MERGE_PROPS, TO_HANDLERS, - PORTAL + PORTAL, + SUSPENSE } from '../runtimeHelpers' import { getInnerRange, isVSlot, toValidAssetId } from '../utils' import { buildSlots } from './vSlot' @@ -36,130 +37,126 @@ const directiveImportMap = new WeakMap() // generate a JavaScript AST for this element's codegen export const transformElement: NodeTransform = (node, context) => { - if (node.type === NodeTypes.ELEMENT) { - if ( - node.tagType === ElementTypes.ELEMENT || - node.tagType === ElementTypes.COMPONENT || - node.tagType === ElementTypes.PORTAL || - //