Nuxt module improvement suggestions
See original GitHub issueThanks, @justin-schroeder for creating a nice Nuxt module. I’ve spotted few items that could be improved regarding config loading.
Config files should be resolved from rootDir
rather than srcDir
. You can use resolvePath
utility from @nuxt/kit
to easily resolve it, respecting supported extensions. example
It would be so nice to reduce dependency on templating as much as possible. this error for instance could be directly thrown in the module instead of delegation to runtime and defaultConfig
can be set as default value for configFile
in module.ts.
Config could also be directly imported in module using requireModule
utility and passed as options object. This not only reduces depending on templating, but also improves build time by avoid transpiler and gives more possibilities to validate config in build time or extend it with other modules.
Would be also nice to also add compatibility
field in meta
field to indicate only Nuxt ^3.0.0 with vue3 is supported.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thanks for the feedback @pi0! We’ll make these changes soon.
@pi0 — I refactored most of the module in this most recent push — including using
resolvePath
and reducing the templating significantly. It now only has 2 simple template outputs. Honestly I would love to get rid of the template all together, but as far as I can tell there is no way to pass functions and other non serializable data to a nuxt plugin from a nuxt module usingaddPlugin
(or is there?).FormKit uses lots of user-defined functions in its configuration (like plugin functions for example) — so as far as I know, I still need to use the template to “manually” write those
import
statements (is my assumption true?)