mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
docs: more clarity on auto imports
This commit is contained in:
parent
bbf481fb26
commit
7b69dc9463
@ -12,7 +12,7 @@ The `shared/` directory is available in Nuxt v3.14+.
|
|||||||
::
|
::
|
||||||
|
|
||||||
::important
|
::important
|
||||||
Code in the shared directory cannot import any Vue or nitro code.
|
Code in the `shared/` directory cannot import any Vue or Nitro code.
|
||||||
::
|
::
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
@ -59,7 +59,13 @@ export default defineEventHandler((event) => {
|
|||||||
|
|
||||||
## Auto Imports
|
## Auto Imports
|
||||||
|
|
||||||
Only files in the `shared/utils/` and `shared/types/` directories will be auto-imported. Files nested in directories within `shared/utils/` or `shared/types/` will not be auto-imported.
|
Only files in the `shared/utils/` and `shared/types/` directories will be auto-imported. Files nested within subdirectories of these directories will not be auto-imported.
|
||||||
|
|
||||||
|
::tip
|
||||||
|
The way `shared/utils` and `shared/types` auto-imports work and are scanned is identical to the [`composables/`](/docs/guide/directory-structure/composables) and [`utils/`](/docs/guide/directory-structure/utils) directories.
|
||||||
|
::
|
||||||
|
|
||||||
|
:read-more{to="/docs/guide/directory-structure/composables#how-files-are-scanned"}
|
||||||
|
|
||||||
```bash [Directory Structure]
|
```bash [Directory Structure]
|
||||||
-| shared/
|
-| shared/
|
||||||
@ -74,7 +80,7 @@ Only files in the `shared/utils/` and `shared/types/` directories will be auto-i
|
|||||||
-----| bar.d.ts # Auto-imported
|
-----| bar.d.ts # Auto-imported
|
||||||
```
|
```
|
||||||
|
|
||||||
Any other files you create in the shared folder must be manually imported using the `#shared` alias (automatically configured by Nuxt):
|
Any other files you create in the `shared/` folder must be manually imported using the `#shared` alias (automatically configured by Nuxt):
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
// For files directly in the shared directory
|
// For files directly in the shared directory
|
||||||
|
Loading…
Reference in New Issue
Block a user