2022-02-03 11:31:15 +00:00
|
|
|
import type { AutoImport } from '../../schema/src/types/imports'
|
|
|
|
import { useNuxt } from './context'
|
|
|
|
import { assertNuxtCompatibility } from './compatibility'
|
|
|
|
|
|
|
|
export function addAutoImport (_autoImports: AutoImport | AutoImport[]) {
|
|
|
|
assertNuxtCompatibility({ bridge: true })
|
|
|
|
|
|
|
|
useNuxt().hook('autoImports:extend', (autoImports: AutoImport[]) => {
|
|
|
|
for (const composable of (Array.isArray(_autoImports) ? _autoImports : [_autoImports])) {
|
|
|
|
autoImports.push(composable)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-02-03 18:02:55 +00:00
|
|
|
export function addAutoImportDir (_autoImportDirs: string | string[]) {
|
2022-02-03 11:31:15 +00:00
|
|
|
assertNuxtCompatibility({ bridge: true })
|
|
|
|
|
2022-02-03 18:02:55 +00:00
|
|
|
useNuxt().hook('autoImports:dirs', (autoImportDirs: string[]) => {
|
2022-02-03 11:31:15 +00:00
|
|
|
for (const dir of (Array.isArray(_autoImportDirs) ? _autoImportDirs : [_autoImportDirs])) {
|
|
|
|
autoImportDirs.push(dir)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|