Open marksamman opened 5 months ago
Please provide a small example project which demonstrates the issue
While preparing a small example I noticed that this is caused by an icon pack I have in my project which totals over 30000 .d.ts files. Since they are in node_modules and I am definitely not editing them in-between saves, it makes me wonder if the processing that happens could be cached.
The icon pack is the paid version of Font Awesome so I cannot share it publicly, I can send over a repro by email if necessary. You may also be able to reproduce the slowdown in a project with these packages in your package.json:
"@fortawesome/free-brands-svg-icons": "^6.5",
"@fortawesome/free-solid-svg-icons": "^6.5",
"@fortawesome/free-regular-svg-icons": "^6.5",
That's slightly under 3000 .d.ts files though, so it won't be as slow as what I'm experiencing.
I solved my problem by re-packaging the icon pack so that all SVG icons are exported from a single file, it's now more or less instant for me. Hope this can still be improved as it's annoyingly slow when it has to check too many files.
Two other issues I have with the "add missing imports" functionality:
- it prefers importing modules from dependencies in node_modules/ over modules with the same name within the project, 99% of the time what I want to import is the module within my project
This isn't a great solution, as it's a bit manual, but it works for common imports that are troublesome. Just exclude them in your settings.json
using "typescript.preferences.autoImportFileExcludePatterns"
I don't know of a way to prioritize local imports, last time I checked, there was not a way.
Type: Performance Issue
The issue happens when saving a ts/tsx file that has missing imports, where I expect it to add the missing imports. It takes over 20 seconds to save when it needs to add a couple of missing imports.
Show this message in the bottom right corner:
Saving 'Filename.tsx': Getting code actions from ''TypeScript and JavaScript Language Features'' (configure).
No extensions installed. I have tried complete reinstallation of VS Code and removed all local configuration (only addMissingImports enabled).
.vscode/settings.json:
tsconfig.json:
Happens in workspace and also if I just open the particular project as a folder. I am not sure exactly when this started happening, as it has been happening from time to time, but right now happens consistently. When it was working fine it was instant.
VS Code version: Code 1.87.2 (Universal) (863d2581ecda6849923a2118d93a088b0745d9d6, 2024-03-08T15:21:31.043Z) OS version: Darwin x64 23.4.0 Modes:
System Info
|Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz (8 x 2300)| |GPU Status|2d_canvas: enabledcanvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled| |Load (avg)|3, 3, 3| |Memory (System)|32.00GB (0.16GB free)| |Process Argv|--crash-reporter-id 4de4c709-1a11-494f-a46a-743da7067cbd| |Screen Reader|no| |VM|0%|
Process Info
``` CPU % Mem MB PID Process 31 164 48342 code main 2 66 48345 gpu-process 0 33 48346 utility-network-service 0 426 48348 window [1] (Filename.tsx — myproject (Workspace)) 2 66 48350 shared-process 0 0 48998 /bin/ps -ax -o pid=,ppid=,pcpu=,pmem=,command= 0 33 48351 fileWatcher [1] 0 98 48352 extensionHost [1] 0 66 48354 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=48352 0 98 48475 electron-nodejs (tsserver.js ) 0 197 48476 electron-nodejs (tsserver.js ) 0 33 48481 electron-nodejs (typingsInstaller.js typesMap.js ) 0 524 48622 window [3] (Filename.tsx — frontend) 0 33 48641 fileWatcher [3] 0 98 48642 extensionHost [3] 0 98 48665 electron-nodejs (tsserver.js ) 0 229 48666 electron-nodejs (tsserver.js ) 0 33 48672 electron-nodejs (typingsInstaller.js typesMap.js ) 0 98 48707 /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Applications/Visual Studio Code.app/Contents/Resources/app/extensions/json-language-features/server/dist/node/jsonServerMain --node-ipc --clientProcessId=48642 4 66 48996 window [4] (Issue Reporter) ```Workspace Info
``` | Window (Filename.tsx — frontend) | Window (Filename.tsx — myproject (Workspace)) | Folder (frontend): 343 files | File types: tsx(136) ts(85) woff2(18) js(13) css(12) png(8) tgz(8) | DS_Store(5) json(4) jpg(4) | Conf files: settings.json(1) package.json(1) tsconfig.json(1) | Folder (frontend): 343 files | File types: tsx(136) ts(85) woff2(18) js(13) css(12) png(8) tgz(8) | DS_Store(5) json(4) jpg(4) | Conf files: settings.json(1) package.json(1) tsconfig.json(1) ```Extensions: none