diff --git a/packages/nuxt-module/src/module.ts b/packages/nuxt-module/src/module.ts index 9da1c2b79..c372b5d7f 100644 --- a/packages/nuxt-module/src/module.ts +++ b/packages/nuxt-module/src/module.ts @@ -1,9 +1,6 @@ import { addPlugin, addPluginTemplate, addTemplate, createResolver, defineNuxtModule } from '@nuxt/kit'; -import { isNotEmpty } from '@primeuix/utils'; -import { PrimeVueResolver } from '@primevue/auto-import-resolver'; import type { MetaType } from '@primevue/metadata'; import { normalize } from 'pathe'; -import Components from 'unplugin-vue-components/nuxt'; import { register } from './register'; import type { ModuleOptions } from './types'; @@ -62,31 +59,6 @@ export default defineNuxtModule({ let registeredStyles: MetaType[] = registered.styles; - if (autoImport) { - const dts = isNotEmpty(moduleOptions.components?.prefix) || isNotEmpty(moduleOptions.directives?.prefix); - - Components( - { - dts, - resolvers: [ - PrimeVueResolver({ - components: moduleOptions.components, - directives: moduleOptions.directives, - resolve: (meta: MetaType) => { - registeredStyles.push({ - ...meta, - name: `${meta.name}Style`, - as: `${meta.as}Style`, - from: `${meta.from}/style` - }); - } - }) - ] - }, - nuxt - ); - } - const styleContent = () => { if (!loadStyles) return `export const styles = [], stylesToTop = [], themes = [];`; @@ -145,7 +117,7 @@ export { styles, stylesToTop, themes }; import { defineNuxtPlugin, useRuntimeConfig } from '#imports'; ${registered.config.map((config: MetaType) => `import ${config.as} from '${config.from}';`).join('\n')} ${registered.services.map((service: MetaType) => `import ${service.as} from '${service.from}';`).join('\n')} -${!autoImport && registered.directives.map((directive: MetaType) => `import ${directive.as} from '${directive.from}';`).join('\n')} +${autoImport && registered.directives.map((directive: MetaType) => `import ${directive.as} from '${directive.from}';`).join('\n')} ${importPT ? `import ${importPT.as} from '${normalize(importPT.from)}';\n` : ''} ${hasTheme && importTheme ? `import ${importTheme.as} from '${normalize(importTheme.from)}';\n` : ''} @@ -158,7 +130,7 @@ export default defineNuxtPlugin(({ vueApp }) => { usePrimeVue && vueApp.use(PrimeVue, { ...options, ...pt, ...theme }); ${registered.services.map((service: MetaType) => `vueApp.use(${service.as});`).join('\n')} - ${!autoImport && registered.directives.map((directive: MetaType) => `vueApp.directive('${directive.name}', ${directive.as});`).join('\n')} + ${autoImport && registered.directives.map((directive: MetaType) => `vueApp.directive('${directive.name}', ${directive.as});`).join('\n')} }); `; } diff --git a/packages/nuxt-module/src/register.ts b/packages/nuxt-module/src/register.ts index 2f5e512e9..e4301831a 100644 --- a/packages/nuxt-module/src/register.ts +++ b/packages/nuxt-module/src/register.ts @@ -45,7 +45,7 @@ function registerComponents(resolvePath: any, moduleOptions: ModuleOptions) { global: true }; - !moduleOptions.autoImport && addComponent(opt); + moduleOptions.autoImport && addComponent(opt); return { ..._item, @@ -82,7 +82,7 @@ function registerComposables(resolvePath: any, moduleOptions: ModuleOptions) { from: resolvePath({ name, as: item.as, from: item.from, type: 'composable' }) }; - addImports(opt); + moduleOptions.autoImport && addImports(opt); return opt; }); @@ -111,7 +111,7 @@ function registerStyles(resolvePath: any, registered: any, moduleOptions: Module } ]; - if (!moduleOptions.autoImport && !options?.unstyled) { + if (moduleOptions.autoImport && !options?.unstyled) { if (isNotEmpty(registered?.components)) { styles.push({ name: 'BaseComponentStyle',