-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Nested module's 'modules:done' doesn't work like expected #947
Comments
With import { defineNuxtModule, installModule } from '@nuxt/kit';
export default defineNuxtModule({
meta: {
name: 'pinia-installer',
compatibility: {
nuxt: '^2.17.0 || ^3.0.0',
bridge: true,
},
},
// add async
async setup() {
// add await
await installModule('@pinia/nuxt');
},
}); |
It's not clear, because nested module setup in sync. This is why I provided 4 different setups above: similar code without async/await works in Nuxt 3 and should work in Nuxt 2b too, I suppose. I've created another example where nested module have only one hook: https://stackblitz.com/edit/github-dwx287-swerdg?file=nuxt.config.ts,modules%2Fsecondary%2Findex.ts,modules%2Fprimary%2Findex.ts I still think we should align the behaviour with nuxt 3 (To compare: https://stackblitz.com/edit/github-dwx287-vi8c7r?file=nuxt.config.ts,modules%2Fsecondary%2Findex.ts,modules%2Fprimary%2Findex.ts) |
Oh, sorry. I didn't realize there was already a reproduction 🙏 |
It's ok) I didn't go deep inside Nuxt internals to realise the causes of this behaviour. I can suggest to label this issue with |
I made a small research and I can declare this is not fully fixable. Nuxt 3 utilises kit's However, Nuxt 2 relies on its own |
Environment
Reproduction
Nuxt 2b:
Direct module install (working as expected):
https://stackblitz.com/edit/github-dwx287-kpyejp?file=nuxt.config.ts
Sync installModule (broken):
https://stackblitz.com/edit/github-dwx287-eqecsd?file=nuxt.config.ts
Async installModule (working as a little bit unexpected):
https://stackblitz.com/edit/github-dwx287-7mgh1y?file=nuxt.config.ts
Nuxt 3:
Sync installModule (working as expected):
https://stackblitz.com/edit/github-dwx287-ogyhr8?file=nuxt.config.ts
Describe the bug
Current behaviour is not fully aligned with nuxt 3. According to this: https://github.com/vuejs/pinia/blob/1151e67f5eb2f5221273f9a8566e3e5ba9154a1e/packages/nuxt/src/module.ts#L78-L84
Pinia module relies on 'modules:done' hook, which is fired after all modules were installed. @pinia/nuxt's
setup()
is also synchronous.I expect pinia to add needed plugins when calling sync installModule function, as it works in nuxt 3 or in direct usage. I got pinia undefined, because module didn't receive 'modules:done' hook
Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: