shinokada / svelte-awesome-icons

Font Awesome SVG icon components for Svelte. Svelte-Awesome-Icons support major CSS frameworks using the class props.
https://svelte-awesome-icons.codewithshin.com
MIT License
17 stars 2 forks source link

[BUG]: Slows down vitest #2

Closed hmajid2301 closed 1 year ago

hmajid2301 commented 1 year ago

Description of the bug

It seems when I use this library with vitest my tests run a lot slower ~14 minutes;

CI: https://gitlab.com/bookmarkey/gui/-/jobs/3703491548

According to this post; https://github.com/vitest-dev/vitest/issues/1861#issuecomment-1413419837

This seem to be caused by:

@hmajid2301 in your case one of the Svelte file imports is unable to tree shake imports. This seems to take most of the time.

import { FolderSolid } from "svelte-awesome-icons";

This ends ups importing all +2000 icons.

const __vite_ssr_import_0__ = await __vite_ssr_import__("/node_modules/.pnpm/svelte-awesome-icons@0.2.11/node_modules/svelte-awesome-icons/PasteSolid.svelte");
const __vite_ssr_import_1__ = await __vite_ssr_import__("/node_modules/.pnpm/svelte-awesome-icons@0.2.11/node_modules/svelte-awesome-icons/ScrewdriverSolid.svelte");
const __vite_ssr_import_2__ = await __vite_ssr_import__("/node_modules/.pnpm/svelte-awesome-icons@0.2.11/node_modules/svelte-awesome-icons/VimeoVBrand.svelte");
...

I can't spot any incorrect configurations from the published package. https://www.npmjs.com/package/svelte-awesome-icons?activeTab=explore ~Maybe some plugin set by svelte-kit is doing that - transforming it early to CJS for SSR?~

Steps To Reproduce

  1. Go to project
  2. Run tests task unit_tests

Additional Information

Link to repo: https://gitlab.com/bookmarkey/gui

shinokada commented 1 year ago

Thanks for the report. I will fix it and let you know asap.

shinokada commented 1 year ago

Can you update to @0.2.16 and let me know.

hmajid2301 commented 1 year ago

Updated; doesn't seem to make much of a difference https://gitlab.com/bookmarkey/gui/-/jobs/3708524352. But I wonder could it be something else affecting the run time ?

shinokada commented 1 year ago

Does uninstalling svelte-aweome-icons change the result? Can you target one file where you use the svelte-awesome-icons to test it?

hmajid2301 commented 1 year ago

Seems to be an issue with vitest itself; https://github.com/vitest-dev/vitest/issues/1861#issuecomment-1415663535

This commit seems have fixed the issue: https://gitlab.com/bookmarkey/gui/-/merge_requests/75/diffs?commit_id=0eb1a6917cdd9b226937ecdda1571c29f3c4e3a7

Can close this issue.