Skip to content

Commit b3cd6e5

Browse files
committed
refactor!: customComponentResolvers renamed to resolvers
1 parent 1a434a3 commit b3cd6e5

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ export default {
106106
plugins: [
107107
/* ... */
108108
Components({
109-
customComponentResolvers: [
109+
resolvers: [
110110
ElementPlusResolver(),
111111
]
112112
}),
@@ -173,7 +173,7 @@ import ViteComponents, {
173173

174174
// your plugin installation
175175
Components({
176-
customComponentResolvers: [
176+
resolvers: [
177177
AntDesignVueResolver(),
178178
ElementPlusResolver(),
179179
VantResolver(),
@@ -185,7 +185,7 @@ You can also write your own resolver easily:
185185

186186
```ts
187187
Components({
188-
customComponentResolvers: [
188+
resolvers: [
189189
// example of importing Vant
190190
(name) => {
191191
// where `name` is always CapitalCase

examples/naive-ui/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const config: UserConfig = {
66
plugins: [
77
Vue(),
88
ViteComponents({
9-
customComponentResolvers: [
9+
resolvers: [
1010
NaiveUiResolver(),
1111
],
1212
globalComponentsDeclaration: true,

examples/vite-vue3/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const config: UserConfig = {
3131
globalNamespaces: ['global'],
3232
importPathTransform: path => path.endsWith('.svg') ? `${path}?component` : undefined,
3333
include: [/\.vue$/, /\.md$/],
34-
customComponentResolvers: [
34+
resolvers: [
3535
(name) => {
3636
if (name === 'MyCustom')
3737
return '/src/CustomResolved.vue'

src/core/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class Context {
163163
return info
164164

165165
// custom resolvers
166-
for (const resolver of this.options.customComponentResolvers) {
166+
for (const resolver of this.options.resolvers) {
167167
const result = resolver(name)
168168
if (result) {
169169
if (typeof result === 'string') {

src/core/fs/glob.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export function searchComponents(ctx: Context) {
1515
absolute: true,
1616
})
1717

18-
if (!files.length && !ctx.options.customComponentResolvers?.length)
18+
if (!files.length && !ctx.options.resolvers?.length)
1919
// eslint-disable-next-line no-console
2020
console.warn('[unplugin-vue-components] no components found')
2121

src/core/options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const defaultOptions: Omit<Required<Options>, 'include' | 'exclude'> = {
1515
globalNamespaces: [],
1616

1717
libraries: [],
18-
customComponentResolvers: [],
18+
resolvers: [],
1919

2020
importPathTransform: v => v,
2121

@@ -25,8 +25,8 @@ export const defaultOptions: Omit<Required<Options>, 'include' | 'exclude'> = {
2525
export function resolveOptions(options: Options, root: string): ResolvedOptions {
2626
const resolved = Object.assign({}, defaultOptions, options) as ResolvedOptions
2727
resolved.libraries = toArray(resolved.libraries).map(i => typeof i === 'string' ? { name: i } : i)
28-
resolved.customComponentResolvers = toArray(resolved.customComponentResolvers)
29-
resolved.customComponentResolvers.push(...resolved.libraries.map(lib => LibraryResolver(lib)))
28+
resolved.resolvers = toArray(resolved.resolvers)
29+
resolved.resolvers.push(...resolved.libraries.map(lib => LibraryResolver(lib)))
3030
resolved.extensions = toArray(resolved.extensions)
3131

3232
const extsGlob = resolved.extensions.length === 1

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export interface Options {
8282
*
8383
* The component names are always in PascalCase
8484
*/
85-
customComponentResolvers?: ComponentResolver | ComponentResolver[]
85+
resolvers?: ComponentResolver | ComponentResolver[]
8686

8787
/**
8888
* Apply custom transform over the path for importing
@@ -117,9 +117,9 @@ export interface Options {
117117

118118
export type ResolvedOptions = Omit<
119119
Required<Options>,
120-
'customComponentResolvers'|'libraries'|'extensions'|'dirs'|'globalComponentsDeclaration'
120+
'resolvers'|'libraries'|'extensions'|'dirs'|'globalComponentsDeclaration'
121121
> & {
122-
customComponentResolvers: ComponentResolver[]
122+
resolvers: ComponentResolver[]
123123
libraries: UILibraryOptions[]
124124
extensions: string[]
125125
dirs: string[]

0 commit comments

Comments
 (0)