From 269121e90b1511d8d60f5ebdf68e272e7fd3e04c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Tue, 29 Aug 2023 00:57:12 +0800 Subject: [PATCH] feat(plugin-vue): expose options in `api` (#177) --- packages/plugin-vue/src/index.ts | 11 +++++++++++ packages/plugin-vue/tsconfig.json | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index 811c7167..3e9f6b18 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -10,6 +10,7 @@ import type { } from 'vue/compiler-sfc' import type * as _compiler from 'vue/compiler-sfc' /* eslint-enable import/no-duplicates */ +import { version } from '../package.json' import { resolveCompiler } from './compiler' import { parseVueRequest } from './utils/query' import { getDescriptor, getSrcDescriptor } from './utils/descriptorCache' @@ -130,6 +131,16 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { return { name: 'vite:vue', + api: { + get options() { + return options + }, + set options(value) { + options = value + }, + version, + }, + handleHotUpdate(ctx) { if (options.compiler.invalidateTypeCache) { options.compiler.invalidateTypeCache(ctx.file) diff --git a/packages/plugin-vue/tsconfig.json b/packages/plugin-vue/tsconfig.json index b8ce2879..cec54d61 100644 --- a/packages/plugin-vue/tsconfig.json +++ b/packages/plugin-vue/tsconfig.json @@ -12,6 +12,7 @@ "noImplicitOverride": true, "noUnusedLocals": true, "esModuleInterop": true, - "baseUrl": "." + "baseUrl": ".", + "resolveJsonModule": true } }