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 maps output #130

Open
zalky opened this issue Sep 3, 2022 · 4 comments
Open

Source maps output #130

zalky opened this issue Sep 3, 2022 · 4 comments

Comments

@zalky
Copy link

zalky commented Sep 3, 2022

Hi there,

I just recently tried to generate source maps via the embedded compiler and the source maps that are being generated are different than what you get from CLI dart-sass. The actual compiled css files are correct, the issue is just with the source maps.

With this embedded compile I'm getting something like:

{
    "version":3,
    "sourceRoot":"",
    "sources": ["file:///Users/user/src/project/test/resources/_dependency.scss","file:///Users/user/src/project/test/resources/dependent.scss"],
    "names":[],
    "mappings":"AAAA,kBACE,cAGF,iBACE"
}

Whereas dart-sass CLI produces something like:

{
    "version":3,
    "sourceRoot":"",
    "sources":["_dependency.scss","dependent.scss"],
    "names":[],
    "mappings":"AACA;EACI;;;ACEJ;EACI",
    "file":"dependent.css"
}

Specifically, the output "file" is missing, but more importantly the paths are absolute, which will probably break. Does this seem right?

I based my usage on the tests in SassCompilerTest.java, basically I just setGenerateSourceMaps on the compiler, and that was it. Is there some other configuration that I'm missing, or some usage example I may have missed?

Thanks for this great library!

@larsgrefer
Copy link
Owner

My library does nothing to the source map content. It only tells the embedded compiler to generate a source map and then passes the source map generated by the compiler back to you.

The embedded protocol actually enforces the missing file entry:

https://github.com/sass/embedded-protocol/blob/6e4c63c9ffd899ff7df5f64c531c647f0af43fb7/embedded_sass.proto#L290-L292

For the sources URLs I'm not sure if its my library or the embedded compiler which generates the absolute pahths

@zalky
Copy link
Author

zalky commented Sep 6, 2022

Gotcha. Well the absolute paths are easy enough to relativize post-hoc. Feel free to close this if you decide it is not an issue with the library.

Thanks again!

@larsgrefer
Copy link
Owner

I'm not sure what to do about this, yet.

On the one hand I completely understand that the current source maps (with absolute paths) are pretty useless.

On the other hand, I don't know how to improve the situation. Neither the embedded compiler nor my host library have enough context to create better source maps.

@zalky
Copy link
Author

zalky commented Feb 3, 2023

Apologies, I didn't want to open a whole other issue for this, but just wanted to stop by and say that there is now a Clojure dart-sass-clj wrapper around your library. Thanks for making that possible!

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