-
Notifications
You must be signed in to change notification settings - Fork 24
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
Treeshake Icon contents #42
Comments
This was actually planned for the 1.0 release.. Old:
New:
The newer way makes more sense, simply importing the PRs are definitely welcome, if you have any ideas let me know. |
Each bundler handles tree-shaking differently. One way to combat a breaking change would be to generate each icon as its own file which default exports a vnode and expose them to import UserIcon from "construct-ui/user-icon"
m(Button, { iconLeft: m(UserIcon) }); This is similar to how you'd treeshake lodash module when bundling with Rollup before passing to Terser but it doesn't seem fitting for construct and better applied in monorepos that modularize these implementations and leverage @ orgs on the NPM registry. Ideally you'd want each Icon available on the module for convenience sake.
I don't think I follow? Do you mean using |
Yeah, sorry for the confusion, currently The Let me look into this more, I'll come up with something when I have time. |
Hey @vrimar
The feather icon pack contributes 50kb of weight to distribution bundles, I'm having trouble tree-shaking those imports. The JSON Mapping of svg contents provided via feather seems the cause. Providing Icons contents as a series of exports would allow svg contents to be cherry picked when bundling for production, I noticed the current approach it to map icon contents to property value but mapping to a vnode would be just as effective, eg:
Are PRs welcome on the project?
The text was updated successfully, but these errors were encountered: