unjs / nitro

Next Generation Server Toolkit. Create web servers with everything you need and deploy them wherever you prefer.
https://nitro.unjs.io
MIT License
5.89k stars 496 forks source link

Nitro `scanModules` returns every files #2680

Open Barbapapazes opened 1 month ago

Barbapapazes commented 1 month ago

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