Mohamed-Kaizen/unplugin-svelte-components

In an existing SvelteKit project, is it possible to prevent 'unplugin-svelte-components' from automatically adding imports for declared components? Removing import statements in an existing project can be quite cumbersome.

muweigg opened this issue · 3 comments

In an existing SvelteKit project, is it possible to prevent 'unplugin-svelte-components' from automatically adding imports for declared components? Removing import statements in an existing project can be quite cumbersome.

Hi @muweigg, sorry for the delay.

Well currently the only way you could achieve that is by adding <!-- unplugin-svelte-components disabled --> inside the file, with that unplugin-svelte-components will ignore that file

<!-- unplugin-svelte-components disabled -->
<script>
import Counter from "../../Shared/Counter.svelte"
</script>

<Counter />

If you have updated to version 0.2.9 or above, you can ignore the above solution. This plugin will now automatically ignore pre-defined components in imports declarations.

I am closing this issue. Please feel free to reopen it if you are still experiencing problems.

Thank you for your work.
I have upgraded to 0.2.9, but I am still encountering the same error.

Log:
[plugin:vite-plugin-svelte] /src/routes/(default)/+page.svelte:5:8 Identifier 'Link' has already been declared
/Users/mui/Projects/svelte-template/src/routes/(default)/+page.svelte:2:1
3 | import Notice from "/Users/mui/Projects/svelte-template/src/lib/components/common/Notice.svelte"
4 | import Link from "/Users/mui/Projects/svelte-template/src/lib/components/common/Link.svelte"
5 | import Link from '$lib/components/common/Link.svelte'
^
6 | import Notice from '$lib/components/common/Notice.svelte'
7 | import {lazy} from '$lib/actions/lazy.js'