1
+ import type { FilterPattern } from '@rollup/pluginutils'
1
2
import type { ComponentResolver } from '../../types'
3
+ import { isExclude } from '../utils'
2
4
3
5
export interface TDesignResolverOptions {
4
6
/**
@@ -23,7 +25,7 @@ export interface TDesignResolverOptions {
23
25
* exclude component name, if match do not resolve the name
24
26
*
25
27
*/
26
- exclude ?: string | RegExp | ( string | RegExp ) [ ]
28
+ exclude ?: FilterPattern
27
29
}
28
30
29
31
export function TDesignResolver ( options : TDesignResolverOptions = { } ) : ComponentResolver {
@@ -34,7 +36,7 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component
34
36
const { library = 'vue' , exclude } = options
35
37
const importFrom = options . esm ? '/esm' : ''
36
38
37
- if ( options . exclude && isExclude ( name , exclude ) )
39
+ if ( isExclude ( name , exclude ) )
38
40
return
39
41
40
42
if ( options . resolveIcons && name . match ( / [ a - z ] I c o n $ / ) ) {
@@ -55,19 +57,3 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component
55
57
} ,
56
58
}
57
59
}
58
-
59
- function isExclude ( name : string , exclude : string | RegExp | ( string | RegExp ) [ ] | undefined ) : boolean {
60
- if ( typeof exclude === 'string' )
61
- return name === exclude
62
-
63
- if ( exclude instanceof RegExp )
64
- return ! ! name . match ( exclude )
65
-
66
- if ( Array . isArray ( exclude ) ) {
67
- for ( const item of exclude ) {
68
- if ( name === item || name . match ( item ) )
69
- return true
70
- }
71
- }
72
- return false
73
- }
0 commit comments