File tree Expand file tree Collapse file tree 4 files changed +19
-20
lines changed Expand file tree Collapse file tree 4 files changed +19
-20
lines changed Original file line number Diff line number Diff line change 6868 "@babel/plugin-syntax-typescript" : " ^7.27.1" ,
6969 "@vue/babel-plugin-jsx" : " ^1.5.0" ,
7070 "@vue/babel-preset-jsx" : " ^1.4.0" ,
71- "unplugin" : " ^2.3.9" ,
72- "unplugin-utils" : " ^0.3.0"
71+ "unplugin" : " ^2.3.9"
7372 },
7473 "devDependencies" : {
7574 "@sxzz/eslint-config" : " ^7.1.4" ,
Original file line number Diff line number Diff line change 11import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx'
2- import type { FilterPattern } from 'unplugin-utils '
2+ import type { FilterPattern } from 'unplugin'
33
44export type Options = {
55 include ?: FilterPattern
@@ -18,7 +18,7 @@ export type OptionsResolved = Overwrite<
1818export function resolveOptions ( options : Options ) : OptionsResolved {
1919 return {
2020 ...options ,
21- include : options . include || [ / \. [ j t ] s x ? $ / ] ,
21+ include : options . include || [ / \. [ j t ] s x $ / ] ,
2222 exclude : options . exclude || [ / n o d e _ m o d u l e s / ] ,
2323 sourceMap : options . sourceMap ?? true ,
2424 }
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ function isTS(id: string): boolean {
1111export function transformVueJsx (
1212 code : string ,
1313 id : string ,
14- options : OptionsResolved ,
14+ options : Omit < OptionsResolved , 'include' | 'exclude' > ,
1515) : { code : string ; map : any } | undefined {
1616 const transformOptions : TransformOptions = {
1717 babelrc : false ,
Original file line number Diff line number Diff line change 11import { createUnplugin , type UnpluginInstance } from 'unplugin'
2- import { createFilter } from 'unplugin-utils'
32import { resolveOptions , type Options } from './core/options'
43import { transformVueJsx } from './core/vue'
54
65const VueJsx : UnpluginInstance < Options | undefined , false > = createUnplugin (
76 ( userOptions = { } ) => {
8- const options = resolveOptions ( userOptions )
9- const filter = createFilter ( options . include , options . exclude )
7+ const { include , exclude , enforce , ... options } =
8+ resolveOptions ( userOptions )
109
1110 return {
1211 name : 'unplugin-vue-jsx' ,
13- enforce : options . enforce ,
12+ enforce,
1413
15- transformInclude ( id ) {
16- return filter ( id )
17- } ,
18-
19- transform ( code , id ) {
20- const result = transformVueJsx ( code , id , options )
21- if ( ! result ?. code ) return
22- return {
23- code : result . code ,
24- map : result . map as any ,
25- }
14+ transform : {
15+ filter : {
16+ id : { include, exclude } ,
17+ } ,
18+ handler ( code , id ) {
19+ const result = transformVueJsx ( code , id , options )
20+ if ( ! result ?. code ) return
21+ return {
22+ code : result . code ,
23+ map : result . map as any ,
24+ }
25+ } ,
2626 } ,
2727 }
2828 } ,
You can’t perform that action at this time.
0 commit comments