-
Notifications
You must be signed in to change notification settings - Fork 7
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
Plugin waveform integration shows large bundle size #6
Comments
Hi, thanks for trying out the library and for bringing up this concern. You're right that tree shaking seems to miss a lot of unused branches. I dug into this a bit during development without finding a satisfactory fix, and the current workaround is to use default imports instead of named imports, targeting only the components you need, as described here: https://kitschpatrol.com/svelte-tweakpane-ui/docs#importing-components Let me know if that gets your bundle size down, and I'm open to any insights into how I could structure the library to encourage the tree shaker to work more aggressively when using named imports instead of default imports. |
Effectively, using default imports reduced noticeably the last chunks. It's still far from perfect, and tree shaking really is something hard to debug, so it'll stay that way for now. Thank you for checking! |
Glad that helped, but the build sizes still bug me so I looked into this a bit further, and picked up a few new insights:
So, I think we're seeing the tradeoffs between distributing plugins as built artifacts instead of source, which is the Tweakpane project's chosen approach. This has some advantages for ease of distribution, but eliminates some opportunities for subsequent build optimization. (FWIW Svelte does the opposite, distributing libraries as I don't know of a solution for this other than maintaining a fork of each plugin with Regardless of possible optimizations in how the third-party plugins are built, it's worth noting that using default instead of named imports still matters for tree shaking / dead code elimination. I will keep this issue open and plan to pursue the externalization strategy when time permits. |
I just updated all the plugin dependencies to externalize With my test project that includes every component from the library, I saw the following changes in a production build:
Pretty close to the 770 K savings estimate. The largest chunk is about a quarter of its previous size, and well under the default 500 K chunk size warning threshold. Again when bundle size is critical, it's still worth using default instead of named imports in addition to this optimization, since tree shaking is a separate issue. Released in v1.2.6. |
And (much) longer term, it looks like Svelte 5 might bring further relief:
Via a Reddit thread regarding a different project |
Closing this since there should be significant improvement in bundle size after v1.2.6. If that's not the case, feel free to comment and I'll re-open! |
On build, I get this:
Notice the warning at the end, and the size of the last chunk.
Since I'm not even using the waveform plugin, and most of my other chunks are under 8kB, I'm really wondering what's happening there. Why is tree shaking not working for the waveform plugin? I don't even know if the error is from tweakpane itself or your otherwise fantastic library here.
Do you know what could be causing that?
The text was updated successfully, but these errors were encountered: