From 7fc7994b1133ced9b841883fe78cd06b0febf4aa Mon Sep 17 00:00:00 2001 From: Evan You Date: Tue, 18 Jun 2024 16:43:14 +0800 Subject: [PATCH] chore: update documentation for new features option --- packages/plugin-vue/README.md | 56 ++++++++++++++++++++++++++------ packages/plugin-vue/src/index.ts | 41 ++++++++++++++++------- 2 files changed, 75 insertions(+), 22 deletions(-) diff --git a/packages/plugin-vue/README.md b/packages/plugin-vue/README.md index 35afc46d..57656766 100644 --- a/packages/plugin-vue/README.md +++ b/packages/plugin-vue/README.md @@ -22,7 +22,47 @@ export interface Options { isProduction?: boolean - // options to pass on to vue/compiler-sfc + /** + * Requires @vitejs/plugin-vue@^5.1.0 + */ + features?: { + /** + * Enable reactive destructure for `defineProps`. + * - Available in Vue 3.4 and later. + * - **default:** `false` in Vue 3.4 (**experimental**), `true` in Vue 3.5+ + */ + propsDestructure?: boolean + /** + * Transform Vue SFCs into custom elements. + * - `true`: all `*.vue` imports are converted into custom elements + * - `string | RegExp`: matched files are converted into custom elements + * - **default:** /\.ce\.vue$/ + */ + customElement?: boolean | string | RegExp | (string | RegExp)[] + /** + * Set to `false` to disable Options API support and allow related code in + * Vue core to be dropped via dead-code elimination in production builds, + * resulting in smaller bundles. + * - **default:** `true` + */ + optionsAPI?: boolean + /** + * Set to `true` to enable devtools support in production builds. + * Results in slightly larger bundles. + * - **default:** `false` + */ + prodDevtools?: boolean + /** + * Set to `true` to enable detailed information for hydration mismatch + * errors in production builds. Results in slightly larger bundles. + * - **default:** `false` + */ + prodHydrationMismatchDetails?: boolean + } + + // `script`, `template` and `style` are lower-level compiler options + // to pass on to respective APIs of `vue/compiler-sfc` + script?: Partial< Omit< SFCScriptCompileOptions, @@ -33,7 +73,6 @@ export interface Options { | 'sourceMap' | 'genDefaultAs' | 'customElement' - | 'defineModel' > > @@ -53,6 +92,7 @@ export interface Options { | 'preprocessLang' > > + style?: Partial< Omit< SFCStyleCompileOptions, @@ -72,18 +112,14 @@ export interface Options { > /** - * Transform Vue SFCs into custom elements. - * - `true`: all `*.vue` imports are converted into custom elements - * - `string | RegExp`: matched files are converted into custom elements - * - * @default /\.ce\.vue$/ + * Use custom compiler-sfc instance. Can be used to force a specific version. */ - customElement?: boolean | string | RegExp | (string | RegExp)[] + compiler?: typeof _compiler /** - * Use custom compiler-sfc instance. Can be used to force a specific version. + * @deprecated moved to `features.customElement`. */ - compiler?: typeof _compiler + customElements?: boolean | string | RegExp | (string | RegExp)[] } ``` diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index d49e904a..b301a596 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -93,36 +93,53 @@ export interface Options { > > - /** - * @deprecated moved to `features.customElement`. - */ - customElement?: boolean | string | RegExp | (string | RegExp)[] - /** * Use custom compiler-sfc instance. Can be used to force a specific version. */ compiler?: typeof _compiler + /** + * Requires @vitejs/plugin-vue@^5.1.0 + */ features?: { - optionsAPI?: boolean - prodDevtools?: boolean - prodHydrationMismatchDetails?: boolean /** * Enable reactive destructure for `defineProps`. * - Available in Vue 3.4 and later. - * - Defaults to true in Vue 3.5+ - * - Defaults to false in Vue 3.4 (**experimental**) + * - **default:** `false` in Vue 3.4 (**experimental**), `true` in Vue 3.5+ */ propsDestructure?: boolean /** * Transform Vue SFCs into custom elements. * - `true`: all `*.vue` imports are converted into custom elements * - `string | RegExp`: matched files are converted into custom elements - * - * @default /\.ce\.vue$/ + * - **default:** /\.ce\.vue$/ */ customElement?: boolean | string | RegExp | (string | RegExp)[] + /** + * Set to `false` to disable Options API support and allow related code in + * Vue core to be dropped via dead-code elimination in production builds, + * resulting in smaller bundles. + * - **default:** `true` + */ + optionsAPI?: boolean + /** + * Set to `true` to enable devtools support in production builds. + * Results in slightly larger bundles. + * - **default:** `false` + */ + prodDevtools?: boolean + /** + * Set to `true` to enable detailed information for hydration mismatch + * errors in production builds. Results in slightly larger bundles. + * - **default:** `false` + */ + prodHydrationMismatchDetails?: boolean } + + /** + * @deprecated moved to `features.customElement`. + */ + customElement?: boolean | string | RegExp | (string | RegExp)[] } export interface ResolvedOptions extends Options {