tabler / tabler-icons

A set of over 5500 free MIT-licensed high-quality SVG icons for you to use in your web projects.
https://tabler.io/icons
MIT License
18.03k stars 899 forks source link

@tabler/icons-svelte, individual import of icons, dead code elimination, typescript error #938

Closed ttmx closed 9 months ago

ttmx commented 9 months ago

Hi, since starting to use tabler icons for my svelte project my build times have gone from 2-3 seconds to 40 seconds, this happens because svelte has to bundle all the icons when we import them in the normal way ( import { IconBattery1} from '@tabler/icons-svelte';)

I wish to be able to import each Icon individually so that my build times go back to what they were before having to bundle 4000 icons each time. This is currently doable! import IconBattery from '@tabler/icons-svelte/dist/svelte/icons/IconBattery1.svelte';

The issue here pertains to typescript types: when importing items that way, I get "Could not find a declaration file for module '@tabler/icons-svelte/dist/svelte/icons/IconBattery1.svelte'. '.../app/node_modules/@tabler/icons-svelte/dist/svelte/icons/IconBattery1.svelte' implicitly has an 'any' type." This could be fixed by also generating a type declaration file for each file.

Is there another way to do this I'm not seeing?

Thank you for the great icons!

BG-Software-BG commented 9 months ago

Duplicate of #669