tabler-icons: icons-svelte builds ALL icons, even ones not used
I’m using @tabler/icons-svelte in my sveltekit project and astro project. When building, it logs the following:
building client
transforming (8344) ../../sveltekit/fulldev-ui/node_modules/@tabler/icons-svelte/dist/svelte/icons/IconWand.svelte
The above is 1 moment in the build. It takes about 30-60 seconds and goed over every icon
Is this supposed to happen?
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 15
- Comments: 35 (5 by maintainers)
Commits related to this issue
- Remove `@tabler/icons-svelte` due https://github.com/tabler/tabler-icons/issues/669 issue — committed to LWJerri/lwjerri.dev by LWJerri 3 years ago
- Client: tablerのアセットのビルドに異常に時間がかかる問題を回避 related: https://github.com/tabler/tabler-icons/issues/669 — committed to nexryai/marinus by nexryai 2 years ago
I’m working on it here: https://github.com/tabler/tabler-icons/pull/969 🙂
@sapkra I’ve moved it to #993 as a part of biggest improvements
It is definitely hacky, it was just the way I had to make it work, I like tabler icons a lot. I feel this change is much more needed than any new icon, but I don’t speak for everyone.
I’ve fixed it in #1039
Results:
I’ve found a “solution” to this issue over at lucide-icons lucide-icons/lucide#1944 :
This converts named imports to direct imports during transforming.
I tested
3.0.0-alpha.1and the issue is still there, all icons are built regardless of how many you are using.any word on this? i’m going to stop using Tabler because I can’t bear waiting many seconds for each file change with HMR
Version 3.0.0:
Importing icons like this
Results in:
Importing icons like this
Results in:
Named imports results in all icons in the icon pack being transformed during build
thx, I looked through the list of icons and found that some of the names had two consecutive numbers, e.g.,
IconNumber123(convert tonumber-123) so the new code is:@levinit add to regex:
0-9, so icons with numbers can work tooIconReceipt2thx @TheEisbaer, it solves the issue, but I made a little modification, now
pnpm buildruns fast, I think only the imported icons are being transformed.update
create a ts file sush as
vite-plugin-optimizer-tabler.ts:use this pluin in the vite.config.js
I was also surprised about a breaking change as part of a minor release. It took me 30min to update all icon paths in our codebase and it would be nice if there was a codemod for such things to save everyone some time.
I don’t know why this keeps going around in circles, but now the whole
import Home from "@tabler/icons-svelte/IconHome.svelte";has changed back, again, toimport Home from "@tabler/icons-svelte/icons/home";for anyone wondering why things are broken after updating.Yeah I understand the change, it’s making zero difference in editor performance at my side but the biggest pain is having to update every single import across the entire project. Because it’s JS/TS, this is rather tedious and as far as I can see not documented anywhere other than that issue (and the link to it from the changelog). To me, this is a breaking change and should be documented as such.
That’s why I’ve posted it here in case someone like myself comes frantically stumbling to this GitHub wondering why everything has suddenly broken after updating the package.
You can just define your icons like
import IconBolt from '@tabler/icons-svelte/icons/bolt'for the time being until this issue is resolved.