File tree 1 file changed +9
-8
lines changed
1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change 1
1
2
+ import { promises as fs } from 'fs'
3
+ import { resolveModule } from 'local-pkg'
2
4
import type { ComponentResolver } from '../../types'
3
5
4
6
/**
@@ -7,16 +9,15 @@ import type { ComponentResolver } from '../../types'
7
9
* @link https://github.com/quasarframework/quasar
8
10
*/
9
11
export function QuasarResolver ( ) : ComponentResolver {
12
+ let components : unknown [ ] = [ ]
13
+
10
14
return {
11
15
type : 'component' ,
12
- resolve : ( name : string ) => {
13
- let components = [ ]
14
-
15
- try {
16
- /* eslint-disable @typescript-eslint/no-var-requires */
17
- components = require ( 'quasar/dist/transforms/api-list.json' )
18
- }
19
- catch ( e ) {
16
+ resolve : async ( name : string ) => {
17
+ if ( ! components . length ) {
18
+ const quasarApiListPath = resolveModule ( 'quasar/dist/transforms/api-list.json' )
19
+ if ( quasarApiListPath )
20
+ components = JSON . parse ( await fs . readFile ( quasarApiListPath , 'utf-8' ) )
20
21
}
21
22
22
23
if ( components . includes ( name ) )
You can’t perform that action at this time.
0 commit comments