-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Nashorn support (Java 8) #2063
Comments
Would be good to add support in 2.0 - In that branch(2_0_0) I'm refactoring the environment abstraction to make things like this alot easier. |
Sure. I've developed a less plugin for the leiningen (clojure) build tool: lein-less, and I've made some minimal changes to the generated |
okay so the current branch is here https://github.com/less/less.js/tree/2_0_0 this my current work in progress pull request You are free to make pull requests against the 2_0_0 branch. My current thoughts were to generate a single javascript file as we do today, but using browserify (as it does for the browser version on that branch). We would "just" need an environment file https://github.com/less/less.js/tree/2_0_0/lib/less/environment/rhino.js following the pattern from node.js and browser.js which implemented all the functions. I haven't thought about changes to the rhino lessc file - I haven't thought much about how to do that, so feel free if you have any changes to that to just commit to there.. |
I'm looking at upgrading my plugin to support less 2.0.0 using browserify while supporting both Rhino and Nashorn VMs. I'd like to contribute my changes, including some Java bootstrapping code, but I'm confused about the multiple build systems referenced. Is the gradle build still used? Is build.yml still doing anything useful? Is your release process documented somewhere? |
Fantastic! Thanks. I wonder whether it might work better as a seperate repo.. what do you |
@sfnelson It would be awesome if you could contribute. Yes, rhino tests are currently gradle based. How to run/build rhino them is described in pull request #1806 . Last time I tried it was with 1.7.5 (probably) - they passed back then. I do not know whether there is a place with release process described. If we would separate rhino/nashortn from main repository, is there a way to run tests on a it every time main repo is pushed or release it when main is released? I do not think rhino tests are now run from travis after each commit, but I think they should be. |
Where I can find info and instruction on how to use less.js using Java 8 Nashorn Javascript Engine? When will Nashorn officially supported by Less.js like Less support Rhino before? |
@ktngo As far as I know, nobody tried to make less.js to run in Nashorn yet. We would be thankful for pull request if someone would made the work needed. |
It works: assets.load('lib/less-env-2.5.1.js');
assets.load('lib/less-2.5.1.js', function (contents) {
// See: https://bugs.openjdk.java.net/browse/JDK-8030198
return contents.replace('this._currentDepth === 0', 'this._currentDepth <= 0');
});
var less = createFromEnvironment(lessenv);
The
There is a bug in Nashorn where finally blocks got executed twice: https://bugs.openjdk.java.net/browse/JDK-8030198 and because of this... less.js produces no output. A hack or workaround is required and that's why I have to replace:
The fix for Nashorn is coming... but it will be great if less can change it too.. feel less release are more easy and frequently than a JVM release :S |
with less.js-2.6.1 (Elementary OS, JDK 1.8):
and a Maven project using the lesscss-maven-plugin version 1.7.0.1.1 with the following configuration
I get the following error: Failed to execute goal org.lesscss:lesscss-maven-plugin:1.7.0.1.1:compile (core) on project platform-ui-skin: Note: less-rhino-1.7.5.js works for Bootstrap v2.3.2 I need to migrate to Bootstrap v3.3.6 Any suggestions? Env: |
Have to look again, but did you replace the expression: Anyway, I replaced nashorn with j2v8 and the results are here: http://jooby.org/doc/assets/#available-processors |
-> Have to look again, but did you replace the expression: this._currentDepth === 0 with this._currentDepth <= 0? I have now :)
(there is only one occurrence) and it works, but not with .less files that have a lot of @import's Let me do some more testing... |
-> (there is only one occurrence) and it works, but not with .less files that have a lot of @import's Actually this is NOT correct as I missed the less-node-2.6.1.js configuration in a few spots and these where the ones that built, that is the less-rhino-1.7.5.js/lessJs> ones :( |
I don't know about the browserify workarounds etc mentioned here... but I put together a nashorn implementation. At this moment here are the stats... running this on windows 10, jdk1.8.0_102... I didn't test on Linux yet but it should be working. Is there still interest in this? c:...\less.js-2.7.1\bin>jjs lessjjsc -- ..\benchmark\benchmark.less c:...\less.js-2.7.1\test\nashorn>jjs index.js -- (I have not posted code or made a pull request yet, FYI) |
I'm certainly interested. What sort of changes did you need to make? |
Changes...
I'll probably get a few more of those tests cases working tonight and tidy up a bit then post the code. I'm also going to post a wrapper that can be called from java for a project I was going to post on my GitHub with some other tools. When I initially looked at converting my 1.x less-rhino wrapper to an updated version of less and to use with nashorn I noticed the build for rhino appears rather dated and delayed me getting going because I was trying to use less the same way as before, with dist/less.js & less-rhinoc.js ... after a bit I figured out that there is no dist of the core lib/less only lib/browser so that makes a java wrapper more complicated. |
Interesting. A long while back I got the lessc functionality basically running with the browserify approach, but I wasn't able to get exceptions/errors working sufficiently well that they were useful for users. How are your error messages looking? If you create a branch I'd be interested to try it out! |
An error message like this? |
@sfnelson Finally checked it in, give it a whirl when you get a chance... you know these US Elections always taking up time! I also was able to get rid of the test\nashorn* dir and just merge it with the test\index.js etc and unified the code mostly Edit: I should mention in this thread that the commit contains many more working tests, I modified copyBom so all those tests work now also... the only tests that are not working are source maps as that is not implemented. 6 Failed, 311 passed |
@sfnelson Any update on testing the feature out? |
Hey @artfiedler it looks interesting, but I don't think it's likely to be accepted upstream because of all the |
Hrmmm, the 2 references to isNashornMode in bin/lessjjsc actually aren't even used, I had left those in there thinking of merging bin/lessc and bin/lessjjsc. The other 10 references to isNashornMode are specifically in the test case set and not linked to lessjjsc or lib/* at all |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Java 8 includes a new javascript engine, Nashorn that provides a massive performance improvement over Rhino. Nashorn's Java interop is sufficiently different from Rhino that the existing Rhino versions don't work in Nashorn, even in Nashorn's Rhino interop mode.
It would be good to have a separate build similar to
less-rhino
, e.g.less-nashorn
that provides the bindings required with work in the nashorn engine. This would supportlessc
integration into Java-based build tools.The text was updated successfully, but these errors were encountered: