Webpack: Tip: Component names should be unique for better debugging experience

Created on 20 Jan 2018  Β·  3Comments  Β·  Source: vuejs-templates/webpack

Don't do this:

β”œβ”€β”€β”€components
β”‚   β”‚
β”‚   └─────A
β”‚   β”‚             PageA.vue
β”‚   β”‚             MyComponent.vue
β”‚   └─────B
β”‚   β”‚             PageB.vue
β”‚   β”‚             MyComponent.vue <-- duplicate name

Code from B/MyComponent will work, but the Chrome debugger may show the code for
A/MyComponent when you are trying to debug B/MyComponent. (MyComponent.vue will only show up once in the devtools Sources pane.)

All component names should be unique to make debugging easier.

Do this:

β”œβ”€β”€β”€components
β”‚   β”‚
β”‚   └─────A
β”‚   β”‚             PageA.vue
β”‚   β”‚             MyComponentA.vue
β”‚   └─────B
β”‚   β”‚             PageB.vue
β”‚   β”‚             MyComponentB.vue <-- unique name

Any one else run into this? I'd love to see more tips and tricks for debugging in Chrome when developing using the webpack dev server.

Most helpful comment

use eval-source-map instead of cheap-module-eval-source-map when setting devtool

All 3 comments

Better yet: provide a name: for each component.

Eslint-plugin-vue can help you remind you.

Not meaning to play the bad parent, but conversations like this are better suited for forum.vuejs.org or chat.vuejs.org

Thanks @LinusBorg for the suggestion. FYI - I assigned a unique name: for the components with duplicate file names, but Chrome's sources tab still shows only one MyComponent.vue entry when expanding webpack:// folder. The debugger displays the file name, not the name from the name: attribute. The code runs OK, but I can't use the debugger in the second instance of the component with the same file name.

use eval-source-map instead of cheap-module-eval-source-map when setting devtool

Was this page helpful?
0 / 5 - 0 ratings

Related issues

happy760690 picture happy760690  Β·  3Comments

nicolas-t picture nicolas-t  Β·  4Comments

rkrejcii picture rkrejcii  Β·  4Comments

exarus picture exarus  Β·  3Comments

paulgeisler picture paulgeisler  Β·  3Comments