馃摎 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.
@danielroe Simple reproduction repository here: https://github.com/lewebsimple/nuxt-onglobalsetup-repro
@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
@danielroe many people have said this before, you are a genius!
Should also now be resolved in v0.22.3. Thanks for raising the issue! 鉂わ笍
Getting the following:
Error: Cannot find module '@nuxtjs/composition-api/templates/polyfill.client.js'
@lewebsimple Check what Node version you are using.
@lewebsimple (Should be fixed in any case with v0.22.4.)