wip: avoid including vdom-only public properties map in bundle

This commit is contained in:
Evan You 2024-12-06 23:06:11 +08:00
parent 68aa9bd768
commit db3151b1a5
No known key found for this signature in database
GPG Key ID: 00E9AB7A6704CE0A
3 changed files with 11 additions and 4 deletions

View File

@ -4,7 +4,6 @@ import {
type Data,
type GenericComponent,
type GenericComponentInstance,
getComponentPublicInstance,
validateComponentName,
} from './component'
import type {
@ -280,6 +279,7 @@ export function createAppAPI<HostElement, Comp = Component>(
// hydrate?: RootHydrateFunction,
mount: AppMountFn<HostElement>,
unmount: AppUnmountFn,
getPublicInstance: (instance: GenericComponentInstance) => any,
render?: RootRenderFunction,
): CreateAppFunction<HostElement, Comp> {
return function createApp(rootComponent, rootProps = null) {
@ -409,7 +409,7 @@ export function createAppAPI<HostElement, Comp = Component>(
// for devtools and telemetry
rootContainer.__vue_app__ = app
return getComponentPublicInstance(instance)
return getPublicInstance(instance)
} else if (__DEV__) {
warn(
`App has already been mounted.\n` +

View File

@ -20,6 +20,7 @@ import {
type Data,
type LifecycleHook,
createComponentInstance,
getComponentPublicInstance,
setupComponent,
} from './component'
import {
@ -2445,7 +2446,12 @@ function baseCreateRenderer(
return {
render,
hydrate,
createApp: createAppAPI(mountApp, unmountApp, render),
createApp: createAppAPI(
mountApp,
unmountApp,
getComponentPublicInstance,
render,
),
}
}

View File

@ -29,7 +29,8 @@ export const createVaporApp: CreateAppFunction<
ParentNode,
VaporComponent
> = comp => {
if (!_createApp) _createApp = createAppAPI(mountApp, unmountApp)
if (!_createApp)
_createApp = createAppAPI(mountApp, unmountApp, i => i.exposed)
const app = _createApp(comp)
const mount = app.mount
app.mount = (container, ...args: any[]) => {