-
Notifications
You must be signed in to change notification settings - Fork 465
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
@import's processed breadth-first instead of depth-first #1262
Comments
This is related to #872 |
I've done some experimenting here and as far as I can tell Libsass acts the same as Ruby Sass. I've compared SassC, Ruby Sass, and node-sass async render (with and without a custom importer). The behaviour is identical. Please confirm this is not a logic bug in your plugin, otherwise provide a test using SassC directly that show this error. |
I think this import-once approach may have some trouble due to #1160. Would love to see a self-contained test. |
Thanks. I'll work on getting a self-contained example today. |
Ok I've been able to confirm that although the imports are being resolved depth-first (i.e. the output is correct), the custom importers are being execute breadth-first. This looks like an issue with custom importers. |
Is this different from ruby sass? Since it seems normal to me - when the piece of code is encountered, it is executed; if the file is about to be included we need to call the importer, parse and execute contents. I guess that the "import once" functionality simply overshadows the old definition of "component/color" and then you get the error. Does it work without the "import once" functionality? |
This issue is independent of any import-once functionality. To be clear Libsass is resolving the imports in the expected order, so all code works as expected. However the custom importers aren't not fired as expected. I have a proof of concept I'm iterating on. First I need to determine if the issue is on the node-sass side or the Libsass C API side. |
That's been my experience as well; the resulting .css is correct (thus it is difficult to make a spec in sass-spec). However, the following patch to libsass shows the problem, diff --git a/parser.cpp b/parser.cpp
index 2c6bc72..ec41473 100644
--- a/parser.cpp
+++ b/parser.cpp
@@ -236,6 +236,7 @@ namespace Sass {
{
bool has_import = false;
string load_path = unquote(import_path);
+ cout << "-- " << import_path << "\n";
for (auto importer : importers) {
// int priority = sass_importer_get_priority(importer);
Sass_Importer_Fn fn = sass_importer_get_function(importer); /* example.scss */
@import "_one.scss";
@import "_three.scss";
/* _one.scss */
@import "_two.scss";
.one { color: #100; }
/* _two.scss */
.one { color: #200; }
/* _three.scss */
.one { color: #300; } compiling sassc with the patched libsass,
Which means that importers will see |
Confirmed the import ordering is a problem (results below), but compilation is correct. Good catch @pkmiec ! The custom importer is being pinged for every import breadth first. It will require a more complex process where the parser sends every import encountered to the custom importer, waits for the response, then continues. Going on and on until it finds no more imports.
The latter example...
|
Makes import resolve depth-first instead of breadth-first Fixes sass#1262
This should be fixed by #1528! I get now this
|
Makes import resolve depth-first instead of breadth-first Fixes sass#1262
Makes import resolve depth-first instead of breadth-first Fixes sass#1262
Makes import resolve depth-first instead of breadth-first Fixes sass#1262
Makes import resolve depth-first instead of breadth-first Fixes sass#1262
Makes import resolve depth-first instead of breadth-first Fixes sass#1262
Makes import resolve depth-first instead of breadth-first Fixes sass#1262
I'm looking to speed up my asset compilation by switching from http://github.com/rails/sass-rails to http://github.com/bolandrm/sassc-rails. I have created http://github.com/appfolio/sassc-import_once to provide "import once" functionality that's normally provided by http://github.com/Compass/compass/tree/master/import-once for Sass.
The problem is that
@import
seems be processed by sassc / libsass breadth-first instead of depth-first. Here is how why that matters,Using sassc (with my sassc-import_once) produces,
The reason is that files are imported in the following order,
Notice the
component/color
fromcomponent.scss
is imported first ... this causes the "import once" from re-importingcomponent/color
next it is seen.The depth-first approach would import files in the following order,
I have a failing test that replicates this case,
edit: fixed typos
The text was updated successfully, but these errors were encountered: