mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): don't scan component dirs when enabled
is false
(#26906)
This commit is contained in:
parent
1a91b120ee
commit
9f9e3e6917
@ -26,6 +26,9 @@ export async function scanComponents (dirs: ComponentsDir[], srcDir: string): Pr
|
|||||||
const scannedPaths: string[] = []
|
const scannedPaths: string[] = []
|
||||||
|
|
||||||
for (const dir of dirs) {
|
for (const dir of dirs) {
|
||||||
|
if (dir.enabled === false) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// A map from resolved path to component name (used for making duplicate warning message)
|
// A map from resolved path to component name (used for making duplicate warning message)
|
||||||
const resolvedNames = new Map<string, string>()
|
const resolvedNames = new Map<string, string>()
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ const dirs: ComponentsDir[] = [
|
|||||||
transpile: false,
|
transpile: false,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
const dirUnable = dirs.map((d) => { return { ...d, enabled: false } })
|
||||||
const expectedComponents = [
|
const expectedComponents = [
|
||||||
{
|
{
|
||||||
chunkName: 'components/isle-server',
|
chunkName: 'components/isle-server',
|
||||||
@ -243,3 +243,8 @@ it('components:scanComponents', async () => {
|
|||||||
}
|
}
|
||||||
expect(scannedComponents).deep.eq(expectedComponents)
|
expect(scannedComponents).deep.eq(expectedComponents)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('components:scanComponents:unable', async () => {
|
||||||
|
const scannedComponents = await scanComponents(dirUnable, srcDir)
|
||||||
|
expect(scannedComponents).deep.eq([])
|
||||||
|
})
|
||||||
|
@ -53,7 +53,7 @@ export interface ScanDir {
|
|||||||
*/
|
*/
|
||||||
pathPrefix?: boolean
|
pathPrefix?: boolean
|
||||||
/**
|
/**
|
||||||
* Ignore scanning this directory if set to `true`
|
* Ignore scanning this directory if set to `false`
|
||||||
*/
|
*/
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user