Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,11 @@ composables
| - index.ts // scanned
| - useFoo.ts // scanned
| - nested
| --- index.ts // scanned
| --- utils.ts // not scanned
```

Only `composables/index.ts` and `composables/useFoo.ts` would be searched for imports.
Only `composables/index.ts`, `composables/useFoo.ts` and `composables/nested/index.ts` would be searched for imports.

To get auto imports working for nested modules, you could either re-export them (recommended) or configure the scanner to include nested directories:

Expand Down
2 changes: 2 additions & 0 deletions packages/nuxt/src/imports/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
let composablesDirs: string[] = []
for (const layer of nuxt.options._layers) {
composablesDirs.push(resolve(layer.config.srcDir, 'composables'))
composablesDirs.push(resolve(layer.config.srcDir, 'composables/*/index.{ts,js,mjs,mts}'))
composablesDirs.push(resolve(layer.config.srcDir, 'utils'))
composablesDirs.push(resolve(layer.config.srcDir, 'utils/*/index.{ts,js,mjs,mts}'))
for (const dir of (layer.config.imports?.dirs ?? [])) {
if (!dir) {
continue
Expand Down