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 66import { defineProps } from ' vue'
77
88const props = defineProps ({
9- msg: String
9+ msg: String ,
1010})
1111 </script >
Original file line number Diff line number Diff line change 66import { defineProps } from ' vue'
77
88const props = defineProps ({
9- msg: String
9+ msg: String ,
1010})
1111 </script >
Original file line number Diff line number Diff line change 11<template >
2- <h3 >Component D: <component-b msg =" wrapper" /></h3 >
2+ <h3 >Component D: <component-b msg =" wrapper" /></h3 >
33</template >
44
55<script lang='ts'>
Original file line number Diff line number Diff line change 66import { defineProps } from ' vue'
77
88const props = defineProps ({
9- msg: String
9+ msg: String ,
1010})
1111 </script >
Original file line number Diff line number Diff line change 11import { createApp } from 'vue'
22import App from '/src/App.vue'
33import './index.css'
4- // import 'vant/lib/index.css'
4+ import '../node_modules/ vant/lib/index.css'
55
66createApp ( App ) . mount ( '#app' )
Original file line number Diff line number Diff line change @@ -160,7 +160,7 @@ export class Context {
160160 return await Promise . resolve ( this . _importsResolveTasks [ key ] [ 0 ] )
161161 }
162162
163- private _searchGlob : Promise < void > | undefined
163+ private _searched = 0
164164
165165 /**
166166 * This search for components in with the given options.
@@ -170,13 +170,14 @@ export class Context {
170170 * @param ctx
171171 * @param force
172172 */
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
178181 }
179-
180- return await this . _searchGlob
181182 }
182183}
Original file line number Diff line number Diff line change @@ -4,10 +4,10 @@ import { Context } from '../context'
44
55const debug = Debug ( 'vite-plugin-components:glob' )
66
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 ( ', ' ) } ]` )
99
10- const files = await fg ( ctx . globs , {
10+ const files = fg . sync ( ctx . globs , {
1111 ignore : [ 'node_modules' ] ,
1212 onlyFiles : true ,
1313 } )
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'
22import { Options } from './types'
33import { Context } from './context'
44import { VueTransformer } from './transforms/vue'
5- import { CustomComponentTransformer } from './transforms/customComponent'
65import { parseId , resolveOptions } from './utils'
7- import { generateResolver , isResolverPath } from './generator/importer'
86
97const defaultOptions : Required < Options > = {
108 dirs : 'src/components' ,
@@ -25,26 +23,13 @@ function VitePluginComponents(options: Options = {}): Plugin {
2523
2624 const transformer = [
2725 VueTransformer ( ctx ) ,
28- CustomComponentTransformer ( ctx ) ,
2926 ]
3027
3128 return {
3229 name : 'vite-plugin-components' ,
33- resolveId ( source ) {
34- if ( isResolverPath ( source ) )
35- return source
36- return null
37- } ,
3830 configResolved ( config ) {
3931 ctx . viteConfig = config
4032 } ,
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- } ,
4833 transform ( code , id ) {
4934 const { path, query } = parseId ( id )
5035 for ( const trans of transformer )
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments