react-native-iconify icon indicating copy to clipboard operation
react-native-iconify copied to clipboard

Why don’t you declare the icons as ES Modules, so they’re fully tree-shakable?

Open fivaz3 opened this issue 1 year ago • 6 comments

You wouldn’t have to deal with the hassle of manually adding the icons you’re going to use in the vite.config.js.

Even if your library has millions of icons, all of them would be available during development, but only the ones actually used would be included in the final build shipped to the client.

fivaz3 avatar Nov 17 '24 21:11 fivaz3

I don’t like multiple imports for icons but i can add this feature later.

Example usage

import UserIcon from "@monicon/lucide/user"
import AccountIcon from "@monicon/lucide/account"

oktaysenkan avatar Nov 18 '24 01:11 oktaysenkan

thanks, it would be great

fivaz3 avatar Nov 19 '24 16:11 fivaz3

@oktaysenkan This would be far more preferable than adding individual icon names to the build config or unnecessarily bloating the bundle with an entire collection. I'd love to recommend we adopt Monicon within my workplace, as the standard icon solution for all our apps, but unfortunately I can't do that if the DX every time is "use an icon.. check the config"

benweier avatar Nov 24 '24 07:11 benweier

I am thinking a solution for this. Metro does not provide module load function like Vite.

oktaysenkan avatar Nov 24 '24 14:11 oktaysenkan

I just created the issue on metro repo

https://github.com/facebook/metro/issues/1422

oktaysenkan avatar Dec 29 '24 22:12 oktaysenkan

I will build a CLI tool to automate the generation of icon files in different formats (.tsx, .jsx, .vue, .svg, etc.). This enables fully tree shakable icons.

Core Features:

  • Users can set a custom output path (default: src/components/icon).
  • Supports predefined templates for different frameworks (SVG, React JSX, React TSX, Vue, etc.).
  • Allows users to define custom templates, similar to a custom loader, making it possible to use Monicon in other programming languages.

This will streamline icon management and improve workflow efficiency. What do you think?

oktaysenkan avatar Feb 05 '25 05:02 oktaysenkan