From cf253a417264c538d6597ac9d98790f6ff0f9c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nathana=C3=ABl=20Labreuil?= Date: Mon, 18 Mar 2024 13:22:11 +0100 Subject: [PATCH] refactor(nuxt): use addBuildPlugin to add DetectComponentUsagePlugin --- packages/nuxt/src/core/nuxt.ts | 3 +-- packages/nuxt/src/core/plugins/detect-component-usage.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index cdfeb48d43d1..42345a814e7a 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -214,8 +214,7 @@ async function initNuxt (nuxt: Nuxt) { detectedComponents } - addVitePlugin(() => DetectComponentUsagePlugin.vite(componentDetectionConfig)) - addWebpackPlugin(() => DetectComponentUsagePlugin.webpack(componentDetectionConfig)) + addBuildPlugin(DetectComponentUsagePlugin(componentDetectionConfig)) nuxt.hook('app:templates', (app) => { // Skip first hook call diff --git a/packages/nuxt/src/core/plugins/detect-component-usage.ts b/packages/nuxt/src/core/plugins/detect-component-usage.ts index adca3f91fc08..d30c02862923 100644 --- a/packages/nuxt/src/core/plugins/detect-component-usage.ts +++ b/packages/nuxt/src/core/plugins/detect-component-usage.ts @@ -7,7 +7,7 @@ interface DetectComponentUsageOptions { detectedComponents: Set } -export const DetectComponentUsagePlugin = createUnplugin((options: DetectComponentUsageOptions) => { +export const DetectComponentUsagePlugin = (options: DetectComponentUsageOptions) => createUnplugin(() => { const importersToExclude = options?.exclude || [] const detectComponentUsagePatterns: Array<[importPattern: string | RegExp, name: string]> = [