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

LibSass source maps don't return file system paths, correct? #2651

Closed
npetruzzelli opened this issue May 23, 2018 · 2 comments
Closed

LibSass source maps don't return file system paths, correct? #2651

npetruzzelli opened this issue May 23, 2018 · 2 comments

Comments

@npetruzzelli
Copy link

This is a general question, which didn't seem to have specific guidelines in https://github.com/sass/libsass/blob/master/.github/CONTRIBUTING.md, I'll do my best to be thorough.

I originally asked this question in node-sass ( sass/node-sass#2393 ), but it sounds like that wasn't the appropriate place for it.


My understanding is that source maps only work with URLs (though I have an issue open to confirm this), not file system paths, though I found the following comment in a popular node package

https://github.com/webpack-contrib/sass-loader/blob/2529c0716b1bca321c22d16636b1385682b1c730/lib/loader.js#L90-L94

            // node-sass returns POSIX paths, that's why we need to transform them back to native paths.
            // This fixes an error on windows where the source-map module cannot resolve the source maps.
            // @see https://github.com/webpack-contrib/sass-loader/issues/366#issuecomment-279460722
            result.map.sourceRoot = path.normalize(result.map.sourceRoot);
            result.map.sources = result.map.sources.map(path.normalize);
  • Question 1: Can you confirm whether or not this comment is accurate?
  • Question 2: Can you confirm whether or not libsass source maps aim to adhere to the Source Map Revision 3 Proposal? If not, can you point me to the documentation for the spec you are adhering to?

Thanks and regards

@mgreter
Copy link
Contributor

mgreter commented May 23, 2018

If the sources are not absolute URLs after prepending of the “sourceRoot”, the sources are resolved relative to the SourceMap (like resolving script src in a html document).

This is what libsass does, so we do adhere to the v3 draft. Since they are relative they are also valid relative "posix" paths. Hth

@npetruzzelli
Copy link
Author

npetruzzelli commented May 24, 2018

Got it, thank you!

So if I were to explain it to someone else, then I'd be telling them that relative URLs only appear to be POSIX paths because:

  • They both use . to represent the current directory
  • They both use .. to represent the parent directory
  • They both use / to represent a segment/directory separator

In the case of relative paths, there are not URI protocols, domains, or ports, so it otherwise is a valid POSIX filesystem path (assuming the relative path does not have a hash or a query string.)

Would it be too confusing to bring up symbolic links here?

And more information can be found:


Does that sound about right?

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

No branches or pull requests

2 participants