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

Allow analyzing Vue files in node_modules #1127

Closed
3 tasks done
ProTip opened this issue Feb 28, 2019 · 2 comments · Fixed by #1979
Closed
3 tasks done

Allow analyzing Vue files in node_modules #1127

ProTip opened this issue Feb 28, 2019 · 2 comments · Fixed by #1979

Comments

@ProTip
Copy link

ProTip commented Feb 28, 2019

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

Info

  • Platform: Linux
  • Vetur version: 0.16.2
  • VS Code version: 1.30.2

Problem

This is more of a feature request. I'm currently working on a Vue/TypeScript project in which we are sharing an shared, uncompiled "source" package between different projects. Currently Vetur appears to avoid analyzing anything in a node_modules path causing the imported type to fall back on the generic shim interface definition.

I have removed node_modules check from here in my extension locally and confirmed the imported type is resolved correctly:

return path.endsWith('.vue.ts') && !path.includes('node_modules');

I would like to have the option to include packages in node_modules for analysis. For TypeScript's part I simply need to add the package to the includes section of tsconfig.json and it will work. Perhaps the option to trust the TypeScript includes would suffice?

@octref
Copy link
Member

octref commented Mar 21, 2019

For TypeScript's part I simply need to add the package to the includes section of tsconfig.json and it will work.

So you are including node_modules in tsconfig?

Perhaps the option to trust the TypeScript includes would suffice?

I turned off node_modules since this is a major source for perf issues.

If you do include node_modules/<package>/**/*.vue, they should show up here:

const files = parsedConfig.fileNames;

Then you can stop ignoring these vue files selectively in the service host. Are you interested in doing a PR?

@tiagoroldao
Copy link
Contributor

@octref ran into this issue on 0.24.0

Tracked it here, in the current code:

/**
* If the path ends with `.vue.ts`, it's a `.vue` file pre-processed by Vetur
* to be used in TS Language Service
*/
export function isVirtualVueFile(path: string) {
return path.endsWith('.vue.ts') && !path.includes('node_modules');
}

Paths are not ignored, added to tsconfig like so:

  "include": [
    "src/**/*.ts",
    "src/**/*.vue",
    "node_modules/ah-common-lib/**/*.ts",
    "node_modules/ah-common-lib/**/*.vue"],
  "exclude": []

And debugging reveals that the typescript never checks for "Foo.vue" and rather attempts all variants (including "Foor.vue.ts"). Adding the files to parsedConfig (through tsConfig changes) makes no difference as it is the vue

Removing the !path.includes('node_modules') check fixes the issue:

  • is there a need for the check?
  • is this for performance reasons?
    • if so, can potentially pass scriptFileNameSet to vueSys and use it to check for file presence in the included files

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

Successfully merging a pull request may close this issue.

3 participants