Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
skip filter when no mode availabl and atomic context update
  • Loading branch information
pi0 committed Jul 27, 2022
commit df7c5ddcb8d68c5d0a93fdae85433be1f2aba739
9 changes: 6 additions & 3 deletions packages/nuxt/src/components/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export default defineNuxtModule<ComponentsOptions>({
}

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) => {
Expand Down Expand Up @@ -125,8 +127,9 @@ export default defineNuxtModule<ComponentsOptions>({

// 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 }) => {
Expand Down