tabler / tabler-icons

A set of over 5500 free MIT-licensed high-quality SVG icons for you to use in your web projects.
https://tabler.io/icons
MIT License
18.03k stars 898 forks source link

PERF: Improve performance of intellisens and IDE #1133

Closed TheEisbaer closed 3 months ago

TheEisbaer commented 4 months ago

Package

Version

@latest

Browser

Operating system

Description

VSCode and Intellisense (especially the language servers) are slowing down (taking up to 40 seconds for auto complete) because of the huge amount of export conditions (one for each icon) in the package.json

See https://github.com/sveltejs/language-tools/issues/2244 for advice on fix for this

Steps to reproduce

  1. have svelte project and vscode extension for svelte language server installed
  2. install tabler icons for svelte
  3. try to do autocomplete -> takes up to 40 seconds to make auto complete suggestion 4

Checklist

TheEisbaer commented 4 months ago

Proposed solution:

final package.json has to look like this:

"exports": {
    ".": {
      "types": "./dist/tabler-icons-svelte.d.ts",
      "svelte": "./dist/tabler-icons-svelte.js",
      "default": "./dist/tabler-icons-svelte.js"
    },
    "./icons": {
      "types": "./dist/tabler-icons-svelte.d.ts",
      "svelte": "./dist/tabler-icons-svelte.js"
    },
    "./icons/*": {
      "types": "./dist/icons/*.svelte.d.ts",
      "svelte": "./dist/icons/*.svelte"
    }
}

then you can import the icons like:

import IconAB from '@tabler/icons-svelte/icons/a-b'; // fast during build and dev server
// or
import { IconAB } from '@tabler/icons-svelte'; // still slow during build and dev server because vite still transforms every icon

Results in much faster IDE performance