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

sourceMap option documentation is inaccurate #2394

Comments

@nex3
Copy link
Contributor

nex3 commented May 24, 2018

The documentation for the sourceMap option claims that

Setting the sourceMap option requires also setting the outFile option

However, in practice, if you set sourceMap to a string and don't set outFile, you still get a map buffer in the result. For example:

var sass = require('node-sass');

var result = sass.renderSync({
  data: 'a {b: c}',
  sourceMap: 'out.css.map'
});
console.log(result.map.toString());

prints

{
        "version": 3,
        "file": "stdin.css",
        "sources": [
                "stdin"
        ],
        "names": [],
        "mappings": "AAAA,AAAA,CAAC,CAAC;EAAC,CAAC,EAAE,CAAC,GAAE"
}
@ericmorand
Copy link

ericmorand commented Apr 15, 2019

The Result object description is also inaccurate:

entry (String) - The path to the scss file, or data if the source was not a file

As seen on @nex3 example, when the source was not a file, the parh to the SCSS file is not data but stdin.

EDIT: Actually, I'm wrong, stats Result object is correctly returning "data" as entry path. Still it is inconsistent with the value returned in the source map "sources" which is "stdin".

saper added a commit to saper/node-sass that referenced this issue Oct 17, 2019
render() and renderSync() should return "map" property in the results
only if source map has been enabled.
@saper saper self-assigned this Oct 17, 2019
@saper
Copy link
Member

saper commented Oct 17, 2019

Thanks for this - there was even a small bug. render() has always provided a map with the undefined value if the map was not requested, unlike renderSync().

Fixed via #2754

@saper saper added this to Backlog in Documentation Oct 18, 2019
@saper saper moved this from Backlog to Review in Documentation Oct 18, 2019
@xzyfer xzyfer closed this as completed in 8498f70 Oct 24, 2019
xzyfer added a commit that referenced this issue Oct 24, 2019
Fix #2394: sourceMap option should have consistent behaviour
This was referenced Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment