GithubHelp home page GithubHelp logo

"print" is not defined about less-sbt HOT 9 CLOSED

softprops avatar softprops commented on July 18, 2024
"print" is not defined

from less-sbt.

Comments (9)

kastigar avatar kastigar commented on July 18, 2024

Possibly here is a solution:

https://groups.google.com/d/msg/mozilla.dev.tech.js-engine.rhino/EJmJJhftc3g/JELu_XEi5TwJ

from less-sbt.

softprops avatar softprops commented on July 18, 2024

Thanks @kastigar I'll have a look tonight.

from less-sbt.

sroebuck avatar sroebuck commented on July 18, 2024

I'm getting the same error mentioned above when I try to compile twitter bootstrap but as it's the first time I've tried I can't comment on whether its to do with a change in less-sbt or just what I'm attempting to do!

I notice in the release note for less-sbt 0.1.4: updated less compiler support from less-rhino-1.1.3.js to less-rhino-1.1.5.js.

But using less-sbt 0.1.4 myself (and in the example output above) it refers to less-rhino-1.1.3.js

Is this in any way connected.

from less-sbt.

softprops avatar softprops commented on July 18, 2024

Can one if you guys set up an example test case repo and toss it on github? That would make things a little easier for me. Afterwards I can translate it to an sbt scripted test so I can avoid regression test failures when I switch between versions. Are you both getting this error using twitters bootstrap. I don't get the error in any of my less projects. It's very likely something I can hack in the compiler js it self. I ran into a similar issue (though the error was no so revealing!) with the coffeescript plugin after I updated. The compiler js was using a property that is a keyword in future versions of ecmascript, static. Rhino is a lot more strict on what it evaluates that most browsers. Thanks for the input guys. The more input I have the quicker I can track down the issue

from less-sbt.

sroebuck avatar sroebuck commented on July 18, 2024

Okay, some progress perhaps...

The current 0.1.4 release of sbt-less uses less-rhino-1.1.3.js but includes the less-rhino-1.1.5.js library file.

The original error relating to print, relates to this code:

if (e) {
    print("Error: " + e);
    rshellGlobal.quit(1);
}

but print presumably isn't defined in rhino. I copied the style of other similar issues in the code and changed it to this:

if (e) {
    // print("Error: " + e);
    // rshellGlobal.quit(1);
    throw e;
}

However, in the end that didn't really help me to identify the underlying problem.

Next...


So, I changed the code in compiler.scala (of less-sbt) to use less-rhino-1.1.5.js.

This resulted in a new error in line 138 of rhino (1.1.5):

if (typeof environment === "object" && ({}).toString.call(environment) === "[object Environment]") {
    // Rhino
    // Details on how to detect Rhino: https://github.com/ringo/ringojs/issues/88
    less = {};
    tree = less.tree = {};
    less.mode = 'rhino';
} else if (typeof(window) === 'undefined') {
    // Node.js
    less = exports,
    tree = require('./tree');
    less.mode = 'rhino';
} else {

Basically, the check for rhino in the first line listed above isn't working so the second condition is getting used which references exports which is undefined outside of node.js. In the interests of pragmatism I just changed the first condition to:

if (true) { // !

And then everything worked fine. Including the complete compile of Twitter Bootcamp 2.

from less-sbt.

softprops avatar softprops commented on July 18, 2024

Aw crap! Not using the newer version of less-rhino. That's clearly my bug. Ill look into this tonight.

from less-sbt.

softprops avatar softprops commented on July 18, 2024

I think I've got the fix.

The key was kind of clear after swapping compiler versions and then running the scripted tests. Aren't tests priceless!

I got an error in the import test on this line. If you look a few above you'll notice the rhino detection failed! Thank's to @kastigar's link above. I followed the original poster n that list back to the ringojs project (like nodejs but using rhino and the jvm) which linked to a gh issue and with a commit back to a file which provided a tremendous amount of insight. I assume no know knows the rhino library better than the authors themselves than this guy.

I think I only need a subset of that to solve the problem but the underlying problem is this:

Js libraries that expose a rhino-friendly interface can and will do so exploiting some function calls that are defined within the rhino shell env. My assumption is that the extend of their testing is to fire up the rhino shell jar and test their library. Since I am embedding rhino instead, these functions are not defined in the js evaluation env I was using. How funny is that?

Well not that funny if you get these kinds of bug reports.

Anyway. I think that closes this issue but I can't be sure until I try to emulate one of either of your test cases. Are you guys just cloning the twitter bootstrap project to get the less source files? I think I will make an sbt scripted test for that since I assume that project is what's driving interest in less these days. I think less has enough merit to stand on its own which is why I love it.

Thank guys for point this out. I'll going to try and get a few more fixes (and tests) in tonight and I'll do a release, 0.1.5 including this and what ever else I can get done.

from less-sbt.

softprops avatar softprops commented on July 18, 2024

I was able to compile twitter bootstrap in a scripted test so I'm closing this one after a946d95

from less-sbt.

sroebuck avatar sroebuck commented on July 18, 2024

Many thanks for being so responsive and for all the work you've done in making this great tool available to all us freeloaders :)

from less-sbt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.