Skip to content
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

Vite dev mode loads all icon chunks with 3.19.0 (React) #1233

Open
4 of 30 tasks
dcentrih opened this issue Sep 28, 2024 · 63 comments
Open
4 of 30 tasks

Vite dev mode loads all icon chunks with 3.19.0 (React) #1233

dcentrih opened this issue Sep 28, 2024 · 63 comments
Labels
bug Something isn't working

Comments

@dcentrih
Copy link

Description

Using the new 3.19.0 version of the react package breaks dev mode.
After importing any one icon into a component, vite will start loading all the icon chunks (takes about 10 seconds on my machine).
Building the app does not have this issue (preview mode).

image

Package

  • @tabler/icons
  • @tabler/icons-eps
  • @tabler/icons-pdf
  • @tabler/icons-png
  • @tabler/icons-webfont
  • @tabler/icons-sprite
  • @tabler/icons-preact
  • @tabler/icons-react
  • @tabler/icons-react-native
  • @tabler/icons-solid
  • @tabler/icons-svelte
  • @tabler/icons-vue
  • Figma plugin
  • source/main
  • other/not relevant

Version

3.19.0

Browser

  • Chrome/Chromium
  • Firefox
  • Safari
  • Edge
  • iOS Safari
  • Opera
  • Other/not relevant

Operating system

  • Windows
  • Linux
  • macOS
  • ChromeOS
  • iOS
  • Android
  • Other/not relevant

Steps to reproduce

  1. Import any icon
    import { IconComponents, IconTag } from "@tabler/icons-react";
  2. Run vite in dev mode

Checklist

  • I have searched if someone has submitted a similar issue before and there weren't any. (Please make sure to also search closed issues, as this issue might already have been resolved.)
@dcentrih dcentrih added the bug Something isn't working label Sep 28, 2024
@fnoopv
Copy link

fnoopv commented Sep 29, 2024

+1

1 similar comment
@adnanfajlur
Copy link

+1

@AhmedHHamdy
Copy link

AhmedHHamdy commented Sep 29, 2024

+1
image

@ciro-maciel
Copy link

+1

2 similar comments
@Kevin-Saukel-Git
Copy link

+1

@amankrokx
Copy link

+1

@noah-franklin
Copy link

was losing my mind over why vite was taking 5 years to load initially, I guess something broke tree shaking in 3.19

@Reynard-G
Copy link

+1

@dougfrei
Copy link

dougfrei commented Oct 2, 2024

It seems like something with [email protected] is causing this problem. I checked down to @tabler/[email protected] and still had issues with all the icon chunks loading in dev mode. After downgrading to [email protected] the excess chunk loading was gone, even when using @tabler/[email protected].

@Cararr
Copy link

Cararr commented Oct 2, 2024

It almost blew my pc.

@pavel-pargachev
Copy link

It has something to do with the new "Dynamic Icons Import" feature released with 3.19.0 (#1081).

When I commented out 2 lines related to this feature from tabler-icons-react.mjs file - the loading of chunks by vite dev went to normal again:
image

@enyelsequeira
Copy link

anyone found a solution yet? downgrading perhaps? or is there a better one?

@ciro-maciel
Copy link

ciro-maciel commented Oct 2, 2024

for now, I forced the installation to:

"@tabler/icons-react": "3.17.0",
"vite": "5.4.8",

I cleaned the environment,

rm -rf node_modules bun.lockb package-lock.json dist

I installed everything again and it worked fine here

CleanShot 2024-10-02 at 15 23 22

@amankrokx
Copy link

for now, I forced the installation to:

"@tabler/icons-react": "3.17.0",
"vite": "5.4.8",

@ciro-maciel any specific reason for not using 3.18.0 ? I'm using that.

@enyelsequeira
Copy link

for now, I forced the installation to:

"@tabler/icons-react": "3.17.0",
"vite": "5.4.8",

I cleaned the environment,

rm -rf node_modules bun.lockb package-lock.json dist

I installed everything again and it worked fine here

CleanShot 2024-10-02 at 15 23 22

Same here ended up locking the correct one, I’m using it with mantine so I’m using that version

@ciro-maciel
Copy link

for now, I forced the installation to:

"@tabler/icons-react": "3.17.0",
"vite": "5.4.8",

@ciro-maciel any specific reason for not using 3.18.0 ? I'm using that.

I tested with 3.18.0 and got the error... so I used 3.17.0 and I'm not getting the error

@lukasbash
Copy link

This not only affects the DEV mode. It also affects the production bundle. Even more critical because it's a silent failure.
image

@astalarico
Copy link

+1

@mathiaswillburger
Copy link

mathiaswillburger commented Oct 9, 2024

same issue, forcing the package to "@tabler/icons-react": "3.17.0" solved the problem for now and speeds up the vite dev application load tremendously again

@KevinVandy
Copy link

@codecalm @timheerwagen Any chance this gets fixed? Kind of afraid that in order to fix this for mantine-react-table, I'll have to just embed the svgs in the codebase instead of using tabler as a peer dep. KevinVandy/mantine-react-table#418

@KevinVandy
Copy link

KevinVandy commented Oct 14, 2024

This not only affects the DEV mode. It also affects the production bundle. Even more critical because it's a silent failure.

@lukasbash

All other reports are that in only affects DEV mode and not production bundles. Could you share what kind of build config that application has? Older webpack?

If true, this is way more serious than I initially thought, as it would be potentially quadrupling the bundle size of some apps for unused icons.

@lukasbash
Copy link

This not only affects the DEV mode. It also affects the production bundle. Even more critical because it's a silent failure.

@lukasbash

All other reports are that in only affects DEV mode and not production bundles. Could you share what kind of build config that application has? Older webpack?

If true, this is way more serious than I initially thought, as it would be potentially quadrupling the bundle size of some apps for unused icons.

Might be I got this wrong but I am simply performing a bundle analyzer call on the latest vite version.

In my case I am using bun:
bunx vite-bundle-visualizer

@AstroCaleb
Copy link

AstroCaleb commented Oct 15, 2024

+1 – I updated deps last night before launching a new project and noticed dev mode started taking the same ~10 seconds others have described.

Forcing "@tabler/icons-react": "3.17.0" also worked for me, running with latest vite (5.4.9) and everything. I even tested with [email protected] and [email protected], based on a comment above, and still noticed the chunks issue. It seems, at least for me, [email protected] is the only change I needed to change.

@baberMatt
Copy link

+1 same issue as described by many in my Remix(vite) vercel app. Will try versioning down

BANANAPEEL202 added a commit to hytech-racing/query-frontend that referenced this issue Oct 15, 2024
@ssdwho
Copy link

ssdwho commented Oct 16, 2024

I wonder if the update that caused this problem could not be determined? Version 3.17.0 is working fine. What happened next?

@sethen
Copy link

sethen commented Oct 31, 2024

3.x.x is unusable for me and crashes my app

IgnisDa added a commit to IgnisDa/ryot that referenced this issue Nov 1, 2024
IgnisDa added a commit to IgnisDa/ryot that referenced this issue Nov 2, 2024
* fix(website): invalidate old keys

* chore(website): hide links

* chore(website): hide more links

* fix(frontend): refresh metadata details on adding to collection

* fix(website): add more padding etc

* fix(website): remove carousel b tns

* refactor(frontend): move location of item

* ci(ts): downgrade tabler icons version

Ref: tabler/tabler-icons#1233

* refactor(frontend): use correct imports

* feat(frontend): display inline progress

* feat(frontend): change orientation of inline progress bar

* chore(models/user): remove repeated stuff

* chore(backend): add new column for deduplicating upcoming section

* chore(gql): generate new types

* fix(frontend): better logic to decide which elements should show

* feat(frontend): deduplicate media

* fix(services/misc): respect new preferences

* fix(frontend): add docs for deduplicate option

* build(ts): upgrade deps

* refactor(frontend): change name of param
@sionguo
Copy link

sionguo commented Nov 4, 2024

+1 v3.21.0

@ssdwho
Copy link

ssdwho commented Nov 8, 2024

3.21.0 added the new icons I needed, but I'm stuck with 3.17.0. ☹️

@mrclrchtr
Copy link

3.21.0 added the new icons I needed, but I'm stuck with 3.17.0. ☹️

There is a workaround #1233 (comment)
Why don't you use it?

@ImanEmadi
Copy link

I was about to open a similar issue until i saw this.
how this problem is not yet addressed is beyond me.

@ssdwho
Copy link

ssdwho commented Nov 13, 2024

3.21.0 added the new icons I needed, but I'm stuck with 3.17.0. ☹️

There is a workaround #1233 (comment) Why don't you use it?

Oh! My mistake, I missed it. Thanks, it's working.

@Icaruk
Copy link

Icaruk commented Nov 17, 2024

Workaround from #1233 (comment) worked!

@Lamarcke
Copy link

I've just spent the whole noun debugging this. Thanks to #1233 (comment) for the workaround!

Lamarcke added a commit to game-node-app/game-node-mobile that referenced this issue Nov 19, 2024
@truckcarr11
Copy link

Also experienced this, glad to see there is a work around. Any way we can get an update on having this fixed?

paoloose added a commit to fisirc/metagallery that referenced this issue Nov 22, 2024
@alikazai
Copy link

alikazai commented Nov 23, 2024

Was going mad at why my app was slow, reading the comments tried this one and it worked Thanks to #1233 (comment) for the workaround!

however there should be a better more permanent solution for future users of this plugin.
not sure what the exact issue is but someone mentioned the dynamic imports was the problem. anyone tried running this without dynamic imports.

@EldinHb
Copy link

EldinHb commented Dec 17, 2024

This is caused by exporting dynamic imports: https://cdn.jsdelivr.net/npm/@tabler/[email protected]/dist/esm/dynamic-imports.mjs

Each dynamic import creates a separate chunk chunk-[hash].js, hence the 5k+ chunks built by Vite

For a temporary workaround, you could setup an alias such that vite resolves the import to only the static exports entrypoint

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      // /esm/icons/index.mjs only exports the icons statically, so no separate chunks are created
      '@tabler/icons-react': '@tabler/icons-react/dist/esm/icons/index.mjs',
    },
  },
})

Credit to hiogawa from the Vite team for the temporary solution

If I use this I get errors with some icons and not with others. For example IconBurger works fine. Icon24Hours provides an error. This is the error: The requested module '/node_modules/.vite/deps/@tabler_icons-react.js?v=d60d3af5' does not provide an export named 'Icon24Hours'. Icon24Hours is missing in the index.mjs. In fact, any icon that starts with a number after icon is missing from @tabler/icons-react/dist/esm/icons

Anyone else experiencing the same issue?

@kenzaflow
Copy link

This is caused by exporting dynamic imports: https://cdn.jsdelivr.net/npm/@tabler/[email protected]/dist/esm/dynamic-imports.mjs
Each dynamic import creates a separate chunk chunk-[hash].js, hence the 5k+ chunks built by Vite
For a temporary workaround, you could setup an alias such that vite resolves the import to only the static exports entrypoint

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      // /esm/icons/index.mjs only exports the icons statically, so no separate chunks are created
      '@tabler/icons-react': '@tabler/icons-react/dist/esm/icons/index.mjs',
    },
  },
})

Credit to hiogawa from the Vite team for the temporary solution

If I use this I get errors with some icons and not with others. For example IconBurger works fine. Icon24Hours provides an error. This is the error: The requested module '/node_modules/.vite/deps/@tabler_icons-react.js?v=d60d3af5' does not provide an export named 'Icon24Hours'. Icon24Hours is missing in the index.mjs. In fact, any icon that starts with a number after icon is missing from @tabler/icons-react/dist/esm/icons

Anyone else experiencing the same issue?

yes
image

@ssdwho
Copy link

ssdwho commented Dec 17, 2024

This is caused by exporting dynamic imports: https://cdn.jsdelivr.net/npm/@tabler/[email protected]/dist/esm/dynamic-imports.mjs
Each dynamic import creates a separate chunk chunk-[hash].js, hence the 5k+ chunks built by Vite
For a temporary workaround, you could setup an alias such that vite resolves the import to only the static exports entrypoint

export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      // /esm/icons/index.mjs only exports the icons statically, so no separate chunks are created
      '@tabler/icons-react': '@tabler/icons-react/dist/esm/icons/index.mjs',
    },
  },
})

Credit to hiogawa from the Vite team for the temporary solution

If I use this I get errors with some icons and not with others. For example IconBurger works fine. Icon24Hours provides an error. This is the error: The requested module '/node_modules/.vite/deps/@tabler_icons-react.js?v=d60d3af5' does not provide an export named 'Icon24Hours'. Icon24Hours is missing in the index.mjs. In fact, any icon that starts with a number after icon is missing from @tabler/icons-react/dist/esm/icons
Anyone else experiencing the same issue?

yes image

The common point in both of your problems is that the icon names are defined as aliases.

"box-seam": "package",
"kering": "kerning",
"2fa": "auth-2fa",
"3d-cube-sphere": "cube-3d-sphere",
"3d-cube-sphere-off": "cube-3d-sphere-off",
"3d-rotate": "rotate-3d",
"12-hours": "hours-12",
"24-hours": "hours-24",

IconHours24
IconPackage

you can use it like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests