diff --git a/packages/nuxt/src/imports/module.ts b/packages/nuxt/src/imports/module.ts index 1b9e698203..94933ca266 100644 --- a/packages/nuxt/src/imports/module.ts +++ b/packages/nuxt/src/imports/module.ts @@ -122,7 +122,25 @@ export default defineNuxtModule>({ const scannedImports = await scanDirExports(composablesDirs, { fileFilter: file => !isIgnored(file), }) + + const presetMap = new Map() + + 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)