-
Notifications
You must be signed in to change notification settings - Fork 358
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
Importers not called for all imports #574
Comments
You're relying on a bug (or arguably a misfeature) in LibSass. This behavior wasn't replicated in Dart Sass because LibSass will eventually move away from it as well. This is disallowed because it violates the principle of locality, which says that it should be possible to reason about a stylesheet without knowing everything about how the entire system is set up. If a user tries to import a stylesheet relative to another stylesheet, that import should always work. It shouldn't be possible for some configuration somewhere else to break it. This is very relevant, for example, when dealing with importers that load files from load paths. If a user writes |
@nex3 it would be great if the There's nothing in the
EDIT: the part about content not defining variables, as actually because the correct return is |
This is a bug; Dart Sass should match Node Sass in this behavior. I've filed #681 to track this.
I agree that that documentation is not great. I recommend using the documentation on the Sass site instead. #680 updates the Dart Sass README to link to the Sass site documentation instead, and sass/sass-site#342 more clearly documents the order that imports are (supposed to be) resolved in. |
Hi Natalie. I'd like to re-open this thread.
I do agree that it violates the principle of locality. But those who write custom importers know what they're doing (like me :) ) And I understand all pros and cons of violating some architecture principles. In fact, the main purpose of something "custom" is to be able to override things which work not the way you need. I can bring you an example and the reason why we need to resolve imports with custom importer first: Overall, my message that it'd be great to change the priority of import resolvers and make custom importer the very first in the queue. Thank you for your work! |
In the upcoming JS API refactor, we're planning to make importers work more like they do in Dart Sass (and like they originally did in Ruby Sass). This means that a relative import from a file loaded by an importer will be given to the same importer at first, which should satisfy your use case without requiring that importers universally take precedence over filesystem-relative imports. |
I stumbled on this too, today. |
I believe this is the same issue that's been discussed in the recent comments of #9. When importing a file by its relative path, custom importers are only called if the file is not found. I've put together a simple way to reproduce this with 3 bash commands:
The only thing logged is
when I would expect to also see the importer receive
exists
.The text was updated successfully, but these errors were encountered: