From df7c5ddcb8d68c5d0a93fdae85433be1f2aba739 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 27 Jul 2022 14:57:37 +0200 Subject: [PATCH] skip filter when no mode availabl and atomic context update --- packages/nuxt/src/components/module.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/nuxt/src/components/module.ts b/packages/nuxt/src/components/module.ts index 845d894fdc5..45b4921d3fc 100644 --- a/packages/nuxt/src/components/module.ts +++ b/packages/nuxt/src/components/module.ts @@ -32,7 +32,9 @@ export default defineNuxtModule({ } const getComponents: getComponentsT = (mode) => { - return context.components.filter(c => c.mode === mode || c.mode === 'all') + return (mode && mode !== 'all') + ? context.components.filter(c => c.mode === mode || c.mode === 'all') + : context.components } const normalizeDirs = (dir: any, cwd: string) => { @@ -125,8 +127,9 @@ export default defineNuxtModule({ // Scan components and add to plugin nuxt.hook('app:templates', async () => { - context.components = await scanComponents(componentDirs, nuxt.options.srcDir!) - await nuxt.callHook('components:extend', context.components) + const newComponents = await scanComponents(componentDirs, nuxt.options.srcDir!) + await nuxt.callHook('components:extend', newComponents) + context.components = newComponents }) nuxt.hook('prepare:types', ({ references }) => {