cloudhead/less.js — comment on commit aefd31051476ccac82ec581ab8ac80ed6c2c5575
File:  line 0
By paulogaspar7:

I did try with 1.2.2. I think I already found what the problem was and got to an acceptable solution. It is a problem with scopes.

The callback you pass when you call less.Parser.importer() at the top of "parser.js" is at the top importing files Parser scope. However, I think this callback only gets called and registers the data ater an import is parsed. This might be to late for some parsing errors.

But if one loads the cache as soon as the less stylesheet code is loaded, then it is necessary to pass the data to the top importing parser cache, which requires some reference passing.

I found a solution simple enough for me to feel confortable. Not beautiful, but I don't feel confortable making a big change on your code. Had to keep it as simple as possible.

I tested everything by:
* Running the tests via "make test";
* Compiling via "lessc" the Less stylesheets for the current (straight rom the master) Twitter Bootstrap and from the app I am working on;
* Running Bootstrap with dynamic loading too.

Everything worked fine except for an unrelated issue, present also on 1.2.2 - resolving variables only on dynamic loading on url()s, like this one:
* https://github.com/twitter/bootstrap/blob/master/less/sprites.less#L24

I will now commit and submit a pull request.

Cheers