Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: scanDirs when nested modules in dirs update #319

Merged
merged 1 commit into from
Feb 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
"@rollup/pluginutils": "^5.0.2",
"local-pkg": "^0.4.3",
"magic-string": "^0.27.0",
"minimatch": "^6.2.0",
"unimport": "^2.2.4",
"unplugin": "^1.0.1"
},
Expand Down
2 changes: 2 additions & 0 deletions playground/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import HelloWorld from './HelloWorld.vue'
ElMessage.warning('Test')
const foo = useFoo()
const bar = useBar()
</script>

<script lang="ts">
Expand All @@ -18,6 +19,7 @@ export default defineComponent({
<template>
<HelloWorld msg="hi" />
<pre>{{ foo }}</pre>
<pre>{{ bar }}</pre>
<pre>{{ FOOBAR }}</pre>
<div v-loading="false">
<ElButton>Hello</ElButton>
Expand Down
3 changes: 3 additions & 0 deletions playground/composables/nested/bar.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function useBar() {
return 'bar from ./composables/nested/'
}
2 changes: 1 addition & 1 deletion playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
ElementPlusResolver(),
],
dirs: [
'./composables',
'./composables/**',
],
vueTemplate: true,
cache: true,
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/core/unplugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import minimatch from 'minimatch'
import { slash } from '@antfu/utils'
import { createUnplugin } from 'unplugin'
import type { Options } from '../types'
import { createContext } from './ctx'
Expand All @@ -24,7 +26,7 @@ export default createUnplugin<Options>((options) => {
},
vite: {
async handleHotUpdate({ file }) {
if (ctx.dirs?.some(dir => file.startsWith(dir)))
if (ctx.dirs?.some(glob => minimatch(slash(file), glob)))
await ctx.scanDirs()
},
async configResolved(config) {
Expand Down