question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VSCode: Formatter slow or freezes if jsconfig.json is present in project

See original GitHub issue

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 image

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:closed
  • Created 3 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
dummdidummcommented, Jun 3, 2021

Closing as there is nothing we can take action on. If performance problems occur, please open a new issue with a detailed reproduction.

1reaction
dummdidummcommented, Jan 13, 2021

I guess you have set resolveJsonModule to true in your tsconfig.json? That means to TS “import and analyze that file”, which is slow and not avoidable. If you set resolveJsonModule to false instead and provide a d.ts declaration which tells TS to just assume that any file ending with .json is ok like so:

declare module "*.json" {
  const value: any;
  export default value;
}

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Visual Studio Code Intellisense Slow on Node proyect
One thing I noticed, is that when I enter the project(just started the window, intellisense works fine) until it finishes loading the "loading ......
Read more >
jsconfig.json Reference - Visual Studio Code
When your JavaScript project is growing too large and performance slows, it is often because of library folders like node_modules . If VS...
Read more >
User and Workspace Settings - Visual Studio Code
When you add a Workspace Settings settings.json file to your project or source ... This is a slow algorithm, that might cause freezes...
Read more >
Visual Studio Code February 0.10.11
Be aware that if you have no jsconfig.json defined to mark the root of your project, then each JavaScript file is considered an...
Read more >
Working with JavaScript in Visual Studio Code
You are using the TypeScript compiler to down-level compile JavaScript source code. Location of jsconfig.json. To define our code as a JavaScript project, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found