N00nDay / stwui

Opinionated yet customizable Svelte-TailwindCSS component library
stwui.vercel.app
MIT License
451 stars 21 forks source link

Including "Select" in tree-shaking manner breaks tree-shaking at all #220

Open darksimpson opened 4 months ago

darksimpson commented 4 months ago

Current Behavior

When "Select" is included like told from docs to be tree-shaking aware: import Select from 'stwui/select'; tree-shaking breaks and all complete STWUI library is included, according to output JS size and rollup-plugin-visualizer stats.

Expected Behavior

When "Select" is included like told from docs to be tree-shaking aware: import Select from 'stwui/select'; tree-shaking must be performed well and only neccessary components shall be included, not all STWUI library code.

Steps To Reproduce

  1. Create any project from empty template, include "Select" this way:
  2. import Button from 'stwui/button';
  3. Build, check the size and dependencies using rollup-plugin-visualizer (only Button code and some helper code of couse will be included)
  4. import Select from 'stwui/select';
  5. Build, check the size and dependencies using rollup-plugin-visualizer (all STWUI code will be included, this is erroneous behavior)

Link to Reproduction / Stackblitz

No response

More Information

I've checked and found that problem resides in Select.svelte component code. At now, Icon is included like this: import { Icon } from '../../'; (at line 5) and this includes complete STWUI in result must be fixed to include it like this: import Icon from '../icon'; I will prepare a pull request.