From 1cca9f94e97a8fb84c6397624ea4393aa8190bec Mon Sep 17 00:00:00 2001 From: okxiaoliang4 Date: Sat, 2 Jul 2022 18:22:44 +0800 Subject: [PATCH] fix: `ShapeFlags` is `undefined` see: https://github.com/evanw/esbuild/issues/1253 --- src/utils/getRootNodes.ts | 2 +- src/utils/vueShared.ts | 14 ++++++++++++++ src/vueWrapper.ts | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/utils/getRootNodes.ts b/src/utils/getRootNodes.ts index 551036985..a40f268e5 100644 --- a/src/utils/getRootNodes.ts +++ b/src/utils/getRootNodes.ts @@ -1,6 +1,6 @@ -import { ShapeFlags } from '@vue/shared' import { isNotNullOrUndefined } from '../utils' import { VNode, VNodeArrayChildren } from 'vue' +import { ShapeFlags } from './vueShared' export function getRootNodes(vnode: VNode): Node[] { if (vnode.shapeFlag & ShapeFlags.ELEMENT) { diff --git a/src/utils/vueShared.ts b/src/utils/vueShared.ts index 2214494b5..37f8900e5 100644 --- a/src/utils/vueShared.ts +++ b/src/utils/vueShared.ts @@ -19,3 +19,17 @@ const hyphenateRE = /\B([A-Z])/g export const hyphenate = cacheStringFunction((str: string): string => { return str.replace(hyphenateRE, '-$1').toLowerCase() }) + +export const enum ShapeFlags { + ELEMENT = 1, + FUNCTIONAL_COMPONENT = 2, + STATEFUL_COMPONENT = 4, + TEXT_CHILDREN = 8, + ARRAY_CHILDREN = 16, + SLOTS_CHILDREN = 32, + TELEPORT = 64, + SUSPENSE = 128, + COMPONENT_SHOULD_KEEP_ALIVE = 256, + COMPONENT_KEPT_ALIVE = 512, + COMPONENT = 6 +} diff --git a/src/vueWrapper.ts b/src/vueWrapper.ts index 6cc96473c..22a753a7f 100644 --- a/src/vueWrapper.ts +++ b/src/vueWrapper.ts @@ -4,7 +4,6 @@ import { ComponentCustomProperties, ComponentPublicInstance } from 'vue' -import { ShapeFlags } from '@vue/shared' // @ts-ignore todo - No DefinitelyTyped package exists for this import pretty from 'pretty' @@ -22,6 +21,7 @@ import { WrapperType } from './wrapperFactory' import { VNode } from '@vue/runtime-core' +import { ShapeFlags } from './utils/vueShared' export class VueWrapper< T extends Omit<