File tree Expand file tree Collapse file tree 11 files changed +22
-136
lines changed Expand file tree Collapse file tree 11 files changed +22
-136
lines changed Original file line number Diff line number Diff line change 6
6
import { defineProps } from ' vue'
7
7
8
8
const props = defineProps ({
9
- msg: String
9
+ msg: String ,
10
10
})
11
11
</script >
Original file line number Diff line number Diff line change 6
6
import { defineProps } from ' vue'
7
7
8
8
const props = defineProps ({
9
- msg: String
9
+ msg: String ,
10
10
})
11
11
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
- <h3 >Component D: <component-b msg =" wrapper" /></h3 >
2
+ <h3 >Component D: <component-b msg =" wrapper" /></h3 >
3
3
</template >
4
4
5
5
<script lang='ts'>
Original file line number Diff line number Diff line change 6
6
import { defineProps } from ' vue'
7
7
8
8
const props = defineProps ({
9
- msg: String
9
+ msg: String ,
10
10
})
11
11
</script >
Original file line number Diff line number Diff line change 1
1
import { createApp } from 'vue'
2
2
import App from '/src/App.vue'
3
3
import './index.css'
4
- // import 'vant/lib/index.css'
4
+ import '../node_modules/ vant/lib/index.css'
5
5
6
6
createApp ( App ) . mount ( '#app' )
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ export class Context {
160
160
return await Promise . resolve ( this . _importsResolveTasks [ key ] [ 0 ] )
161
161
}
162
162
163
- private _searchGlob : Promise < void > | undefined
163
+ private _searched = 0
164
164
165
165
/**
166
166
* This search for components in with the given options.
@@ -170,13 +170,14 @@ export class Context {
170
170
* @param ctx
171
171
* @param force
172
172
*/
173
- async searchGlob ( ) {
174
- if ( ! this . _searchGlob ) {
175
- this . _searchGlob = ( async ( ) => {
176
- await searchComponents ( this )
177
- } ) ( )
173
+ searchGlob ( forceMs = - 1 ) {
174
+ if ( this . _searched && forceMs < 0 )
175
+ return
176
+
177
+ const now = + new Date ( )
178
+ if ( now - this . _searched > forceMs ) {
179
+ searchComponents ( this )
180
+ this . _searched = now
178
181
}
179
-
180
- return await this . _searchGlob
181
182
}
182
183
}
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ import { Context } from '../context'
4
4
5
5
const debug = Debug ( 'vite-plugin-components:glob' )
6
6
7
- export async function searchComponents ( ctx : Context ) {
8
- debug ( `searching start with: [${ ctx . globs . join ( ', ' ) } ]` )
7
+ export function searchComponents ( ctx : Context ) {
8
+ debug ( `started with: [${ ctx . globs . join ( ', ' ) } ]` )
9
9
10
- const files = await fg ( ctx . globs , {
10
+ const files = fg . sync ( ctx . globs , {
11
11
ignore : [ 'node_modules' ] ,
12
12
onlyFiles : true ,
13
13
} )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2,9 +2,7 @@ import type { Plugin } from 'vite'
2
2
import { Options } from './types'
3
3
import { Context } from './context'
4
4
import { VueTransformer } from './transforms/vue'
5
- import { CustomComponentTransformer } from './transforms/customComponent'
6
5
import { parseId , resolveOptions } from './utils'
7
- import { generateResolver , isResolverPath } from './generator/importer'
8
6
9
7
const defaultOptions : Required < Options > = {
10
8
dirs : 'src/components' ,
@@ -25,26 +23,13 @@ function VitePluginComponents(options: Options = {}): Plugin {
25
23
26
24
const transformer = [
27
25
VueTransformer ( ctx ) ,
28
- CustomComponentTransformer ( ctx ) ,
29
26
]
30
27
31
28
return {
32
29
name : 'vite-plugin-components' ,
33
- resolveId ( source ) {
34
- if ( isResolverPath ( source ) )
35
- return source
36
- return null
37
- } ,
38
30
configResolved ( config ) {
39
31
ctx . viteConfig = config
40
32
} ,
41
- async load ( id ) {
42
- if ( isResolverPath ( id ) ) {
43
- await ctx . searchGlob ( )
44
- return await generateResolver ( ctx , id . slice ( 1 ) ) // remove the heading '/'
45
- }
46
- return null
47
- } ,
48
33
transform ( code , id ) {
49
34
const { path, query } = parseId ( id )
50
35
for ( const trans of transformer )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments