language-tools: VSCode: Formatter slow or freezes if jsconfig.json is present in project
Describe the bug
Since updating to 105.4.0 of the VS Code extension the formatter is really slow or freezes when saving a .svelte file making me having to skip formatting from the VS Code prompt almost every time I’m saving a file.
There’s a jsconfig.json
present in the project, it’s got a couple of aliases mapped in the root of my project.
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"#js/*": ["./client_src/js/*"],
"#api/*": ["./server_src/api/*", "./client_src/js/api/*"],
"#api/scripts/*": ["./server_src/scripts/api/*"],
"#api/webapps/*": ["./server_src/webapps/api/*"],
"#api/restapps/*": ["./server_src/restapps/api/*"],
}
},
"exclude": ["node_modules"]
}
https://code.visualstudio.com/docs/languages/jsconfig
If I remove this file the formatter works as expected.
Version 102.3.0 doesn’t have this problem, I’ve downgraded to that version in the meanwhile.
To Reproduce
Add a jsconfig.json
file to the project, content doesn’t seem to matter.
I added an empty jsconfig.json
file, or with an empty object, and this causes the formatter to freeze.
Expected behavior Format the code without freezing.
Screenshots
System (please complete the following information):
- OS: Windows 10
- IDE: VS Code
- Plugin/Package: Svelte for VSCode 102.4.0 102.5.1
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (9 by maintainers)
Closing as there is nothing we can take action on. If performance problems occur, please open a new issue with a detailed reproduction.
I guess you have set
resolveJsonModule
totrue
in yourtsconfig.json
? That means to TS “import and analyze that file”, which is slow and not avoidable. If you setresolveJsonModule
tofalse
instead and provide ad.ts
declaration which tells TS to just assume that any file ending with.json
is ok like so:Then the file is not analyzed and it should be faster. The disadvantage is that you no longer have type definitions for the JSON module and also TS will not error if there’s no JSON file at the path you specify.
I was trying to not open a separate issue unnecessarily, but I think my issue might be different enough that it calls for one. I’ll try to make a minimal repo as well. The project is small.
I guess most of those files are from the other projects. Because there’s only the jsconfig at the root, everything’s loaded even if not needed. I also think we cannot do much there. The initial load is most likely the TS service reading the config file and then scanning and loading all the js/ts files initially. Since that’s synchronous we are essentially blocked from doing anything else.