Skip to content

Improve SourceMap Handling #1163

Closed
Closed
@auchenberg

Description

@auchenberg

We on the VS Code team just released a debugging recipe for Vue.js, to allow our Chrome debugger to debug Vue, and during this release we discovered some fundamental problems with the sourcemaps generated by vue-loader used in the webpack projects generated by vue-cli,

Observed problems

  • The generated sourcemaps seems to be invalid and unreadable for tools like https://sokra.github.io/source-map-visualization/

  • Stepping in debuggers like Chrome DevTools and VS Code doesn't work as expected, as we experience "sliding breakpoints" caused by missing mappings that causes us to "slide" the breakpoint down to the next line we have mappings for. Causes experiences like:
    chromw1

  • Mappings for simple statements seems to be missing/wrong, which causes debuggers to load the compiled source, which causes experiences like, where a breakpoint is set on line 94, but is in reality set in a different place.
    chrome2

  • Generated entries for sourcefiles are added to the sourcemap under the . path, which creates confusion, as the files under ./src are generated outputs, and not the original authoring abstraction. This is causing problems for debuggers like VS Code that relies on mappings between the served bundle and the original original authoring abstraction.

screen shot 2018-02-13 at 5 19 29 pm

In this example the original authoring abstraction is also referenced under /src/components/HelloWorld.vue

  • Using let statements for variables seems to cause problems for the sourcemaps, as both VS Code and Chrome DevTools can't step over the statements, but stays on the same line when using step-over.

chrome3

Steps to reproduce

  1. Generate webpack project by vue-cli
  2. Add a few new lines to line 90 in HelloWorld.vue, so you have logic like:
export default {
  name: 'HelloWorld',
  data () {
    var a = 1
    var b = 2
    var c = 3
    var d = a+c
    return {
        msg: 'Welcome to Your Vue.js App' + d
    }
  }
}
  • Open up Chrome DevTools or the VS Code debugger, and try to set breakpoints in HelloWorld.vue

Relevant issues

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