vuetifyjs / nuxt-module

Zero-config Nuxt Module for Vuetify
https://nuxt.vuetifyjs.com/
MIT License
208 stars 21 forks source link

vuetifyImportPlugin ignores excluded components/directives from vuetifyModule option #236

Closed AndreyYolkin closed 2 months ago

AndreyYolkin commented 2 months ago

Similar to https://github.com/userquin/vuetify-nuxt-module/issues/226, but with further investigation

Version

vuetify: 3.6.11 nuxt-vuetify-module: 0.14.1 nuxt: 3.12.3

Intro

We have VuetifyOptions with directives and components fields

 { /**
   * @default false
   */
  directives?: Directives,

  /**
   * @default false
   */
  components?: Components
}

However, selected options does't make an effect on vite-plugin, as it still autoimports the components and directives

The reason is https://github.com/userquin/vuetify-nuxt-module/blob/be68923fa4a46c45bf2ade1f0070319b84ceb608/src/utils/configure-vite.ts#L68 is always an empty object

Case

Part of page: image

Default output:

image

When I pass { autoImport: { ignore: ['Tooltip'] } as argument (+ extra log for options):

image

I expect that options provided in directives and components will effect on autoImports list

userquin commented 2 months ago

I'll keep current behavior, the linked PR no makes sense, check https://github.com/userquin/vuetify-nuxt-module/pull/239#issuecomment-2223534574

userquin commented 2 months ago

I'm going to update the docs... auto import is better than changing the configuration or dealing with errors.

AndreyYolkin commented 2 months ago

I still doubt, because if I register directive via nuxtApp.vueApp.directive() with VTooltip name it will be overridden. Probably we can address the issue to the vuetify vite plugin itself, but as a compromise i would suggest adding another option inside moduleConfig to fine-tune the vite plugin

userquin commented 2 months ago

Why? If you use some directive/component, the plugin will auto import them for you, that's the expected behavior.

Why do you need to register the directive if the plugin will do it for you? We're using Vite (Rollup), no dead code and no code duplication.

AndreyYolkin commented 2 months ago

I don't want to use the tooltip provided by vuetify, but want to have own directive with the same name (v-tooltip is very common). The only way for now is to write custom autoimport rule to resolve cutom directive before it's done by vuetify

userquin commented 2 months ago

@AndreyYolkin that's another problem, cannot use x-tooltip for example?

userquin commented 2 months ago

I'll try to add ignore directives option, the option will be provided directly to the vuetify plugin