Skip to content

.ts 文件里 import .vue 文件,会无法定位 #3170

@masquevil

Description

@masquevil

Describe the bug

问题一

vscode 编辑器,在 .ts 或 .js 文件里 import .vue 文件,会无法定位到文件,只能定位到 shims-vue.d.ts ,在 .vue 文件里 import .vue 文件则没有问题:

注意联想框里没有 entry.vue 文件:
截屏2021-04-27 下午1 41 08

command + 点击跳转,会跳转到 shims-vue.d.ts:
截屏2021-04-27 下午1 41 32

问题二

.vue 文件里 import .vue 文件可以定位,但会找到两个模块,是同一个文件,但是是不同的范围:

找到了两个 module:
截屏2021-04-27 下午2 02 25

点第一个进去,会选中 <script> 标签内的全部内容
截屏2021-04-27 下午2 03 47

点第二个进去,会选中从 <script> 标签开始,到文件结尾
截屏2021-04-27 下午2 04 53

问题三

import Comp from './xxx/yyy'

如果不写 .vue 以及 index.vue,则不能识别到对应的文件

Reproduction

https://github.com/masquevil/stock

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: macOS 11.0.1
    CPU: (4) x64 Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz
    Memory: 415.90 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.14.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.11.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 90.0.4430.93
    Firefox: 72.0.2
    Safari: 14.0.1
  npmPackages:
    @vitejs/plugin-vue: ^1.2.1 => 1.2.1 
    vite: ^2.1.5 => 2.1.5 

Used package manager:
yarn

Logs


Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions