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

Wrong paths in source maps #95

Closed
thorn0 opened this issue Sep 3, 2014 · 0 comments · Fixed by #117
Closed

Wrong paths in source maps #95

thorn0 opened this issue Sep 3, 2014 · 0 comments · Fixed by #117
Labels

Comments

@thorn0
Copy link
Contributor

thorn0 commented Sep 3, 2014

Please consider this simple demo configuration: https://github.com/thorn0/grunt-contrib-concat-sourcemaps-bug

After compiling TypeScript, we have this structure:

src
|   bar.ts
|
\---foodir
        foo.ts
build
|
\---src
    |   bar.js
    |   bar.js.map       -- correctly refers to ../../src/bar.ts`
    |
    \---foodir
            foo.js
            foo.js.map  -- correctly refers to ../../../src/foodir/foo.ts

But after concatenation, we get build/foobar.js.map, which has the following contents in its sources field: ["../src/bar.ts","../../src/foodir/foo.ts"], while it should be ["../src/bar.ts","../src/foodir/foo.ts"].

Also, README states that the default value for the sourceMapStyle option is embed, so I expected to find the TypeScript sources inside of foobar.js.map, but it's not there.

riaann added a commit to riaann/grunt-contrib-concat that referenced this issue Feb 17, 2015
On windows, node's path api returns backslashes for path separators.
Because the source-map library expects forward slashes in all cases,
their relative path logic (specifically their "normalize" function)
gives incorrect results when passing in backslash.  The
mozilla/source-map library won't change this, because they are actually
expecting URLs as input - see
mozilla/source-map#91 (comment).

This fix is similar to the one made for grunt-contrib-uglify:
gruntjs/grunt-contrib-uglify#175.

This should fix issue gruntjs#110 and gruntjs#95.
riaann added a commit to riaann/grunt-contrib-concat that referenced this issue Feb 18, 2015
On windows, node's path api returns backslashes for path separators.
Because the source-map library expects forward slashes in all cases,
their relative path logic (specifically their "normalize" function)
gives incorrect results when passing in backslash.  The
mozilla/source-map library won't change this, because they are actually
expecting URLs as input - see
mozilla/source-map#91 (comment).

This fix is similar to the one made for grunt-contrib-uglify:
gruntjs/grunt-contrib-uglify#175.

Standardized line endings for test fixtures by enforcing LF end of files for fixtures directory
(through repository .gitattributes).  This change was needed
because the expected output of source maps are based on input files with LF, rather
than CRLF. Before this change the tests were breaking due to git autocrlf on Windows.
The difference between the source maps generated from input
files using CRLF and the source maps generated from input files using
only LF can't be normalized in the test, due to the nature of the
changes:  the offsets in the source map are changed, as well as the
embedded source.  These kinds of changes aren't as simple to normalize
as just line feeds in output files - and such normalization would be too
invasive, to the point of making the test less effective.

This should fix issue gruntjs#110 and gruntjs#95 and all unit tests should now pass.
@XhmikosR XhmikosR added the bug label Feb 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants