Skip to content

Commit c6d77c0

Browse files
committed
fix: correct prefixed component name
1 parent 7b2ead2 commit c6d77c0

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

src/core/context.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,10 @@ export class Context {
215215
Array
216216
.from(this._componentPaths)
217217
.forEach((path) => {
218-
const name = pascalCase(getNameFromFilePath(path, this.options))
218+
const fileName = getNameFromFilePath(path, this.options)
219+
const name = this.options.prefix
220+
? `${pascalCase(this.options.prefix)}${pascalCase(fileName)}`
221+
: pascalCase(fileName)
219222
if (isExclude(name, this.options.excludeNames)) {
220223
debug.components('exclude', name)
221224
return

src/core/declaration.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,6 @@ export function parseDeclaration(code: string): DeclarationImports | undefined {
3838
return imports
3939
}
4040

41-
function addComponentPrefix(component: ComponentInfo, prefix?: string) {
42-
if (!component.as || !prefix)
43-
return component
44-
45-
return {
46-
...component,
47-
as: `${prefix}${component.as}`,
48-
}
49-
}
50-
5141
/**
5242
* Converts `ComponentInfo` to an array
5343
*
@@ -82,10 +72,11 @@ export interface DeclarationImports {
8272
}
8373

8474
export function getDeclarationImports(ctx: Context, filepath: string): DeclarationImports | undefined {
85-
const prefixComponentNameMap = Object.values(ctx.componentNameMap).map(info => addComponentPrefix(info, ctx.options.prefix))
8675
const component = stringifyComponentsInfo(filepath, [
87-
...Object.values(ctx.componentCustomMap),
88-
...prefixComponentNameMap,
76+
...Object.values({
77+
...ctx.componentNameMap,
78+
...ctx.componentCustomMap,
79+
}),
8980
...resolveTypeImports(ctx.options.types),
9081
], ctx.options.importPathTransform)
9182

0 commit comments

Comments
 (0)