Skip to content

Optimize the priority of calculating the displayed name of the component on devtool #2049

New issue

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

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

Already on GitHub? # to your account

Closed
Azurewarth0920 opened this issue Apr 10, 2023 · 0 comments · Fixed by #2050
Closed
Assignees

Comments

@Azurewarth0920
Copy link
Contributor

Vue devtools version

6.5.0

Link to minimal reproduction

https://play.vuejs.org/#eNpVjrsKwjAYhV/lN0sUpNklFlxEF1eXLKX5K4HcSNIilL67CZVAxu9cOGclN++7ZUZyITyOQfkEEdPse2GV8S4kuCuNr8Hg00r8whScAdoxVagUaQ2uEHCC7R/ZLWFHZ2MCEz9wLf6RPlBrB28XtDzQk7Cc7bt5MUNC4/WQMBMAb7dZFjmrCXIm9UW531alWvpqc1awbW8/zLdYMA==

Steps to reproduce & screenshots

SFC playground sample.

  1. Create SFC index.vue.
  2. import FileNameIndex from './index.vue'
  3. The component is registered as FileNameIndex, but Index is displayed on the devtool.

Screenshot 2023-04-10 at 11 09 08

Dev server sample.

  1. Create SFC ./FileNameIndex/index.vue.
  2. import FileNameIndex from './FileNameIndex/index.vue'
  3. The component is registered as FileNameIndex (by checking vm.$.components), but Index is displayed on the devtool.

Screenshot 2023-04-10 at 10 53 26

What is expected?

The registered name should have a higher display priority than the file name.

The name of the component should be displayed as the registered one: FileNameIndex

What is actually happening?

The file name of the Component is evaluated,
https://github.com/vuejs/devtools/blob/main/packages/app-backend-vue3/src/components/util.ts#L30

before the registered name.
https://github.com/vuejs/devtools/blob/main/packages/app-backend-vue3/src/components/util.ts#L33-L35

System Info

System:
    OS: macOS 13.2.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 3.77 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nodenv/versions/16.14.2/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.5.0 - ~/.nodenv/versions/16.14.2/bin/npm
  Browsers:
    Chrome: 111.0.5563.146
    Safari: 16.3

Any additional comments?

As the name field becomes unpopular in SFC setup syntax, the component's displayed name will always be determined by the file name of the component.

I'm using this kind of file structure in the project.

./TheComponent
  -/index.vue
  -/index.spec.ts

And the name displayed on the devtool will all become Index, which is not ideal.
The component registered name should have a higher priority to be selected as the component's name on devtool, as we register our component like this.

// setup script 
import TheComponent from './TheComponent(/index.vue)'
   //  ^^^^^^^^^^^ This name should become the component name.


// optional API
...
  components: {
    TheComponent
    // equals 'TheComponent': TheComponent
    //         ^^^^^^^^^^^^ This name should become the component name.
  }
...
@Azurewarth0920 Azurewarth0920 changed the title Optimize the priority of calculating the of the component Optimize the priority of calculating the displayed name of the component on devtool Apr 10, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
1 participant