Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Source-map issue on windows #47

Closed
3cp opened this issue Jan 10, 2019 · 1 comment · Fixed by #51
Closed

Source-map issue on windows #47

3cp opened this issue Jan 10, 2019 · 1 comment · Fixed by #51

Comments

@3cp
Copy link
Contributor

3cp commented Jan 10, 2019

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

mozilla/source-map#91

  1. the file and sourceRoot has to be normalized.
    const map = new SourceMapGenerator({
    file: filename,
    sourceRoot
{
  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.
    sourceRoot = process.cwd(),

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
Copy link
Member

sodatea commented Jan 14, 2019

PRs are welcome :)

@znck znck closed this as completed in #51 Jan 14, 2019
znck pushed a commit that referenced this issue Jan 14, 2019
#51)

This enforces separator '/' is used for any OS. It also changed sourceRoot default value from process.cwd() to empty string, because
local directory is irrelevant in browser where sourceMap is consumed.

closes #47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants