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

Add imported URIs getter to ImportCache #1355

Closed
wants to merge 1 commit into from
Closed

Conversation

irundaia
Copy link

@irundaia irundaia commented Jun 12, 2021

Hi,

I was looking to implement a feature in dart-sass-embedded, to expose all imported URIs (see sass/embedded-protocol#62).

However, to do this using the current api's, I'd have to first setup a StylesheetGraph including an ImportCache, then use the graph to load the to-be-compiled file, and then compile the file as normal.
I think it would be easier, to expose a getter on the ImportCache class to expose all imported canonical URIs.

@nex3
Copy link
Contributor

nex3 commented Jun 14, 2021

We already track similar information in _EvaluateVisitor._includedFiles. Although this is specifically made to match Node Sass's API and so only handles filesystem paths, it could be made to handle URLs instead and then converted to filesystem paths in node.dart.

The real question is how we expose this from the public Dart API. The public compile* methods all return strings, which are difficult to add extra information to. Ideally we'd return a CompileResult like we do for the internal compile* methods, but that would be a breaking change at this point. It's probably easiest to just do the same thing we do for source maps, and have users pass in a callback that gets passed the URLs.

nex3 added a commit that referenced this pull request Jul 14, 2021
This also exposes CompileResult.includedUrls.

Closes #1355
Partially addresses sass/embedded-protocol#62
@nex3
Copy link
Contributor

nex3 commented Jul 14, 2021

Thanks for the contribution! I've ended up going a different direction in #1398, but I really appreciate you pitching in!

@nex3 nex3 closed this Jul 14, 2021
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

Successfully merging this pull request may close these issues.

None yet

2 participants