Feature Request: Allow external modules to provide colada options #415
Replies: 3 comments
-
|
What about exposing the internal function that injects options so they can be overwritten? |
Beta Was this translation helpful? Give feedback.
-
|
I sent a PR, but I'm not entirely sure. |
Beta Was this translation helpful? Give feedback.
-
|
Moving this to a discussion to gather more feedback. All 3 options presented are not possible because they mix module and runtime code. It's why there is a colada.options.ts file in the first place. I'm not completely sure of the doability of this in Nuxt and Nuxt layers, without over complicating things. It's worth noting that the options need to be set before installing the Pinia Colada plugin for Pinia Colada's plugin to work |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Problem
Currently,
@pinia/colada-nuxtonly loadscolada.options.tsfrom the consuming project's root directory:This makes it impossible for Nuxt modules/layers to provide default Pinia Colada configurations (like global error handling) to consuming projects.
Use Case
I'm building a shared Nuxt module (
nuxt-shared) that provides:I want to provide default
PiniaColadaQueryHooksPluginconfiguration withonSuccessandonErrorhooks, but currently:colada.options.tsin every projectProposed Solution
Allow modules to register colada options via Nuxt module hooks:
Option 1: Module Hook
Option 2: Module Config
Option 3: Multiple Config Files
Benefits
Workaround (Current)
Currently, I'm forced to:
app.use(PiniaColada, options)This bypasses
@pinia/colada-nuxt's built-in setup and SSR handling.References
@nuxtjs/i18n: Supports both config file and inline optionspinia-colada/nuxt/src/module.ts
Lines 24 to 28 in d063471
Would love to hear thoughts on this! Happy to contribute a PR if there's interest. 🙏
Beta Was this translation helpful? Give feedback.
All reactions