Compare commits

...

5 Commits

Author SHA1 Message Date
OrbisK
6918ea0d72
Merge 38bfe2a6bc into 9bf8465806 2024-11-19 23:30:27 +02:00
Robin Kehl
38bfe2a6bc chore: update map type 2024-11-19 16:44:37 +01:00
Robin Kehl
06add6e7fb chore: clarify duplicate import message 2024-11-19 15:48:06 +01:00
Robin Kehl
6aa5d12652 chore: clarify duplicate import message 2024-11-19 15:42:10 +01:00
Robin Kehl
05403910ac feat: add warning if some preset import is overridden 2024-11-19 15:25:08 +01:00

View File

@ -122,7 +122,25 @@ export default defineNuxtModule<Partial<ImportsOptions>>({
const scannedImports = await scanDirExports(composablesDirs, {
fileFilter: file => !isIgnored(file),
})
const presetMap = new Map<string, string>()
for (const preset of presets) {
preset.imports = preset.imports ?? []
for (const i of preset.imports) {
presetMap.set(i, preset.from)
}
presetMap.set(preset.as, preset.from)
}
for (const i of scannedImports) {
const name = i.as ?? i.name
const preset = presetMap.get(name)
if (preset) {
console.warn(`[imports] "${name}" is already defined and auto imported from "${preset ?? 'unknown preset'}" within nuxt itself. Please consider renaming "${name}" at ${i.from}.`)
}
i.priority = i.priority || priorities.find(([dir]) => i.from.startsWith(dir))?.[1]
}
imports.push(...scannedImports)