nitro icon indicating copy to clipboard operation
nitro copied to clipboard

Nitro `scanModules` returns every files

Open Barbapapazes opened this issue 6 months ago • 0 comments

Environment

nitropack-nightly@3.0.0-beta-28665895.e727afda-nitro-nightly-mirror

Reproduction

  1. Create the dir modules
  2. Add the file log/index.ts and log/runtime/routes/log.ts
  3. Inspect the return of https://github.com/unjs/nitro/blob/d20ffcbd16fc4003b774445e1a01e698c2bb078a/src/core/scan.ts#L44

Describe the bug

You'll see that the return will have both the index.ts file which define the module and the log.ts file which define an event handler. This makes the local modules system unusable.

Like Nuxt, this could be nice to only scan two patters (https://nuxt.com/docs/guide/directory-structure/modules#:~:text=The%20auto%2Dregistered,modules/*.ts)

The auto-registered files patterns are:

  • modules/*/index.ts
  • modules/*.ts

Additional context

No response

Logs

No response

Barbapapazes avatar Aug 22 '24 14:08 Barbapapazes