Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(runtime-vapor): support functional component for defineVaporComponent #12927

Open
wants to merge 2 commits into
base: vapor
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions packages/runtime-vapor/src/apiDefineComponent.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
import type { VaporComponent } from './component'
import type { ObjectVaporComponent, VaporComponent } from './component'
import { extend, isFunction } from '@vue/shared'

/*! #__NO_SIDE_EFFECTS__ */
export function defineVaporComponent(comp: VaporComponent): VaporComponent {
export function defineVaporComponent(
comp: VaporComponent,
extraOptions?: Omit<ObjectVaporComponent, 'setup'>,
): VaporComponent {
if (isFunction(comp)) {
// #8236: extend call and options.name access are considered side-effects
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
return /*@__PURE__*/ (() =>
extend({ name: comp.name }, extraOptions, {
setup: comp,
__vapor: true,
}))()
}
// TODO type inference
comp.__vapor = true
return comp
Expand Down