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

Not prepending sourceRoot when parsing source maps #126

Closed
nainslie opened this issue Jan 11, 2017 · 0 comments
Closed

Not prepending sourceRoot when parsing source maps #126

nainslie opened this issue Jan 11, 2017 · 0 comments
Labels
Milestone

Comments

@nainslie
Copy link
Contributor

nainslie commented Jan 11, 2017

From the v3 source map specification, sourceRoot is:

an optional source root, useful for relocating source files on a server or removing repeated values in the “sources” entry. This value is prepended to the individual entries in the “source” field.

In my workflow I'm generating a single js bundle from individual TypeScript files. Using gulp-sourcemaps I'm getting a source map for a single JS file that looks like

{"version":3,
"sources":["/src/App.ts","/src/common/Capability.ts","/src/common/controllers/AboutController.ts",
... snip approx 60 more files ...],
 "file":"tsbundle.js","sourceRoot":"../.."}

The sourceRoot is being generated relative to the destPath I specified when writing out sourceMaps. The whole gulp task looks like:

gulp.task('tsc', ['template'], function () {
    return tsProject.src()
        .pipe(sourcemaps.init()) // This means sourcemaps will be generated
        .pipe(tsProject())
        .js
        .pipe(sourcemaps.write('.', { destPath: 'www/js', includeContent: false }))
        .pipe(gulp.dest("www/js"));
});

Important to note here is that, although the sources specified in the sourcemap look like absolute paths, once the sourceRoot is prepended (per the spec) they become relative paths.

However, remap-istanbul interprets them as absolute paths and tries to load files like C:\src\App.ts, which don't exist.

I have a fix for this and will put together a pull request shortly.

@dylans dylans added the bug label Jan 11, 2017
@dylans dylans added this to the 0.9.0 milestone Jan 11, 2017
nainslie added a commit to nainslie/remap-istanbul that referenced this issue Jan 11, 2017
nainslie added a commit to nainslie/remap-istanbul that referenced this issue Jan 11, 2017
nainslie added a commit to nainslie/remap-istanbul that referenced this issue Jan 11, 2017
nainslie added a commit to nainslie/remap-istanbul that referenced this issue Jan 11, 2017
@dylans dylans closed this as completed in 6e40c3a Jan 22, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants