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 "sources" array should be resolved relative to source map #1348

Closed
nex3 opened this issue Apr 13, 2020 · 2 comments
Closed

Source map "sources" array should be resolved relative to source map #1348

nex3 opened this issue Apr 13, 2020 · 2 comments
Milestone

Comments

@nex3
Copy link
Contributor

nex3 commented Apr 13, 2020

Currently, if a previous source map's "sources" array contains relative URLs, those URLs are interpreted as relative to the current working directory rather than the location of the source map. This produces incorrect original file paths, which is particularly problematic in error messages. In conjunction with #1347, this makes it essentially impossible to correctly handle source map paths for CSS files outside the current working directory.

// test.js
const postcss = require('postcss');
const fs = require('fs');

const root = postcss.parse(
  fs.readFileSync('subdir/test.css', 'utf8'), {from: 'subdir/test.css'});
console.log(root.source.input.origin(1, 1));
$ echo 'a {b: c}' > test.scss
$ mkdir subdir
$ sass test.scss subdir/test.css
$ pwd
/home/nweiz/goog/postcss
$ node test.js
{ file: '/home/nweiz/goog/test.scss', line: 1, column: 0 }

Note that the file path is /home/nweiz/goog/test.scss, while it should be /home/nweiz/goog/postcss/test.scss.

@alexander-akait
Copy link

alexander-akait commented Jul 22, 2020

I think will be great to add tests for absolute sources too, sass can generate absoute sources, so merging them should be correct, maybe tests already exist, just want to say it

@ai
Copy link
Member

ai commented Jul 22, 2020

@nex3 fixed 7ae3421

@evilebottnawi we already use absolute paths in opts.map.absolute test. Feel free to suggest some additional test.

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

No branches or pull requests

3 participants