VSCode: Formatter slow or freezes if jsconfig.json is present in project
See original GitHub issueDescribe 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
Issue Analytics
- State:
- Created 3 years ago
- Comments:20 (9 by maintainers)
Top GitHub Comments
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.