Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

feat: composables import path #10084

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions packages/nuxt/src/imports/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ 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'))
ineshbose marked this conversation as resolved.
Show resolved Hide resolved
for (const dir of (layer.config.imports?.dirs ?? [])) {
if (!dir) {
Expand Down