Skip to content

Commit d8f8365

Browse files
committed
chore: pref improve
1 parent 624a527 commit d8f8365

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/glob.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@ function toArray<T>(arr: T | T[]): T[] {
1111
return [arr]
1212
}
1313

14+
/**
15+
* This search for components in with the given options.
16+
* Will be called multiple times to ensure file loaded,
17+
* should normally run only once.
18+
*
19+
* TODO: watch on file changes for server mode
20+
*
21+
* @param ctx
22+
* @param force
23+
*/
1424
export async function searchComponents(ctx: Context, force = false) {
1525
if (force || !ctx._searchingPromise) {
1626
ctx._searchingPromise = (async() => {
@@ -45,7 +55,6 @@ export async function searchComponents(ctx: Context, force = false) {
4555
debug(`[${components.map(i => i).join(', ')}]`)
4656

4757
ctx.components = components
48-
ctx._searchingPromise = undefined
4958
})()
5059
}
5160

src/plugins/server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import { isResolverPath, generateResolver } from '../generator/resolver'
44
import { searchComponents } from '../glob'
55

66
export function createServerPlugin(context: Context): ServerPlugin {
7-
return ({ app }) => {
7+
return ({ app, watcher }) => {
8+
// TODO: handle HMR use watch
9+
810
app.use(async(ctx, next) => {
911
if (!isResolverPath(ctx.path))
1012
return next()

0 commit comments

Comments
 (0)