Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vetur Intellisense slow and incomplete if project has jsconfig #547

Closed
3 tasks done
Akryum opened this issue Nov 15, 2017 · 46 comments
Closed
3 tasks done

Vetur Intellisense slow and incomplete if project has jsconfig #547

Akryum opened this issue Nov 15, 2017 · 46 comments

Comments

@Akryum
Copy link
Member

Akryum commented Nov 15, 2017

  • 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.

@Akryum Akryum changed the title Vetur slow and incomplete if project has jsconfig Vetur Intellisense slow and incomplete if project has jsconfig Nov 15, 2017
@HerringtonDarkholme
Copy link
Member

I cannot reproduce this. Though at first load, I can feel some delay.

This is caused by automatic typing resolution in vscode: vscode will automatically install typing file used in your project. After initial loading, I cannot feel significant delay.

@Akryum
Copy link
Member Author

Akryum commented Nov 16, 2017 via email

@HerringtonDarkholme
Copy link
Member

About 3 seconds.

@Akryum
Copy link
Member Author

Akryum commented Nov 16, 2017

And do you have complete Intellisense with props, computed, methods, and Vue API inside the component?

@Akryum
Copy link
Member Author

Akryum commented Nov 16, 2017

Did you try on Windows 10?

@HerringtonDarkholme
Copy link
Member

Nope, I'm on MBP. @octref do you have windows box ?

@Akryum
Copy link
Member Author

Akryum commented Nov 16, 2017

I tested on a MBP, I cannot reproduce the slowness, but I can reproduce the incompleteness. For example, in the PageHome.vue component:

  • Inside the emptyMessage computed prop, I should have questions, loading, refresh and all the other Vue API (like $refs) also suggested, but I only have emptyMessage.
  • Inside the refresh method, I only have refresh suggested.

@octref
Copy link
Member

octref commented Nov 16, 2017

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

I'll take a look at the incomplete IntelliSense.

@TristinDavis
Copy link

Any update on the incomplete IntelliSense issue?

@Hanruis
Copy link

Hanruis commented Dec 22, 2017

I have the same problem , any update on this issue ?

@HerringtonDarkholme
Copy link
Member

Can you try intelisense in JS file or TS file?

Vetur shares the same TypeScript engine with VSCode. So the problem should also occur there.

@doommm
Copy link

doommm commented Jan 23, 2018

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/**/*"
    ],

@HerringtonDarkholme
Copy link
Member

Please do provide a reproduction repo if you have the same issue.

@Akryum
Copy link
Member Author

Akryum commented Jan 29, 2018

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

@octref octref added the bug label Jan 31, 2018
@octref
Copy link
Member

octref commented Jan 31, 2018

@Akryum I tested on a Windows VM running in Parallel. I do feel some lagginess in the beginning, but after a while the completion becomes smooth. What's your machine's spec?

Meanwhile I tested the project on both macOS / Win, interestingly, the incomplete completion only happens on Windows...Looking into it.

@Akryum
Copy link
Member Author

Akryum commented Jan 31, 2018

Windows 10 Pro 64-bit
Intel i7 3770K @ 4GHz (4 cores/8 threads)
16 GB DDR3

@RenanOliv
Copy link

RenanOliv commented Feb 2, 2018

@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.

@Hanruis
Copy link

Hanruis commented Apr 24, 2018

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

@wasichris
Copy link

same intellisense slow issue with jsconfig.json

@zcoding
Copy link

zcoding commented May 24, 2018

same intellisense slow issue

delay about 3 seconds...

@octref
Copy link
Member

octref commented May 24, 2018

Can you try this thing now:

  • Edit setting "vetur.trace.server": "verbose"
  • Go to Output -> Vue Language Server
  • Trigger completion
  • Paste result here

@uriannrima
Copy link

Having the same trouble, as I write intellisence takes a couple of seconds (about 3) to say something (error, autocomplete, etc), and as I'm writing, it starts to give the intellisence response from the previous text. So it seems to send at each key that I press, instead of maybe wait for me to stop writing or something.

I've enabled the verbose output, it printed like a LOT of text, how should I share here? I mean, it's really a LOT to paste in here.

@Hanruis
Copy link

Hanruis commented Jun 11, 2018

@uriannrima if more than hundreds line of the output, provide a file for download would be better, i think.

@octref
Copy link
Member

octref commented Aug 12, 2018

@Akryum Does this still happen to you?
@uriannrima You can paste log files up to 10MB to GitHub.

@octref octref mentioned this issue Aug 13, 2018
17 tasks
@UltimaBeaR
Copy link

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"
  }
}

@tartinesKiller
Copy link

I experience the same behaviour, but I've noticed something strange: I've got two projects with the same jsconfig.json, quite the same folder structure, but intellisense is very slow on one, and fast as hell on the other.
Here is the jsconfig:

{
    "compilerOptions": {
        "baseUrl": ".",
        "module": "es6",
        "paths": {
            "@/*": ["*", "./src/*"],
            "@static/*": ["*", "./static/*"],
        },
        "moduleResolution": "node"
    },
    "include": [
        "./src/**/*"
    ],
}

I've noticed in the Vetur logs that the task "textDocument/completion" took 158ms for the "fast" project, and 4904ms for the "slow" project. Both are quite small projects, but I can't share them, sorry.
May it help if I share the vetur logs?

@tartinesKiller
Copy link

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.

@octref
Copy link
Member

octref commented Oct 1, 2018

Changing moduleResolution in compilerOptions from node to classic on the slow project seems to fix the slowness

@tartinesKiller That's because we are using the TypeScript language service that turns on/off features based on the tsconfig.json file. I'll try to repro this.

@octref
Copy link
Member

octref commented Oct 1, 2018

@tartinesKiller Changing the module resolution to node does not repro it for me in this project: https://github.com/octref/veturpack

Can you also try another build? See #913 (comment). Thanks in advance.

@momocow
Copy link

momocow commented Oct 2, 2018

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
Copy link
Member

octref commented Oct 2, 2018

@momocow Thanks a lot for the info! If you remove paths, is the slowness gone?

@momocow
Copy link

momocow commented Oct 3, 2018

No, almost the same.
Only removing jsconfig.json eliminates the slowness.

@Hanruis
Copy link

Hanruis commented Oct 8, 2018

@momocow how about just remove the ./src/* of include .

I have found that it will make vetur anylasis all files in the src dir. And the slowness occur while src dir has large amount js and vetur files. In my project, there are more than 1000 files in src dir.

@momocow
Copy link

momocow commented Oct 8, 2018

@Hanruis My project is not that big, containing 10 .vues and 4 .jss only.

BTW, a good news is that after auto-updating vetur from v0.12.7 to v0.13.0, the slowness is gone even with the jsconfig.json as follows. 😂
I cannot reproduce the slowness yet.

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

@david-mart
Copy link

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

@zbjornson
Copy link

@octref here's a somewhat abbreviated output from the verbose log (I removed some of the response bodies, or parts of large response bodies). You can see the responses often take 2-3+ seconds. The responses from the typescript server on the same computer take 75 to 250 ms generally.

[Trace - 7:15:48 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
        "version": 37
    },
    "contentChanges": [
        {
            "text": <5,295 characters>
        }
    ]
}

[Trace - 7:15:48 PM] Sending request 'textDocument/completion - (96)'.
Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue"
    },
    "position": {
        "line": 107,
        "character": 4
    },
    "context": {
        "triggerKind": 1
    }
}

[Trace - 7:15:48 PM] Sending notification '$/cancelRequest'.
Params: {
    "id": 96
}

[Trace - 7:15:48 PM] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
        "version": 41
    },
    "contentChanges": [
        {
            "text": <5,321 characters>
        }
    ]
}

[Trace - 7:15:48 PM] Sending request 'textDocument/completion - (97)'.
Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue"
    },
    "position": {
        "line": 107,
        "character": 8
    },
    "context": {
        "triggerKind": 2,
        "triggerCharacter": "."
    }
}

[Trace - 7:15:49 PM] Received response 'textDocument/completion - (96)' in 712ms.
Result: {
    "isIncomplete": false,
    "items": [
        {
            "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
            "position": {
                "line": 107,
                "character": 4
            },
            "label": "arguments",
            "sortText": "00",
            "kind": 6,
            "data": {
                "languageId": "javascript",
                "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
                "offset": 2019
            }
		},
		// ... 2,523 items elided
        {
            "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
            "position": {
                "line": 107,
                "character": 4
            },
            "label": "of",
            "sortText": "02525",
            "kind": 14,
            "data": {
                "languageId": "javascript",
                "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
                "offset": 2019
            }
        }
    ]
}


[Trace - 7:15:49 PM] Sending request 'textDocument/documentSymbol - (98)'.
Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue"
    }
}


[Trace - 7:15:49 PM] Sending request 'textDocument/documentLink - (99)'.
Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue"
    }
}

[Trace - 7:15:49 PM] Sending request 'textDocument/documentColor - (100)'.
Params: {
    "textDocument": {
        "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue"
    }
}

[Trace - 7:15:49 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 107,
                    "character": 3
                },
                "end": {
                    "line": 107,
                    "character": 4
                }
            },
            "severity": 1,
            "message": "Cannot find name 't'."
        }
    ]
}

[Trace - 7:15:50 PM] Received response 'textDocument/completion - (97)' in 1957ms.
Result: {
    "isIncomplete": false,
    "items": [
        {
            "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
            "position": {
                "line": 107,
                "character": 8
            },
            "label": "badgeClasses",
            "sortText": "00",
            "kind": 5,
            "data": {
                "languageId": "javascript",
                "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
                "offset": 2023
            }
        },
		// ... 149 items elided
        {
            "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
            "position": {
                "line": 107,
                "character": 8
            },
            "label": "contains",
            "sortText": "151",
            "kind": 17,
            "data": {
                "languageId": "javascript",
                "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
                "offset": 2023
            }
        }
    ]
}

[Trace - 7:15:50 PM] Sending request 'completionItem/resolve - (101)'.
Params: {
    "label": "badge",
    "insertTextFormat": 1,
    "kind": 5,
    "sortText": "05",
    "data": {
        "languageId": "javascript",
        "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
        "offset": 2023
    }
}

[Trace - 7:15:51 PM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
    "diagnostics": [
        {
            "range": {
                "start": {
                    "line": 107,
                    "character": 8
                },
                "end": {
                    "line": 107,
                    "character": 8
                }
            },
            "severity": 1,
            "message": "Identifier expected."
        }
    ]
}

[Trace - 7:15:51 PM] Received response 'textDocument/documentSymbol - (98)' in 2852ms.
Result: [
    {
        "name": "docs",
        "location": {
            "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
            "range": {
                "start": {
                    "line": 0,
                    "character": 0
                },
                "end": {
                    "line": 41,
                    "character": 7
                }
            }
        },
        "containerName": "",
        "kind": 8
    },
	// ... about 100 items elided
    {
        "name": ".pb-tag__badge + .pb-tag__dismiss",
        "kind": 5,
        "location": {
            "uri": "file:///c%3A/Users/zachb/git/repo/public/src/components/Tag.vue",
            "range": {
                "start": {
                    "line": 225,
                    "character": 0
                },
                "end": {
                    "line": 227,
                    "character": 1
                }
            }
        }
    }
]

[Trace - 7:15:51 PM] Received response 'textDocument/documentLink - (99)' in 2656ms.
// (removed)

[Trace - 7:15:52 PM] Received response 'textDocument/documentColor - (100)' in 3230ms.
// (removed)

[Trace - 7:15:52 PM] Received response 'completionItem/resolve - (101)' in 1840ms.
// (removed)

@gambolputty
Copy link

No Intellisene for me in Vue files, but in js files. After replacing the exclude with the include option in my jsconfig.json it worked (thanks @UltimaBeaR!):

{
  "compilerOptions": {
    "target": "es2017",
    "baseUrl": "src",
    "module": "commonjs"
  },
  "include": ["./src/**/*"]
}

@karlito40
Copy link

karlito40 commented Feb 26, 2019

I'm encountering the same problem with the emmet auto suggestion on all my SFC. In my case it looks to be cause by the size of my project. Everything works fine when i load those components in a separate vscode window.

Removing my .jsconfig does also make the auto suggestions appear.

@coppyC
Copy link

coppyC commented Feb 27, 2019

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

@mattixittam
Copy link

mattixittam commented Mar 11, 2019

Can confirm 2-second delay for suggestions on my 2017 MBP using jsconfig in my project (containing about 500 .vue/.js files).

The jsconfig file doesn't even need to contain anything. An empty jsconfig (or one containing an empty object) triggers the delay as well.

@octref
Copy link
Member

octref commented May 8, 2019

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.

@octref octref closed this as completed May 8, 2019
@qwqcode
Copy link

qwqcode commented Dec 22, 2019

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

@gooqiao
Copy link

gooqiao commented Mar 27, 2020

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

I have this problem, too.
@octref

@rennzhang
Copy link

我在 vue2中没有这个问题,vue3中很严重,大概有2~3s 的延迟

@gah98
Copy link

gah98 commented Dec 15, 2021

How to solve this problem

@carlos00027
Copy link

carlos00027 commented Feb 4, 2022

in root folder create file vetur.config.js

module.exports = {
// optional default: {}
// override vscode settings
// Notice: It only affects the settings used by Vetur.
settings: {
"vetur.useWorkspaceDependencies": true,
"vetur.experimental.templateInterpolationService": true
},
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests