fix(nuxt): don't scan component dirs when enabled is false (#26906)

This commit is contained in:
rgehbt 2024-04-23 20:19:12 +08:00 committed by GitHub
parent 1a91b120ee
commit 9f9e3e6917
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 2 deletions

View File

@ -26,6 +26,9 @@ export async function scanComponents (dirs: ComponentsDir[], srcDir: string): Pr
const scannedPaths: string[] = []
for (const dir of dirs) {
if (dir.enabled === false) {
continue
}
// A map from resolved path to component name (used for making duplicate warning message)
const resolvedNames = new Map<string, string>()

View File

@ -86,7 +86,7 @@ const dirs: ComponentsDir[] = [
transpile: false,
},
]
const dirUnable = dirs.map((d) => { return { ...d, enabled: false } })
const expectedComponents = [
{
chunkName: 'components/isle-server',
@ -243,3 +243,8 @@ it('components:scanComponents', async () => {
}
expect(scannedComponents).deep.eq(expectedComponents)
})
it('components:scanComponents:unable', async () => {
const scannedComponents = await scanComponents(dirUnable, srcDir)
expect(scannedComponents).deep.eq([])
})

View File

@ -53,7 +53,7 @@ export interface ScanDir {
*/
pathPrefix?: boolean
/**
* Ignore scanning this directory if set to `true`
* Ignore scanning this directory if set to `false`
*/
enabled?: boolean
/**