sveetch / boussole

Command line interface to build Sass projects using 'libsass-python'.
http://boussole.readthedocs.io
MIT License
10 stars 5 forks source link

Import resolution #37

Open sveetch opened 5 years ago

sveetch commented 5 years ago

Currently Boussole is very strict about import resolution: it refuses to compile sources which have import path that resolve to more than one source.

Note this is only an issue with "watch" mode which make introspection on Sass sources to find main sources to rebuild. With the "compile" mode, there is not introspection and this libsass which does everything, no boussole code is involved in import resolution.

Current behavior

If a source contains @import "foo" and there are foo.css and foo.scss files, it raises an error about unclear resolution since foo can be understood as foo.css or foo.scss. This can happen also with identical source file (relative) path with included libraries.

Expected behavior

This is not the way other compiler works especially node-sass. Even Sass documentation define another behavior: https://sass-lang.com/documentation/at-rules/import#load-paths

Also, we should fit to the node-sass behaviors so Boussole could be a valid replacement. And so we may have to implement the "~" behavior which seek for path from "node_modules" which path will have to be configured in settings.

Filename in current directory win against similar names from include libraries. This should be the default behavior to adopt (and strict could stay as an option).

Still there is some details to study to go further:

This must not replace the current import behavior and must be introduced as a new optional resolution engine (depending a setting?) and current behavior will still be the default one for some time as a deprecation process.

sveetch commented 4 years ago

For sanity, i checked compilation with Foundation, Bootstrap and Bulma from their node modules and everything is fine for compile and watch mode.

But as stated from issue detail, an exception is raised for conflicts, if the Sass project import Foundation and also contains a components/_badge.scss file, it make a conflict with the one from Foundation.

sveetch commented 4 years ago

Plan: