vuejs / component-compiler-utils

Lower level utilities for compiling Vue single file components
319 stars 75 forks source link

Source-map issue on windows #47

Closed 3cp closed 5 years ago

3cp commented 5 years ago

First, mozilla/source-map doesn't support \ as separator at all, because it's designed to be consumed in browser.

https://github.com/mozilla/source-map/issues/91

  1. the file and sourceRoot has to be normalized. https://github.com/vuejs/component-compiler-utils/blob/8de35e69abc1d7ac9dc879237f0f2743c70b0327/lib/parse.ts#L91-L93
{
  file: filename.replace(/\\/g, '/'),
  sourceRoot: sourceRoot.replace(/\\/g, '/')
}

There is one more to be fixed in @vue/component-compiler. https://github.com/vuejs/vue-component-compiler/blob/afa1cd440123e2e0c195908c1e15935273ac64a9/src/assembler.ts#L77

  1. actually the default sourceRoot doesn't make much sense, because when serving the source-map to browser, process.cwd() is irrelevant. https://github.com/vuejs/component-compiler-utils/blob/8de35e69abc1d7ac9dc879237f0f2743c70b0327/lib/parse.ts#L52

Change to

sourceRoot = '',

With the above two fixes, it can fix https://travis-ci.org/dumberjs/gulp-vue-file/builds/477568946 Update: I managed to fix the gulp-vue-file bug within gulp-vue-file by rewriting sourcemaps (normalize sources and file path). But the incoming sourcemaps should also be fixed in vue compiler.

Let me know what you think, I can make some PRs for this.

sodatea commented 5 years ago

PRs are welcome :)