Skip to content
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

help: Using onGlobalSetup from custom nuxt module #406

Closed
lewebsimple opened this issue Mar 17, 2021 · 7 comments
Closed

help: Using onGlobalSetup from custom nuxt module #406

lewebsimple opened this issue Mar 17, 2021 · 7 comments
Assignees

Comments

@lewebsimple
Copy link

📚 What are you trying to do? Please describe.
I'm currently developing a Nuxt module for the Villus GraphQL client and when trying to add support for @nuxtjs/composition-api I run into the following error (the call stack indicates this is coming from onGlobalSetup):

Cannot read property 'add' of undefined

🔍 What have you tried?
I tried mashing my keyboard with a wooden spoon to make it work but it didn't work :|

ℹ️ Additional context
The plugin provided by the Nuxt module is transpiled from TypeScript.
@nuxtjs/composition-api is listed both in peerDependencies and devDependencies on the module side of things.
I'm testing the module inside a local project using yarn link nuxt-villus but I also tried releasing the module and using it as a normal dependency to no avail.

@lewebsimple
Copy link
Author

@danielroe Simple reproduction repository here: https://github.com/lewebsimple/nuxt-onglobalsetup-repro

Copy link
Member

@lewebsimple The issue here is that your module's injected plugin is running before the composition API has been initialised. A workaround (before I resolve the core issue) is to move your module to buildModules or moving the composition API to modules - and put composition API last - see https://codesandbox.io/s/vibrant-ganguly-hqv6t?file=/nuxt.config.js

@lewebsimple
Copy link
Author

@danielroe many people have said this before, you are a genius!

@danielroe
Copy link
Member

Should also now be resolved in v0.22.3. Thanks for raising the issue! ❤️

@lewebsimple
Copy link
Author

Getting the following:

Error: Cannot find module '@nuxtjs/composition-api/templates/polyfill.client.js'

@danielroe
Copy link
Member

@lewebsimple Check what Node version you are using.

@danielroe
Copy link
Member

@lewebsimple (Should be fixed in any case with v0.22.4.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants