1
1
import { relative } from 'path'
2
2
import Debug from 'debug'
3
3
import { ResolvedConfig } from 'vite'
4
- import { ComponentInfo , ComponentsImportMap , ResolvedOptions } from './types'
5
- import { pascalCase , toArray , getNameFromFilePath , resolveAlias , kebabCase } from './utils'
4
+ import { ComponentInfo , ResolvedOptions } from './types'
5
+ import { pascalCase , toArray , getNameFromFilePath , resolveAlias } from './utils'
6
6
import { searchComponents } from './fs/glob'
7
7
8
8
const debug = {
@@ -15,8 +15,6 @@ export class Context {
15
15
16
16
private _componentPaths = new Set < string > ( )
17
17
private _componentNameMap : Record < string , ComponentInfo > = { }
18
- private _imports : ComponentsImportMap = { }
19
- private _importsResolveTasks : Record < string , [ ( null | Promise < string [ ] > ) , ( null | ( ( result : string [ ] ) => void ) ) ] > = { }
20
18
21
19
constructor (
22
20
public readonly options : ResolvedOptions ,
@@ -34,8 +32,6 @@ export class Context {
34
32
? `${ i } /**/*.${ extsGlob } `
35
33
: `${ i } /*.${ extsGlob } ` ,
36
34
)
37
-
38
- this . searchGlob ( )
39
35
}
40
36
41
37
get root ( ) {
@@ -62,12 +58,6 @@ export class Context {
62
58
return false
63
59
}
64
60
65
- findReferencesOfComponentName ( name : string ) {
66
- return Object . entries ( this . _imports )
67
- . map ( ( [ path , components ] ) => components ?. includes ( name ) ? path : undefined )
68
- . filter ( Boolean ) as string [ ]
69
- }
70
-
71
61
private updateComponentNameMap ( ) {
72
62
this . _componentNameMap = { }
73
63
@@ -131,35 +121,6 @@ export class Context {
131
121
return relative ( this . root , path ) . replace ( / \\ / g, '/' )
132
122
}
133
123
134
- setImports ( key : string , names : string [ ] ) {
135
- const casedNames = names . map ( name => pascalCase ( name ) )
136
- this . _imports [ key ] = casedNames
137
- if ( this . _importsResolveTasks [ key ] )
138
- this . _importsResolveTasks [ key ] [ 1 ] ?.( casedNames )
139
- return key
140
- }
141
-
142
- /**
143
- * Await for imports to get resolved
144
- *
145
- * @param ctx
146
- * @param force
147
- */
148
- async getImports ( key : string ) {
149
- if ( this . _imports [ key ] )
150
- return this . _imports [ key ]
151
-
152
- if ( ! this . _importsResolveTasks [ key ] ) {
153
- this . _importsResolveTasks [ key ] = [ null , null ]
154
- const p = new Promise < string [ ] > ( ( resolve ) => {
155
- this . _importsResolveTasks [ key ] [ 1 ] = resolve
156
- } )
157
- this . _importsResolveTasks [ key ] [ 0 ] = p
158
- }
159
-
160
- return await Promise . resolve ( this . _importsResolveTasks [ key ] [ 0 ] )
161
- }
162
-
163
124
private _searched = 0
164
125
165
126
/**
0 commit comments