@@ -4,7 +4,7 @@ import Debug from 'debug'
44import type { UpdatePayload , ViteDevServer } from 'vite'
55import { slash , throttle , toArray } from '@antfu/utils'
66import type { ComponentInfo , Options , ResolvedOptions , Transformer } from '../types'
7- import { getNameFromFilePath , matchGlobs , parseId , pascalCase , resolveAlias } from './utils'
7+ import { getNameFromFilePath , matchGlobs , normalizeComponetInfo , parseId , pascalCase , resolveAlias } from './utils'
88import { resolveOptions } from './options'
99import { searchComponents } from './fs/glob'
1010import { generateDeclaration } from './declaration'
@@ -116,8 +116,8 @@ export class Context {
116116 }
117117
118118 addCustomComponents ( info : ComponentInfo ) {
119- if ( info . name )
120- this . _componentCustomMap [ info . name ] = info
119+ if ( info . as )
120+ this . _componentCustomMap [ info . as ] = info
121121 }
122122
123123 removeComponents ( paths : string | string [ ] ) {
@@ -176,16 +176,16 @@ export class Context {
176176 }
177177
178178 this . _componentNameMap [ name ] = {
179- name,
180- path,
179+ as : name ,
180+ from : path ,
181181 }
182182 } )
183183 }
184184
185185 async findComponent ( name : string , type : 'component' | 'directive' , excludePaths : string [ ] = [ ] ) : Promise < ComponentInfo | undefined > {
186186 // resolve from fs
187187 let info = this . _componentNameMap [ name ]
188- if ( info && ! excludePaths . includes ( info . path ) && ! excludePaths . includes ( info . path . slice ( 1 ) ) )
188+ if ( info && ! excludePaths . includes ( info . from ) && ! excludePaths . includes ( info . from . slice ( 1 ) ) )
189189 return info
190190
191191 // custom resolvers
@@ -197,16 +197,16 @@ export class Context {
197197 if ( result ) {
198198 if ( typeof result === 'string' ) {
199199 info = {
200- name,
201- path : result ,
200+ as : name ,
201+ from : result ,
202202 }
203203 this . addCustomComponents ( info )
204204 return info
205205 }
206206 else {
207207 info = {
208- name,
209- ...result ,
208+ as : name ,
209+ ...normalizeComponetInfo ( result ) ,
210210 }
211211 this . addCustomComponents ( info )
212212 return info
0 commit comments