Skip to content
Open
Show file tree
Hide file tree
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
16 changes: 15 additions & 1 deletion src/parser/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { camelCase } from "scule"
import type { ComponentMeta } from 'vue-component-meta'
import type { ModuleOptions } from '../types/module'

export function refineMeta(meta: ComponentMeta, fields: Record<string, boolean> = { type: true, props: true, slots: true, events: true, exposed: true }): ComponentMeta {
export function refineMeta(meta: ComponentMeta, fields: ModuleOptions['metaFields'] = { type: true, props: true, slots: true, events: true, exposed: true }): ComponentMeta {
const eventProps = new Set<string>(meta.events.map((event :any) => camelCase(`on_${event.name}`)))
const props = (fields.props ? meta.props : [])
.filter((prop: any) => !prop.global && !eventProps.has(prop.name as string))
Expand Down Expand Up @@ -35,6 +36,19 @@ export function refineMeta(meta: ComponentMeta, fields: Record<string, boolean>
// Remove descriptional fileds to reduce chunk size
removeFields(refinedMeta, ['declarations'])

if (fields.slots === 'no-schema') {
removeFields(refinedMeta.slots, ['schema'])
}
if (fields.events === 'no-schema') {
removeFields(refinedMeta.events, ['schema'])
}
if (fields.exposed === 'no-schema') {
removeFields(refinedMeta.exposed, ['schema'])
}
if (fields.props === 'no-schema') {
removeFields(refinedMeta.props, ['schema'])
}

return refinedMeta
}

Expand Down
8 changes: 4 additions & 4 deletions src/types/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ export interface ModuleOptions {
*/
metaFields: {
type: boolean,
props: boolean,
slots: boolean,
events: boolean,
exposed: boolean
props: boolean | 'no-schema',
slots: boolean | 'no-schema',
events: boolean | 'no-schema',
exposed: boolean | 'no-schema'
},
/**
* Allow to load external components definitions.
Expand Down
Loading