Skip to content

Commit ad462f4

Browse files
committed
Don't use import resource cache if there are custom importers
The import resource cache prevent custom importers from being called for all imports. This happens because we during the import resolution we cache the resources parsed AST tree and simply substitute it for future reference to that resource. If that resource has it's own imports those imports are only resolved the first time the file is parsed. Although this is a nice optimisation, it does negatively affect custom importers. Rather than disabling the resource caching wholesale, this patch disables it only if a custom importer has been registered.
1 parent 0a05c8d commit ad462f4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/context.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,9 @@ namespace Sass {
351351

352352
// process the resolved entry
353353
else if (resolved.size() == 1) {
354+
bool use_cache = c_importers.size() == 0;
354355
// use cache for the resource loading
355-
if (sheets.count(resolved[0].abs_path)) return resolved[0];
356+
if (use_cache && sheets.count(resolved[0].abs_path)) return resolved[0];
356357
// try to read the content of the resolved file entry
357358
// the memory buffer returned must be freed by us!
358359
if (char* contents = read_file(resolved[0].abs_path)) {

0 commit comments

Comments
 (0)