dargmuesli / nuxt-cookie-control

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

export statement in CookieControl component's <script setup> #146

Open Willo0ow opened 1 year ago

Willo0ow commented 1 year ago

Environment

Reproduction

The error doesn't show in reproduction template, but it seems obvious and the solution is even in vue docs.

Describe the bug

There is an export statement inside script setup tag in CookieControl.vue which causes app to crash. It's this block:

export interface Props {
  locale?: Locale
}

The export should be in a separate script tag (like vue documentation suggests), or in somewhere in types.

Additional context

No response

Logs

[plugin:vite:vue] [@vue/compiler-sfc] <script setup> cannot contain ES module exports. If you are using a previous version of <script setup>, please consult the updated RFC at https://github.com/vuejs/rfcs/pull/227.

/node_modules/@dargmuesli/nuxt-cookie-control/dist/runtime/components/CookieControl.vue
194|  import { getAllCookieIdsString, getCookieId, getCookieIds, removeCookie, resolveTranslatable } from '../methods'
195|  import setCssVariables from '#cookie-control/set-vars'
196|  import { useCookieControl, useCookie } from '#imports'
   |                                                         ^
197|  export 
   |  ^^^^^^^
198|  const props = withDefaults(defineProps<Props>(), {
   |  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
199|    locale: 'en',
   |  ^^^^^^^^^^^^^^^
200|  })
dargmuesli commented 1 year ago

The error doesn't show in reproduction template, but it seems obvious and the solution is even in vue docs.

The error should show in a minimal reproduction so that I can figure out the actual root cause. I'm wondering why noone else reported this issue yet, for example.

The export should be in a separate script tag (like vue documentation suggests), or in somewhere in types.

Actually I've taken the export from Vue's documentation: https://vuejs.org/api/sfc-script-setup.html#default-props-values-when-using-type-declaration

Willo0ow commented 1 year ago

I guess that's the origin of the documentation that you used - https://github.com/vuejs/rfcs/blob/master/active-rfcs/0040-script-setup.md#default-props-values-when-using-type-declaration - and there is no export.

As vue documentation states "A normal Githubissues.

  • Githubissues is a development platform for aggregating issues.