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

slow auto import with svelte-google-materialdesign-icons #2244

Closed
jasonlyu123 opened this issue Jan 4, 2024 · 6 comments
Closed

slow auto import with svelte-google-materialdesign-icons #2244

jasonlyu123 opened this issue Jan 4, 2024 · 6 comments
Labels
perf Performance upstream

Comments

@jasonlyu123
Copy link
Member

jasonlyu123 commented Jan 4, 2024

In my case the cause of the slow IntelliSense was the addition of "svelte-google-materialdesign-icons": "^0.8.3" this exports all of its components for the icons and makes autocomplete very slow to load. I am also using svelte-fa for fontawesome icons that we are using. I guess for now I will settle on one of these which is the more sensible choice anyway.

I have included a CPU profile of how long it takes to load with this package added: CPU-20240101T203600.cpuprofile

Here is the profiler with svelte-google-materialdesign-icons removed: CPU-20240101T204056-after.cpuprofile

Profiles were taken on 108.1.0 of the extension and the following vscode version:

 code-insiders --version
1.86.0-insider
9621add46007f7a1ab37d1fce9bcdcecca62aeb0
arm64

Originally posted by @MiraiSubject in #1984 (comment)

@jasonlyu123 jasonlyu123 added the perf Performance label Jan 4, 2024
@jasonlyu123
Copy link
Member Author

jasonlyu123 commented Jan 4, 2024

The reason for this is because of this monster package.json exports:

https://github.com/shinokada/svelte-google-materialdesign-icons/blob/8f434623c724c1d57d4ee0e2edd0be6d70e81b88/package.json#L85

It's over 8000 lines. TypeScript spends a ton of time comparing the path of the dts files to the subpath export. Even though a single comparison is cheap, it is looped n x n times. Although TypeScript can definitely optimize to reduce the loop count. But this feels like an edge case. Normally, the exports field should be really small and the optimization isn't worthy for the majority of the time.

With auto-import cache (#2237 or #2242), this should be at least usable. But it'll still take a huge amount of time for the first time and after the cache has been invalidated.

Another thing is during the parser error stage. All completion is global completion with no token to filter auto-import. So the time it takes is usually way higher than in the ts file.

@m4nh
Copy link

m4nh commented Mar 18, 2024

Save issue here with Tabler Icons Svelte, maybe for the same reason: big export in package.json file of that library.

I can't figure out how to solve it browsing linked issue. Can you provide the fix here?
Thanks a lot

@jasonlyu123
Copy link
Member Author

I am closing this since there is not much we can do. This needs to be fixed in TypeScript. Or the libraries should remove the thousands of lines of export map. I still haven't heard a reason as to why this is needed so I also don't know how to explain it when opening an upstream issue. If library authors have Svelte-specific reasons why this is required, feel free to comment here. Otherwise, please file an issue in TypeScript.

@jasonlyu123 jasonlyu123 closed this as not planned Won't fix, can't repro, duplicate, stale May 7, 2024
@dummdidumm
Copy link
Member

A solution to these monster export maps is using star imports:

"./*.svelte": {
  "types": "./dist/*.svelte.d.ts",
  "svelte": "./dist/*.svelte.ts"
}

@TheEisbaer
Copy link

A solution to these monster export maps is using star imports:

"./*.svelte": {
  "types": "./dist/*.svelte.d.ts",
  "svelte": "./dist/*.svelte.ts"
}

can you further elaborate this? for what did you make that work?

@dummdidumm
Copy link
Member

This is something the library itself needs to do, so it's not under your control as a consumer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
perf Performance upstream
Projects
None yet
Development

No branches or pull requests

4 participants