dargmuesli / nuxt-cookie-control

A highly configurable cookie banner for Nuxt.
MIT License
244 stars 45 forks source link

Support package usage with Vite #149

Closed strife-cloud closed 1 year ago

strife-cloud commented 1 year ago

Describe the feature

Hey, I'm trying to use this package with nuxt3 but it feels like it doesn't work whenever I'm trying to do this

// nuxt.config.js

modules: [
  '@dargmuesli/nuxt-cookie-control'
],
cookieControl: {
  // typed module options
}

the typing is not recognized in this case

but in this case, it's recognized // nuxt.config.js

modules: [
  ['@dargmuesli/nuxt-cookie-control', {
    // untyped module options
  }]
]

and in default.vue (my default layout)

<template>
  <CookieControl locale="en" />
</template>

<script setup lang="ts">
const {
  cookiesEnabled,
  cookiesEnabledIds,
  isConsentGiven,
  isModalActive,
  moduleOptions,
} = useCookieControl()
</script>

the component and the composable is not recognized maybe I'm missing some import ?

Here's my package.json

{
  "private": true,
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "generate": "nuxt generate",
    "preview": "nuxt preview"
  },
  "devDependencies": {
    "@dargmuesli/nuxt-cookie-control": "^6.4.5",
    "@nuxt/content": "^2.6.0",
    "@nuxt/image-edge": "^1.0.0-rc.1-28143901.afe4120",
    "@nuxtjs/tailwindcss": "^6.7.2",
    "@tailwindcss/typography": "^0.5.9",
    "@types/rss": "^0.0.30",
    "nuxt-simple-robots": "^3.0.2",
    "nuxt-simple-sitemap": "^3.0.9",
    "prettier": "^2.8.8",
    "rss": "^1.2.2",
    "vue-disqus": "^5.1.0",
    "vue-social-sharing": "^4.0.0-alpha4"
  },
  "dependencies": {
    "@gtm-support/vue-gtm": "^2.2.0",
    "@headlessui/vue": "^1.7.14",
    "@heroicons/vue": "^2.0.18",
    "nuxt": "^3.6.2"
  }
}

I'm using with vite not webback node: 16.14.0

Any suggestion? Maybe I'm missing something

Additional information

Final checks

dargmuesli commented 1 year ago

Hey, thank you for creating this issue. To verify that there is an actual issue, please use stackblitz.com to recreate the project as you're describing it here so it's done once and not by everyone who tries to debug the issue separately.

Regarding your issue: make sure to run a nuxi upgrade (or delete the lockfile and node_modules and reinstall all dependencies).

strife-cloud commented 1 year ago

no worry, I didn't knew but I discover nuxt prepare who regenerate typescript file so the module is now discovered We can close the issue

dargmuesli commented 1 year ago

Thanks for letting us know!