unplugin / unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup
MIT License
3.21k stars 195 forks source link

Feature: Allow excluding from presets #273

Open Bobakanoosh opened 2 years ago

Bobakanoosh commented 2 years ago

Clear and concise description of the problem

I use the @vueuse/core preset. I have a useFileDialog function that comes from another library (with a preset).

Because @vueuse/core added useFileDialog recently, I now get this error: [vite] [auto-import] identifier useFileDialog already defined with @vueuse/core

Suggested solution

Allow some exclusion syntax in the vite plugin like:

exclude: ["@vueuse/core", ["useFileDialog"]]

Alternative

If I could use this syntax:

'@vueuse/core': [
        ['useFetch', 'useMyFetch'], // import { useFetch as useMyFetch } from '@vueuse/core',
],

then I could just rename the one coming from @vueuse/core.

However, It's not preferable to do this because then I lose all of the other imports that the @vueuse/core preset adds automatically.

Additional context

No response

Validations

azaleta commented 2 years ago

since you are using preset, it can be override. https://github.com/antfu/unplugin-auto-import/blob/main/src/types.ts#L121