Skip to content

Commit 0e3e3d7

Browse files
authored
fix: scanDirs when nested modules in dirs update (#319)
1 parent 6114023 commit 0e3e3d7

File tree

6 files changed

+19
-2
lines changed

6 files changed

+19
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
"@rollup/pluginutils": "^5.0.2",
112112
"local-pkg": "^0.4.3",
113113
"magic-string": "^0.27.0",
114+
"minimatch": "^6.2.0",
114115
"unimport": "^2.2.4",
115116
"unplugin": "^1.0.1"
116117
},

playground/App.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import HelloWorld from './HelloWorld.vue'
33
ElMessage.warning('Test')
44
const foo = useFoo()
5+
const bar = useBar()
56
</script>
67

78
<script lang="ts">
@@ -18,6 +19,7 @@ export default defineComponent({
1819
<template>
1920
<HelloWorld msg="hi" />
2021
<pre>{{ foo }}</pre>
22+
<pre>{{ bar }}</pre>
2123
<pre>{{ FOOBAR }}</pre>
2224
<div v-loading="false">
2325
<ElButton>Hello</ElButton>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function useBar() {
2+
return 'bar from ./composables/nested/'
3+
}

playground/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default defineConfig({
1414
ElementPlusResolver(),
1515
],
1616
dirs: [
17-
'./composables',
17+
'./composables/**',
1818
],
1919
vueTemplate: true,
2020
cache: true,

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/core/unplugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import minimatch from 'minimatch'
2+
import { slash } from '@antfu/utils'
13
import { createUnplugin } from 'unplugin'
24
import type { Options } from '../types'
35
import { createContext } from './ctx'
@@ -25,7 +27,7 @@ export default createUnplugin<Options>((options) => {
2527
},
2628
vite: {
2729
async handleHotUpdate({ file }) {
28-
if (ctx.dirs?.some(dir => file.startsWith(dir)))
30+
if (ctx.dirs?.some(glob => minimatch(slash(file), glob)))
2931
await ctx.scanDirs()
3032
},
3133
async configResolved(config) {

0 commit comments

Comments
 (0)