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

Include loaded URLs in failed compilation result #3830

Open
aduth opened this issue Apr 8, 2024 · 3 comments
Open

Include loaded URLs in failed compilation result #3830

aduth opened this issue Apr 8, 2024 · 3 comments
Labels
enhancement New feature or request JS API About the shared JS API planned We would like to add this feature at some point

Comments

@aduth
Copy link

aduth commented Apr 8, 2024

For the same reasons as described in #3577 , it can be useful to know which files were loaded at the time of a compilation failure. For example, watching those files and recompiling once one of the files are saved.

Currently, handleCompileResult wraps response.result.value into the thrown exception.

https://github.com/sass/embedded-host-node/blob/eabbe379fe1224be32a1b8c36d7c0f3ca1913fe2/lib/src/compiler/utils.ts#L220-L221

Based on my understanding of linked issues, loaded files would be available at response.loadedUrls, but there is no way to access this value when catch-ing the thrown error. If more of the raw response value were included in the exception, it could be possible to access this from a catch handler.

My use-case is a compiler wrapper for sass-embedded which includes a "watch" option to recompile on save. When a compilation error occurs, I currently resort to parsing through the Sass stack trace to find the files to watch, but this has proven to be both error-prone and unstable.

@nex3 nex3 transferred this issue from sass/embedded-host-node Apr 8, 2024
@nex3
Copy link
Contributor

nex3 commented Apr 8, 2024

Moving this to the language repo because JS API updates have to go through the spec process. I agree that the set of loaded files should be exposed through the JS API on error, though. Do you have any interest in making this change?

@nex3 nex3 added planned We would like to add this feature at some point JS API About the shared JS API enhancement New feature or request labels Apr 8, 2024
@aduth
Copy link
Author

aduth commented Apr 22, 2024

Thanks for moving the issue to the correct location. I'd have an interest in seeing this forward, though may not have the bandwidth to do so right away. Happy to let someone else take it up, but if nobody beats me to it by the time I free up some availability, I can try to give it a shot!

Is this the process which should be followed for that? https://github.com/sass/sass/blob/main/CONTRIBUTING.md#process

@nex3
Copy link
Contributor

nex3 commented Apr 22, 2024

That's right!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request JS API About the shared JS API planned We would like to add this feature at some point
Projects
None yet
Development

No branches or pull requests

2 participants