Skip to content

Commit 4d044cb

Browse files
committed
feat: new allowOverrides options
1 parent d1f8e0d commit 4d044cb

File tree

5 files changed

+11
-2
lines changed

5 files changed

+11
-2
lines changed

src/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export class Context {
129129
.from(this._componentPaths)
130130
.forEach((path) => {
131131
const name = pascalCase(getNameFromFilePath(path, this.options))
132-
if (this._componentNameMap[name]) {
132+
if (this._componentNameMap[name] && !this.options.allowOverrides) {
133133
// eslint-disable-next-line no-console
134134
console.warn(`[vite-plugin-components] component "${name}"(${path}) has naming conflicts with other components, ignored.`)
135135
return

src/fs/glob.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export function searchComponents(ctx: Context) {
1616
})
1717

1818
if (!files.length && !ctx.options.customComponentResolvers?.length)
19+
// eslint-disable-next-line no-console
1920
console.warn('[vite-plugin-components] no components found')
2021

2122
debug(`${files.length} components found.`)

src/helpers/libraryResolver.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function tryLoadVeturTags(name: string): string[] | undefined {
2020
return Object.keys(tags).map(i => camelCase(i))
2121
}
2222
catch (e) {
23+
// eslint-disable-next-line no-console
2324
console.error(e)
2425
}
2526
}
@@ -32,6 +33,7 @@ export function LibraryResolver(options: UILibraryOptions): ComponentResolver {
3233
} = options
3334

3435
if (!entries) {
36+
// eslint-disable-next-line no-console
3537
console.warn(`[vite-plugin-components] Failed to load Vetur tags from library "${libraryName}"`)
3638
return () => {}
3739
}

src/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ export interface Options {
100100
* @default false
101101
*/
102102
globalComponentsDeclaration?: boolean | string
103+
104+
/**
105+
* Do not emit warning on component overriding
106+
*
107+
* @default false
108+
*/
109+
allowOverrides?: boolean
103110
}
104111

105112
export type ResolvedOptions = Omit<

src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export function getNameFromFilePath(filePath: string, options: ResolvedOptions):
170170
filename = [...folders, filename].filter(Boolean).join('-')
171171
}
172172

173-
// console.log('!!!', filename)
174173
return filename
175174
}
176175

0 commit comments

Comments
 (0)