From 1ad6fe5d3bd9de61a71d5fba367156cfe3473f80 Mon Sep 17 00:00:00 2001 From: Farnabaz Date: Fri, 7 Nov 2025 12:38:31 +0100 Subject: [PATCH] feat: introduce `no-schema` option to drop `schema` form meta fields --- src/parser/utils.ts | 16 +++++++++++++++- src/types/module.ts | 8 ++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/parser/utils.ts b/src/parser/utils.ts index b6700b3..01df6dd 100644 --- a/src/parser/utils.ts +++ b/src/parser/utils.ts @@ -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 = { 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(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)) @@ -35,6 +36,19 @@ export function refineMeta(meta: ComponentMeta, fields: Record // 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 } diff --git a/src/types/module.ts b/src/types/module.ts index 16d63f2..1bca2fa 100644 --- a/src/types/module.ts +++ b/src/types/module.ts @@ -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.