1+ import type { FilterPattern } from '@rollup/pluginutils'
12import type { ComponentResolver } from '../../types'
3+ import { isExclude } from '../utils'
24
35export interface TDesignResolverOptions {
46 /**
@@ -23,7 +25,7 @@ export interface TDesignResolverOptions {
2325 * exclude component name, if match do not resolve the name
2426 *
2527 */
26- exclude ?: string | RegExp | ( string | RegExp ) [ ]
28+ exclude ?: FilterPattern
2729}
2830
2931export function TDesignResolver ( options : TDesignResolverOptions = { } ) : ComponentResolver {
@@ -34,7 +36,7 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component
3436 const { library = 'vue' , exclude } = options
3537 const importFrom = options . esm ? '/esm' : ''
3638
37- if ( options . exclude && isExclude ( name , exclude ) )
39+ if ( isExclude ( name , exclude ) )
3840 return
3941
4042 if ( options . resolveIcons && name . match ( / [ a - z ] I c o n $ / ) ) {
@@ -55,19 +57,3 @@ export function TDesignResolver(options: TDesignResolverOptions = {}): Component
5557 } ,
5658 }
5759}
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