11import { relative } from 'path'
22import Debug from 'debug'
33import { 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'
66import { searchComponents } from './fs/glob'
77
88const debug = {
@@ -15,8 +15,6 @@ export class Context {
1515
1616 private _componentPaths = new Set < string > ( )
1717 private _componentNameMap : Record < string , ComponentInfo > = { }
18- private _imports : ComponentsImportMap = { }
19- private _importsResolveTasks : Record < string , [ ( null | Promise < string [ ] > ) , ( null | ( ( result : string [ ] ) => void ) ) ] > = { }
2018
2119 constructor (
2220 public readonly options : ResolvedOptions ,
@@ -34,8 +32,6 @@ export class Context {
3432 ? `${ i } /**/*.${ extsGlob } `
3533 : `${ i } /*.${ extsGlob } ` ,
3634 )
37-
38- this . searchGlob ( )
3935 }
4036
4137 get root ( ) {
@@ -62,12 +58,6 @@ export class Context {
6258 return false
6359 }
6460
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-
7161 private updateComponentNameMap ( ) {
7262 this . _componentNameMap = { }
7363
@@ -131,35 +121,6 @@ export class Context {
131121 return relative ( this . root , path ) . replace ( / \\ / g, '/' )
132122 }
133123
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-
163124 private _searched = 0
164125
165126 /**
0 commit comments