-
-
Notifications
You must be signed in to change notification settings - Fork 367
/
Copy pathtypes.ts
132 lines (109 loc) · 2.97 KB
/
types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import type { FilterPattern } from '@rollup/pluginutils'
import type { TransformResult } from 'unplugin'
export interface ImportInfo {
name?: string
importName?: string
path: string
}
export type SideEffectsInfo = (ImportInfo | string)[] | ImportInfo | string | undefined
export interface ComponentInfo extends ImportInfo {
sideEffects?: SideEffectsInfo
}
export type ComponentResolveResult = string | ComponentInfo
export type ComponentResolver = (name: string) => ComponentResolveResult | null | undefined | void
export interface UILibraryOptions {
name: string
prefix?: string
entries?: string[]
}
export type Matcher = (id: string) => boolean | null | undefined
export type Transformer = (code: string, id: string, path: string, query: Record<string, string>) => TransformResult | null | Promise<null | TransformResult>
/**
* Plugin options.
*/
export interface Options {
/**
* RegExp or glob to match files to be transformed
*/
include?: FilterPattern
/**
* RegExp or glob to match files to NOT be transformed
*/
exclude?: FilterPattern
/**
* Relative paths to the directory to search for components.
* @default 'src/components'
*/
dirs?: string | string[]
/**
* Valid file extensions for components.
* @default ['vue']
*/
extensions?: string | string[]
/**
* Search for subdirectories
* @default true
*/
deep?: boolean
/**
* Allow subdirectories as namespace prefix for components
* @default false
*/
directoryAsNamespace?: boolean
/**
* Subdirectory paths for ignoring namespace prefixes
* works when `directoryAsNamespace: true`
* @default "[]"
*/
globalNamespaces?: string[]
/**
* comp libraries to use auto import
*/
libraries?: (string | UILibraryOptions)[]
/**
* Pass a custom function to resolve the component importing path from the component name.
*
* The component names are always in PascalCase
*/
resolvers?: ComponentResolver | ComponentResolver[]
/**
* Apply custom transform over the path for importing
*/
importPathTransform?: (path: string) => string | undefined
/**
* Transformer to apply
*
* @default 'vue3'
*/
transformer?: 'vue3' | 'vue2'
/**
* Generate TypeScript declaration for global components
*
* Accept boolean or a path related to project root
*
* @see https://github.com/vuejs/vue-next/pull/3399
* @see https://github.com/johnsoncodehk/volar#using
* @default true
*/
dts?: boolean | string
/**
* Do not emit warning on component overriding
*
* @default false
*/
allowOverrides?: boolean
}
export type ResolvedOptions = Omit<
Required<Options>,
'resolvers'|'libraries'|'extensions'|'dirs'|'globalComponentsDeclaration'
> & {
resolvers: ComponentResolver[]
libraries: UILibraryOptions[]
extensions: string[]
dirs: string[]
resolvedDirs: string[]
globs: string[]
dts: string | false
root: string
}
export type ComponentsImportMap = Record<string, string[] | undefined>