New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(nuxt): auto-register modules in ~/modules
#19394
Conversation
Β Open in CodeSandbox Web Editor | VS Code | VS Code Insiders |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice idea! As a complement we might also introduce nuxt/kit
since users have only nuxt dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome feature idea!
I can easily see using it in my projects :)
I would like to update the behaviour to scanning Also, modules tends to include files so a directory is better for separation of concerns. This way it's easier to extract when then want to publish their package to the Nuxt community |
Well actually I would prefer Why did we decide to go with |
For module builder package template, top-level BTW for local scanning, |
I will try to keep it simple to Explaining to rename to I guess we could also support top-level file for very simple modules? |
I'm okay with either convention in local dir. Each has cons and pros. |
Co-authored-by: pooya parsa <pyapar@gmail.com>
I'm against this idea. Although auto registering modules inside |
I fully agree, and because of that, when you manually specify them in modules[] in configuration, they will be kept in your custom order. |
@HigherOrderLogic well you can do: modules/
1.c-module/
2.d-module/ Similar to what we have in Nuxt Content for ordering links in the generated navigation. |
Might be worth adding to the docs? |
How to ignore local modules that I don't want to be automatically registered |
You can use a different directory, nest them in a folder under |
Regarding ordering, from the PR I understand that local modules load after
We can also add functionality for prepending filename with
The thing (for me at least) was to have consistent file-scanning in Nuxt (like #18418) because when the behaviour is different, it tends to confuse (me at least); though this PR has been long-released now. π (Sorry for continuing the thread!) |
I think we already respect current And if local modules are added to |
π Linked issue
β Type of change
π Description
This adds support for scanning
~/modules
and automatically registering any local modules there. The directory is configurable viadir.modules
and supports local modules in layers.It also adds support for automatically restarting Nuxt when these local module files are updated, resolving #12350. Note that at the moment, they are cached and a soft restart does not load an updated module - we should likely investigate the cause of this so we do not need a hard restart in this case.
π Checklist