Klarr-Agency/Circum-Icons

Bundling of @klarr-agency/circum-icons-react is not right.

sannajammeh opened this issue · 1 comments

A few bundle issues here result in production and development errors.

  1. You ship React in your bundle, causes mismatching versions error.
  2. There is no Barrel export so Webpack based frameworks will experience a development slowdown trying to serialize 400kb of modules.
  3. The bundle is un-treeshakeable due to it shipping all icons as an array and serializes them in runtime.
  4. Using this library results in 77kb added to bundle regardless of bundler and serializer

To resolve:

  1. Add React as a peer dependency so Rollup skips bundling it.
  2. Consider running a generate script before building to generate a React component for each SVG as a separate file.
  3. Add a barrel export file for all the generated components
  4. Run SWC or any other transpiler over the bundle to produce ESM and CJS modules.

I am happy to fix these issues and submit a PR if you'd like.

Hi @sannajammeh ,
Thank you for bringing these errors to my attention and offering to assist. I am not familiar with React and packaging in general. You can submit a PR to include React as a peer dependency to address this issue. Additionally, for the other points, you can create a separate branch. I might have to do the same for the other frameworks. I decided to create an array initially to keep the publishing process more straightforward, but I am willing to consider making a component for each icon if it improves performance.

Thanks for your help!