Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terrible Performance on lucide-solid library #2371

Closed
6 of 30 tasks
FelipeEmos opened this issue Aug 15, 2024 · 7 comments · Fixed by #2375
Closed
6 of 30 tasks

Terrible Performance on lucide-solid library #2371

FelipeEmos opened this issue Aug 15, 2024 · 7 comments · Fixed by #2375
Assignees
Labels
🐛 bug Something isn't working

Comments

@FelipeEmos
Copy link

Package

  • lucide
  • lucide-angular
  • lucide-flutter
  • lucide-preact
  • lucide-react
  • lucide-react-native
  • lucide-solid
  • lucide-svelte
  • lucide-vue
  • lucide-vue-next
  • Figma plugin
  • source/main
  • other/not relevant

Version

0.427.0

Can you reproduce this in the latest version?

  • Yes
  • No

Browser

  • Chrome/Chromium
  • Firefox
  • Safari
  • Edge
  • iOS Safari
  • Opera
  • Other/not relevant

Operating system

  • Windows
  • Linux
  • macOS
  • ChromeOS
  • iOS
  • Android
  • Other/not relevant

Description

The lucide-solid lib is with a terrible performance because it is loading all the icons instead of only the ones the project is using...

I created 2 repos to compare both lucide-solid and lucide-react and the performance difference is really big.

These repos were set up the same way, I used bun create vite@latest, deleted everything in the App.tsx and just added one icon.

Results

Benchmark Repo Lucide React Lucide Solid
Time 250 ms 3500 ms
Amount of Icons being loaded 1 all of them
Screenshots REACT SOLID

Steps to reproduce

Just import any icon in a Vite SolidJS project from the lucide-solid library and see the Lighthouse Network tab

Checklist

  • I have searched if someone has submitted a similar issue before and there weren't any. (Please make sure to also search closed issues, as this issue might already have been resolved.)
@FelipeEmos FelipeEmos added the 🐛 bug Something isn't working label Aug 15, 2024
@FelipeEmos
Copy link
Author

FelipeEmos commented Aug 15, 2024

Oh, I've just realized after continuing my search on the topic that this is probably a known issue... there's a section in the docs where it says

Tree-shaking is only available in these packages: lucide, lucide-react, lucide-vue, lucide-vue-next, lucide-angular, lucide-preact

I'm assuming that's exactly what's going on here... anyhow, is it too difficult to implement? Maybe I could give it a shot...

Any tips or resources would be appreciated.

@jamiemlaw
Copy link
Contributor

There is an article at https://christopher.engineering/en/blog/lucide-icons-with-vite-dev-server/ that proposes a workaround. Hope it helps.

@FelipeEmos
Copy link
Author

FelipeEmos commented Aug 15, 2024

@jamiemlaw thank you for the amazing resource!
I had no idea this was a Vite's deliberate feature not to Tree Shake when on DEV mode... ok then.

Although the article's workaround works, it unfortunately breaks Typescript so I'm not considering it seriously. I'd rather do the manual boring work of copy pasting the SVG's I need and maintain my own icon components.

But there's a real opportunity to improve the library here, and it doesn't seems so hard.
I'm really curious on how the lucide-react side of things works 🤔
I read the code and it's small and seems simple.

Cus if it's a VITE problem (and apparently on lucide-react it's been fixed by using some clever code generation technique), then there is no reason why almost the same approach wouldn't work for lucide-solid.

Porting the newest version of lucide-react to lucide-solid seems something I could do. Maybe by the time lucide-solid was ported this tree shaking thing was still an issue?

@ericfennis
Copy link
Member

@jamiemlaw
Maybe something has changed on the Vite side, not sure.
lucide-solid can't be directly compared to lucide-react since Solid is a compiled framework like Svelte. This means that the compiler can't handle pre-transpiled script files like React does, and all the files that shipped with this package are uncompiled. Also Solid Start uses different script files then normal Solid+Vite setup what it made it even more complicated.

Our build process is based on the rollup-preset-solid, but looks like we might go even more custom on this.

Thanks for reporting. I'm looking into it.

@FelipeEmos
Copy link
Author

FelipeEmos commented Oct 14, 2024

Hi, @ericfennis, I don't wanna bother and I'm grateful for your work!

But unfortunately I think we should reopen the issue.
I've just tried upgrading the library on my DEMO that I used to showcase the issue and it persists exactly the same.

I hope I did something wrong with the test but it's pretty straight forward... I upgraded the lib to the latest version (0.452.0), your fix got in on 0.433.0 and the problem persists

I then tested on exactly the version the fix got in ( in case there was any regression going on ) but it didn't work either

@vincehi
Copy link

vincehi commented Oct 22, 2024

Me to

@jguddas
Copy link
Member

jguddas commented Oct 22, 2024

Might be interesting, the vite peopel are working on a rewrite of the bundler, it's called rolldown and will hopefully fix a lot of performance problems.

Maybe someone wants to give it a try, maybe we don't have the issue with vite-rolldown?

There was also a good talk about the internal reworkings of the bundlers at viteconf https://youtu.be/IjV0tLysXc0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants