-
Notifications
You must be signed in to change notification settings - Fork 1
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
Is this plugin useful anymore? #11
Comments
Hi there, thanks for opening this issue! It's true that I didn't really make things clear on that side, so let me try to clarify. First off, I'd like to preface by saying that I'm not an expert at all on the subject of tree-shaking, ESM, bundling, etc. I read stuff about this very issue and based this plugin on my general knowledge and the conclusions I've made based on what I've experienced, that's it.
It is. Again, I'm not an expert, so I'll prove my point with a real-life example. Here's my advent-of-svelte project with this plugin, in dev mode (I use this one as an example, but it could be any project, really. I just happen to use it to try things out with the plugin):
Now, without the plugin:
This latter is the one we want to avoid, and that gets generated, as I state in my README, once a single import is using the raw This is the problem lucide-icons/lucide#1707 solved for Svelte: generating/dealing with this large useless file effectively slows down the Vite dev server. I've never really experienced it myself because I have a decently fast machine, but this PR speaks for itself. But yeah: the issue is (AFAIK) dev-mode only and doesn't seem to affect bundle size, that's why you might not have felt it.
They say it themselves right under the snippet you sent me:
Direct imports give better performance in dev mode and while building in general, as it helps Vite figure out what to import and avoid having to tree-shake all of that.
Indeed
I'm not really sure what you mean by "the amount of transferred JS", though I can encourage you to try it out by yourself by inspecting the Sources in dev mode as I did above.
Hope these explanations helped, let me know if you have any further questions or if I made any mistakes somewhere! |
Ah, OK, now I understand.
I meant that in the network tab in Dev Tools, the summary "... MBs transferred" showed the same number before and after installing the preprocessor. Also I looked at the building times and I see they are a bit shorter too. Great. Thanks for the plugin. |
Glad to hear! Thanks again for posting :) |
Just updated the README with corrections and a link to my answer from here |
Issue type
question
Description
Hello.
I stumbled upon this issue lucide-icons/lucide#2295, which linked to this repo.
The readme of this package says:
I'm a bit skeptical of this claim. Is it actually true? Maybe it was true some time ago, but is it still?
Because in the Lucide's docs, they say:
That is in the context of their examples of the suggested usage:
They did suggest, that importing icons directly may improve build and load times, but didn't explain why.
They also warned against this kind of usage:
which, understandably, is not tree-shakable, and will bundle all the icons.
Moreover, I tried using this plugin in my project and there was no difference in the amount of transferred JS code before and after the change. It is possible I installed it wrong, but I tried to follow the instruction in the readme.
Could you clear my confusion?
Thanks.
Special case
The text was updated successfully, but these errors were encountered: