vetur: Vetur Intellisense slow and incomplete if project has jsconfig

  • I have searched through existing issues
  • I have read through docs
  • I have read FAQ

Info

  • Platform: Win
  • Vetur version: 0.11.3
  • VS Code version: 1.18.0

Problem

Vetur shows incomplete Intellisense and it takes too much time. It works fine if the project is virtual (no jsconfig or tsconfig).

image

Reproducible Case

https://github.com/Akryum/devfest-nantes-2017/tree/vs-code/app

Open this folder in VS Code and try Vetur in a .vue file.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 12
  • Comments: 46 (19 by maintainers)

Most upvoted comments

This should be fixed in 0.20.0. A small summary:

  • Vetur used to read all files included in js/tsconfig.json
  • Besides that, Vetur would read their dependencies, even if they are in node_modules
  • This is triggered on each file update, auto completion etc, so it’s very exepensive

New way it works:

  • All file system access to node_modules are cached and frozen (since they likely won’t change).
  • Local vue/js/ts file access are cached. When they are updated, caches are purged.

updated 2018-5-8 after more debug, I found that remove the ./src/* in include of jsconfig.json, can fix this problem.

=======================================

for the slow problem, I try to run simple profile.

after profiling by devtool, I found that large project with jsconfig.json or tsconfig.json cause this host.getScriptFilaNames returns a large array of filePath, and this will cause ts language service run HostCache.createEntry huge times。

the host.getScriptFileNames returns

vetur-performance-debug-getscriptfilenames

the profile

img20180425155436

Had same issue. Regular .js files were fine, but not .vue files. Fixed it by adding “include” in jsconfig.json:

{
  "include": [
    "./src/**/*"
  ],
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "~/*": ["src/*"],
      "src/*": ["src/*"],
      "vendor-dll/*": ["vendor-dll/*"]
    },
    "reactNamespace": "h"
  }
}

Have same issue. Intelisense works slow in .vue file, and works fine in .ts. So for a better coding performance, i have to separate SFC into .vue and .ts.

  • VSCode 1.19.2, Win10 1703 x64
  • Vetur 0.11.6
  • TypeScript 2.6.2

The config include in tsconfig is setted as below. There are almost 300 files in these directories(.vue, .js, .ts).

// tsconfig.json
    "include": [
        "./Scripts/**/*",
        "./components/**/*",
        "./src/**/*"
    ],

This should be fixed in 0.20.0. A small summary:

  • Vetur used to read all files included in js/tsconfig.json
  • Besides that, Vetur would read their dependencies, even if they are in node_modules
  • This is triggered on each file update, auto completion etc, so it’s very exepensive

New way it works:

  • All file system access to node_modules are cached and frozen (since they likely won’t change).
  • Local vue/js/ts file access are cached. When they are updated, caches are purged.

But if node_modules are frozen, when i use npm link, it seems that autocomplete cannot refresh after I made some changes to the code.

in .vue file

In .ts file it is working QQ20191222-164031@2x

@octref I was able to reproduce this issue with a couple files in this repository. I managed to find two cases that neither intellisense or path suggestions works. I hope this information can help somehow.

Specs that I used to reproduce the issue

Windows 10 Version 1709 Visual Studio Code Update 1.19.3 Vetur Version 0.11.7

Open folder has a subfolder with a jsconfig.json file

sample-vetur-jsconfig\sub-folder-example

Intellisense: works on .js files only Path suggestions: works on .js files only

Open folder has a root jsconfig.json file

sample-vetur-jsconfig\sub-folder-example\js

Intellisense: works on .js and .vue files Path suggestions: works on .js and .vue files

Open folder has a root jsconfig.json file with path aliases

sample-vetur-jsconfig\root-folder-example

Intellisense: works on .js and .vue files Path suggestions: works on .js and .vue files. But not with alias (.js and .vue).

I’ve looked further in this case and I saw this issue in the TypeScript repository that mentions this behaviour. I believe this issue may also affect vetur suggestions. But I’m not sure if this fix is available in the stable release or not. 🤔

There is also a fourth case that vetur is not understanding the baseUrl value in root jsconfig.json if your value is a subfolder like "baseUrl": "./js",. In this last one both Intellisense and path suggestion will work on .js files but not on .vue files.

Setting "moduleResolution": "classic" in compilerOptions seems to fix the slowness. However, it disables node_modules intellisense on some modules.

Changing moduleResolution in compilerOptions from node to classic on the slow project seems to fix the slowness, even if I don’t understand why it runs without problem like that on the fast project. If that can help anyone.

Any update on the incomplete IntelliSense issue?

me too, finally, I find it work slow with jsconfig.json. It work bad on my old note computer with third generations i5 , and work very fastly on my new computer with i7 8700. but in js (not vue ), all they work very fast. I think Vetur has High cpu usage with jsconfig.json / tsconfig.json. #913

Same slowness here on my notebook. (about 3 secs)

Both path suggestion and intellisense work but are slow. (paths alias in jsconfig.json also works.)


System info

  • Win10 Home (10.0.17134)
  • i7-7700HQ

Specs

  • Vue.js Extension Pack 1.1.3
  • Vetur 0.12.7
  • VSC 1.27.2

Here’s my jsconfig.json.

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": [ "./src/*" ]
    }
  }
}

After I rename it to jsconfig2.json (the same effect as removing it from the project), the slowness is fixed. Adding or removing include has no effect to fix the slowness. (After each change, VSC was restarted)

But with the same jsconfig.json, I cannot reproduce the slowness in a minimal project yet. (I should look into what the differences are between the minimal project and my current one)

@octref Did you have time to check the reproduction on Windows to see if you have the issue?

I do have a Windows machine at home. I can try it later today.

I’ll take a look at the incomplete IntelliSense.