Skip to content

Nuxt usage of scanDirExports is extremly slow if Nuxt is used with layers #401

@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 basically want to raise awareness in this repo.

Nuxt uses scanDirExports from unimport here: https://github.com/nuxt/nuxt/blob/main/packages/nuxt/src/imports/module.ts
It seems like that more folders than expected are scanned, if Nuxt layers are used.

I raised an issue in Nuxt with details here:
nuxt/nuxt#30137

The reproduction is a Nuxt app with layers.
If a layer is a sibling of a folder with a lot of files, these slow down the bundling.

Going back to Unimport 3.13.4 solves the issue (tinyglobby??!)

  "devDependencies": {
    "unimport": "3.13.4"
  },
  "overrides": {
    "unimport": "3.13.4"
  }

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions