Skip to content

Layers make nuxt scan too many directories, if the layer has non app related sibling directories #30137

@fabianwohlfart

Description

@fabianwohlfart

Environment


  • Operating System: Darwin
  • Node Version: v22.11.0
  • Nuxt Version: 3.14.1592
  • CLI Version: 3.16.0
  • Nitro Version: 2.10.4
  • Package Manager: npm@10.9.0
  • Builder: -
  • User Config: default
  • Runtime Modules: -
  • Build Modules: -

Reproduction

https://github.com/fabianwohlfart/test__nuxt-layers-slowdown

Describe the bug

I have a layer repo which is used by multiple websites.
It it located as a sibling / parallel to all the other website folders.

If I move this layer repo inside my website layer everything works as expected.

Development
- website-1
- - layer (works)
- website-2
- …

The moment I move it to a parent folder nuxt slows down with the warning

Development
- layer (slow)
- website-1
- website-2
- …

WARN Slow module imports took 10219.28ms to setup.

The moment I move it to my User folder the OS asks me for permission to access certain folders. That's why I assume that siblings are scanned too.

User
- Development
- layer (asks for permissions)
- Dokuments
- Images

As it is not possible for me to give you a reproduction with all my folders.
Yet I simplified it to a setup where we have one folder as a sibling with 250k js files.
If this folder exists it slows down nuxt significantly, but should not, as I don't expect it to be part of my app.

- app
- layer
- should-not-matter
- - [number].js (x 250000)

Without this folder

✔ Vite client built in 25ms
✔ Vite server built in 241ms
✔ Nuxt Nitro server built in 453 ms
ℹ Vite client warmed up in 0ms
ℹ Vite server warmed up in 308ms

With this folder

✔ Vite client built in 20ms                                                                                                  
✔ Vite server built in 172ms                                                                                             
✔ Nuxt Nitro server built in 1717 ms                                                                                 
ℹ Vite client warmed up in 1ms
ℹ Vite server warmed up in 325ms 

Original speed when my layer repo is a sibling of my website repos

 WARN  Slow module imports took 10219.28ms to setup.

ℹ Re-optimizing dependencies because lockfile has changed
✔ Vite client built in 26ms
✔ Vite server built in 348ms
✔ Nuxt Nitro server built in 20094 ms
ℹ Vite client warmed up in 0ms
ℹ Vite server warmed up in 440ms 

Additional context

No response

Logs

Metadata

Metadata

Assignees

Labels

upstreamIssue caused by a dependency or upstream project⚡ performancePerformance degradation or optimization opportunity🐛 bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions