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 - Producing invalid JSON #242

Closed
am11 opened this issue Jan 11, 2014 · 10 comments · Fixed by #441 or #451
Closed

SourceMap - Producing invalid JSON #242

am11 opened this issue Jan 11, 2014 · 10 comments · Fixed by #441 or #451

Comments

@am11
Copy link
Contributor

am11 commented Jan 11, 2014

Cc: sass/node-sass#218

Like LESS, please replace \ with \\ in file paths in .map files.

Here is what I am getting:

{
    "version": 3,
    "file": "C:\Users\Adeel\Documents\Visual Studio 2013\WebSites\WebSite1\1\2\3\SASS\cd.scss",
    "sources": [
        "C:\Users\Adeel\Documents\Visual Studio 2013\WebSites\WebSite1\1\2\3\SASS\cd.scss"
    ],
    "names": [

    ],
    "mappings": "AAsCA;EACI,QAAQ;;AAGZ,MAAM,OAAO,UAAU;EArCnB,aAAa;EAwCb,WAAW;;AAEf,IAAI,IAAI,IAAI,IAAI;EA1CZ,aAAa;;AA8CjB;EACI,OAAO;EACP,WAAW;EACX,YAAY;EACZ,eAAe;;AAEnB;EACI,WAAW;;AAEf;EACI,OAAO;EACP,YAAY;;AAEhB;EA3DI,aAAa;EA8Db,WAAW;;AAGf;EACI,YAAqC;EACrC,YAAY;EAEZ,eAAe;EAJnB,UAKI;IACI,QAAQ;IACR,kBAAkB;;AAKtB;EADJ,MAEQ;IAAQ,SAAS;EAFzB,MAGQ;IAAQ,SAAS;AAErB;EALJ;IAMQ,SAAS;IANjB,MAOQ;MAAQ,SAAS;AAErB;EATJ;IAUQ,SAAS;IAVjB,MAWQ;MAAQ,SAAS;AAXzB,MAcI;EAAK,QAAQ"
}

which is an invalid JSON

The expected result (the valid JSON) can be achieved by replacing \ in file paths with \\.

Also, (OAN) the value of file is supposed to be path to output CSS, not the input SCSS (sass/node-sass#219).

Thank you.

@ghost
Copy link

ghost commented Jan 11, 2014

@am11 I have created a separate issue to track the file bug in issue #243. I'm working on a fix.

I do not use Windows, but I will look to setup a Windows VM to look at this issue.

@am11
Copy link
Contributor Author

am11 commented Jan 11, 2014

@svnieuw, thanks for your input.

The LESS compiler generates the sourcemap with \\ in file paths in Windows. We solved those in the post-processing step in SAAS compiler class of Web Essentials extension for VS. On the contrary, we didn't need that step in the corresponding function of LESS compiler class.

@nschonni
Copy link
Collaborator

I don't think the Windows style paths are valid whether they are escaped or not. Going by the spec https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#! any paths need to be in URL format

@am11
Copy link
Contributor Author

am11 commented Jan 11, 2014

@nschonni, yes. Ideally, it should calculate relative paths of destination file (.css) and all the sources .scss in map, from map file as a reference. Note, the map file can also be generated at different location than css and the source scss files.

There is a C++ Windows system function PathRelativePathTo() in shlwapi.dll, which calculates relative paths from a point of reference.

@am11
Copy link
Contributor Author

am11 commented Jan 11, 2014

Total Paths:

  • From .map to .css file; for "file: " value in JSON.
  • From .map to all .scss files; for "sources[]" values in JSON.
  • From .css to .map file; for /*# SourceMap .. / comment.

@am11
Copy link
Contributor Author

am11 commented Jan 13, 2014

FWIW, here is how we can consume shlwapi.dll in C# managed code madskristensen/WebEssentials2013#134 (comment).

am11 referenced this issue in SLaks/WebEssentials2013 Jan 14, 2014
About 1/4th done.
Also correct some usages & properties.
Fixes madskristensen#480, madskristensen#387
SLaks added a commit to SLaks/WebEssentials2013 that referenced this issue Jan 14, 2014
SLaks added a commit to SLaks/WebEssentials2013 that referenced this issue Jan 21, 2014
SLaks added a commit to SLaks/WebEssentials2013 that referenced this issue Jan 22, 2014
@am11 am11 changed the title SourceMap: Replace \ with \\ in map files SourceMap: Producing invalid JSON Mar 29, 2014
@am11 am11 changed the title SourceMap: Producing invalid JSON SourceMap - Producing invalid JSON Mar 29, 2014
am11 added a commit to am11/WebEssentials2013 that referenced this issue Apr 24, 2014
am11 added a commit to am11/WebEssentials2013 that referenced this issue Apr 24, 2014
@am11
Copy link
Contributor Author

am11 commented May 4, 2014

@svnieuw, @nschonni, is it solved by eeee3a8 and ef3eadb? I just found these in merged commits (https://github.com/hcatlin/libsass/commits/master).

@andrew, can you please give us an estimate; when would this fix be available in node-sass?

Thanks. :)

@nschonni
Copy link
Collaborator

nschonni commented May 5, 2014

The changes were from #329, but I still believe that this was patched in the wrong place.

Node-sass won't be updated anytime soon because there are more regressions for @extend since the last submodule update.

@am11
Copy link
Contributor Author

am11 commented Jul 14, 2014

@nschonni, can you please code-review my PRs for libsass and on node-sass repo?

I am preparing another set of commits, which require merging of those branches (cherry-pick).

Would be fantastic, if those changes would make their way in v2.0.

Thanks in anticipation :)

akhleung pushed a commit that referenced this issue Jul 28, 2014
SourceMap: Fix relative paths for Windows (#242)
@am11
Copy link
Contributor Author

am11 commented Jul 28, 2014

Thank you so much @akhleung for merging this.

@nschonni, as per your convenience, could you please review my PRs on node-sass? I have some other minor related fixes in my backlog for both repos. Thanks in anticipation.

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