color-mode v2.1.1 does not support custom `globalName`
Version
@nuxtjs/color-mode: 2.1.1 nuxt: v2.15.8
Steps to reproduce
After connecting via
buildModules: ['@nuxtjs/color-mode']
Then I open any page
What is actually happening?
client.js?116f:103 TypeError: window.onNuxtReady is not a function at eval (plugin.client.js?4766:85:1) at _callee2$ (index.js?fcc8:97:1) at tryCatch (runtime.js?96cf:63:1) at Generator.invoke [as _invoke] (runtime.js?96cf:294:1) at Generator.eval [as next] (runtime.js?96cf:119:1) at asyncGeneratorStep (asyncToGenerator.js?1da1:3:1) at _next (asyncToGenerator.js?1da1:25:1)
Would you provide a reproduction via https://template.nuxtjs.org/? 🙏
I experiment a little. As a result, i managed to get rid of this error.
The thing is that I used the globalName variable in my Nuxt config. When I removed it, the error disappeared. Not sure, but maybe this is a bug. At least this worked for me.
I'm talking about this in nuxt.config.js:
export default { globalName: 'ProjectName', }
Neither Bridge nor Nuxt 3 support a custom globalName, and the last version of this module did not either:
https://github.com/nuxt-community/color-mode-module/blob/139b0e68fced030db9035839ffdfd2fa1d80c117/lib/templates/plugin.client.js#L85-L90
Neither Bridge nor Nuxt 3 support a custom
globalName, and the last version of this module did not either:https://github.com/nuxt-community/color-mode-module/blob/139b0e68fced030db9035839ffdfd2fa1d80c117/lib/templates/plugin.client.js#L85-L90
While this is not a very popular use case, but it might be worth writing about on the setup page.
As a workaround, you could set globals.readyCallback to () => 'onNuxtReady' without touching the rest of your code: https://nuxtjs.org/docs/configuration-glossary/configuration-global-name#the-globals-property