You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 support lessc integration into Java-based build tools.
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.
Would you be interested in helping?
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 less-rhino-1.7.2.js artifact to support nashorn, it should be fairly straightforward to add support for both. How would you like to proceed?
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
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 have no idea if gradle is used, i think so, the build.yml i kept around
just for rhino but no idea if its even used in the last rhino build. @SomMeri might be able to help
I wonder whether it might work better as a seperate repo.. what do you
think? If you agree i could create a less.java and give you developer
rights on it.
@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.
Failed to execute goal org.lesscss:lesscss-maven-plugin:1.7.0.1.1:compile (core) on project platform-ui-skin:
Execution core of goal org.lesscss:lesscss-maven-plugin:1.7.0.1.1:compile failed: Failed to initialize LESS compiler.
Encountered code generation error while compiling script: generated bytecode for method exceeds 64K limit.
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:
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
-> (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
Finished: 6185.745009ms I don't have node installed so I don't know how fast this runs on node, can someone post some timings? I'm measuring from just before less.render and first line in .then()
c:...\less.js-2.7.1\test\nashorn>jjs index.js --
13 Failed, 147 passed I believe some of the failed tests actually pass just the output doesn't match, and a few minor tweaks might make a few more tests run successfully. Right now I know svg image size and source maps aren't implemented so those tests fail
(I have not posted code or made a pull request yet, FYI)
Zero changes to the original lib/less, and test case files..
Added a lib/less-nashorn dir
Copied of bin/lessc as bin/lessjjsc, modifications were a quick require() impl and a few other tweaks, a large majority of the file could be reused between node and jjs
Copied test/*.js to test/nashorn/ which I modified index.js and less-test.js... I did not modify copy-bom.js I disabled that because it required some additional implementation and I didn't look into what "bom" is so I skipped it figured I would see how it runs against the main tests which as of last night was "8 failed and 152 passed"
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?
c:...\less.js-2.7.1\bin>jjs lessjjsc -- ..\test\less\errors\color-func-invalid-color.less
ERROR: ArgumentError: error evaluating function color: argument must be a color keyword or 3/6 digit hex e.g. #FFF in c:...\less.js-2.7.1\bin..\test\less\errors\color-func-invalid-color.less on line 2, column 10:
1 .test {
2 color: color("NOT A COLOR");
3 }
@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
Hey @artfiedler it looks interesting, but I don't think it's likely to be accepted upstream because of all the isNashornMode checks. Still it's a good start, and good to have a proof of concept. If you want to get it merged I'd suggest looking at ways of using browserify/similar builds to replace the conditional tests.
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.
Activity
lukeapage commentedon Jun 22, 2014
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.
Would you be interested in helping?
sfnelson commentedon Jun 22, 2014
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
less-rhino-1.7.2.jsartifact to support nashorn, it should be fairly straightforward to add support for both. How would you like to proceed?lukeapage commentedon Jun 24, 2014
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
#1902
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..
sfnelson commentedon Nov 17, 2014
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?
lukeapage commentedon Nov 17, 2014
Fantastic! Thanks.
I have no idea if gradle is used, i think so, the build.yml i kept around
just for rhino but no idea if its even used in the last rhino build.
@SomMeri might be able to help
I wonder whether it might work better as a seperate repo.. what do you
think? If you agree i could create a less.java and give you developer
rights on it.
SomMeri commentedon Dec 4, 2014
@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.
ktngo commentedon May 27, 2015
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?
SomMeri commentedon Jun 1, 2015
@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.
jknack commentedon Sep 16, 2015
It works:
asset.loadjust read a file from classpath and load it via nashorn:loadfunction.The
less-envfile was created with:browserify node_modules/less-node/environment.js --s lessenv -o less-env-2.5.1.jslesswith:browserify node_modules/less/lib/less/index.js --s createFromEnvironment -o less-2.5.1.jsThere 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:
this._currentDepth === 0withthis._currentDepth <= 0The 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
Robinyo commentedon Apr 5, 2016
@jknack
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:
Execution core of goal org.lesscss:lesscss-maven-plugin:1.7.0.1.1:compile failed: Failed to initialize LESS compiler.
Encountered code generation error while compiling script: generated bytecode for method exceeds 64K limit.
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:
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
jknack commentedon Apr 5, 2016
Have to look again, but did you replace the expression:
this._currentDepth === 0withthis._currentDepth <= 0?Anyway, I replaced nashorn with j2v8 and the results are here: http://jooby.org/doc/assets/#available-processors
Robinyo commentedon Apr 5, 2016
-> 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...
Robinyo commentedon Apr 5, 2016
-> (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 :(
artfiedler commentedon Nov 7, 2016
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
Finished: 6185.745009ms
I don't have node installed so I don't know how fast this runs on node, can someone post some timings? I'm measuring from just before less.render and first line in .then()
c:...\less.js-2.7.1\test\nashorn>jjs index.js --
13 Failed, 147 passed
I believe some of the failed tests actually pass just the output doesn't match, and a few minor tweaks might make a few more tests run successfully. Right now I know svg image size and source maps aren't implemented so those tests fail
(I have not posted code or made a pull request yet, FYI)
sfnelson commentedon Nov 7, 2016
I'm certainly interested. What sort of changes did you need to make?
artfiedler commentedon Nov 8, 2016
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.
sfnelson commentedon Nov 8, 2016
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!
artfiedler commentedon Nov 8, 2016
An error message like this?
c:...\less.js-2.7.1\bin>jjs lessjjsc -- ..\test\less\errors\color-func-invalid-color.less
ERROR: ArgumentError: error evaluating function
color: argument must be a color keyword or 3/6 digit hex e.g. #FFF in c:...\less.js-2.7.1\bin..\test\less\errors\color-func-invalid-color.less on line 2, column 10:1 .test {
2 color: color("NOT A COLOR");
3 }
artfiedler commentedon Nov 10, 2016
@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
artfiedler commentedon Nov 16, 2016
@sfnelson Any update on testing the feature out?
sfnelson commentedon Nov 17, 2016
Hey @artfiedler it looks interesting, but I don't think it's likely to be accepted upstream because of all the
isNashornModechecks. Still it's a good start, and good to have a proof of concept. If you want to get it merged I'd suggest looking at ways of using browserify/similar builds to replace the conditional tests.artfiedler commentedon Nov 17, 2016
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
stale commentedon Nov 14, 2017
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.