@@ -4,7 +4,7 @@ import Debug from 'debug'
4
4
import type { UpdatePayload , ViteDevServer } from 'vite'
5
5
import { slash , throttle , toArray } from '@antfu/utils'
6
6
import 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'
8
8
import { resolveOptions } from './options'
9
9
import { searchComponents } from './fs/glob'
10
10
import { generateDeclaration } from './declaration'
@@ -116,8 +116,8 @@ export class Context {
116
116
}
117
117
118
118
addCustomComponents ( info : ComponentInfo ) {
119
- if ( info . name )
120
- this . _componentCustomMap [ info . name ] = info
119
+ if ( info . as )
120
+ this . _componentCustomMap [ info . as ] = info
121
121
}
122
122
123
123
removeComponents ( paths : string | string [ ] ) {
@@ -176,16 +176,16 @@ export class Context {
176
176
}
177
177
178
178
this . _componentNameMap [ name ] = {
179
- name,
180
- path,
179
+ as : name ,
180
+ from : path ,
181
181
}
182
182
} )
183
183
}
184
184
185
185
async findComponent ( name : string , type : 'component' | 'directive' , excludePaths : string [ ] = [ ] ) : Promise < ComponentInfo | undefined > {
186
186
// resolve from fs
187
187
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 ) ) )
189
189
return info
190
190
191
191
// custom resolvers
@@ -197,16 +197,16 @@ export class Context {
197
197
if ( result ) {
198
198
if ( typeof result === 'string' ) {
199
199
info = {
200
- name,
201
- path : result ,
200
+ as : name ,
201
+ from : result ,
202
202
}
203
203
this . addCustomComponents ( info )
204
204
return info
205
205
}
206
206
else {
207
207
info = {
208
- name,
209
- ...result ,
208
+ as : name ,
209
+ ...normalizeComponetInfo ( result ) ,
210
210
}
211
211
this . addCustomComponents ( info )
212
212
return info
0 commit comments