What happens if two modules have the same configKey?

Reading the docs (https://nuxt.com/docs/guide/going-further/modules), it's unclear what happens. This line in the defineNuxtModule section makes it seems like they get automatically merged? "Support defaults and meta.configKey for automatically merging module options"
2 Replies
kapa.ai
kapa.ai4mo ago
Hi @David Stack. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The knowledge sources confirm that when you define a Nuxt module using defineNuxtModule, the meta.configKey property allows users to configure the module via a key in their nuxt.config. The helper will "support defaults and meta.configKey for automatically merging module options"—meaning that user-provided options under that key are merged with the module's defaults before being passed to the module's setup function Module Anatomy. However, the documentation does not explicitly state what happens if two different modules use the same configKey. It is unclear whether their options are merged together, if one overrides the other, or if this causes a conflict or error. The sources only describe the merging of user options with a single module's defaults, not the behavior when multiple modules share the same key. Therefore, based on the available documentation, it is not possible to provide a definitive answer about the behavior when two modules have the same configKey. The knowledge sources do not explicitly mention this scenario. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
kapa.ai
kapa.ai4mo ago
<@983744844226785321> Kapa.ai is still learning and improving, please let me know how I did by reacting below.

Did you find this page helpful?