diff --git a/src/core/transform.ts b/src/core/transform.ts index 59a082d..45c04b5 100644 --- a/src/core/transform.ts +++ b/src/core/transform.ts @@ -45,7 +45,7 @@ export function transformVueJsxVapor( inline: true, isTS: id.endsWith('tsx'), filename: id, - ...options?.compile, + ...options?.compilerOptions, }, ) vaporHelpers.forEach((helper) => importSet.add(helper)) diff --git a/src/index.ts b/src/index.ts index fa80378..5b08dd7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,19 +1,38 @@ import { type UnpluginFactory, createUnplugin } from 'unplugin' import { createFilter, transformWithEsbuild } from 'vite' +import { shallowRef } from 'vue' +import { version } from '../package.json' import { transformVueJsxVapor } from './core/transform' import type { Options } from './types' export const unpluginFactory: UnpluginFactory = ( - options = {}, + rawOptions = {}, ) => { + const options = shallowRef({ + include: /\.[jt]sx$/, + ...rawOptions, + }) + + const api = { + get options() { + return options.value + }, + set options(value) { + options.value = value + }, + version, + } + const transformInclude = createFilter( - options?.include || /\.[jt]sx$/, - options?.exclude, + options.value.include, + options.value.exclude, ) + return [ { name: 'unplugin-vue-jsx-vapor', vite: { + api, config(config) { return { // only apply esbuild to ts files @@ -31,9 +50,15 @@ export const unpluginFactory: UnpluginFactory = ( } }, }, + rollup: { + api, + }, + rolldown: { + api, + }, transformInclude, transform(code, id) { - return transformVueJsxVapor(code, id, options) + return transformVueJsxVapor(code, id, options.value) }, }, { diff --git a/src/types.ts b/src/types.ts index 515e693..d0cc2a1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,5 +5,5 @@ export interface Options { // define your plugin options here include?: FilterPattern exclude?: FilterPattern - compile?: CompilerOptions + compilerOptions?: CompilerOptions }