-
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
Feature - Nashorn support (Java 8) #2985
Conversation
Added support for test cases to run with nashorn Implemented lessjjsc
Is this a replacement for less-rhino? |
Yes, as less-rhino doesn't work... I made less-nashorn that can utilize java's integrated javascript engine (nashorn) |
I also have a wrapper for lesscss to use directly in java but I never got around to publishing that along with my other wrappers. |
Okay, perfect. One of my concerns is that less-rhino got stale for a number of reasons. Are those reasons addressed in these ways:
I know that's a lot of work, but it would help make sure that the work you just did stays integrated into the Less repo for a long time. |
|
I'll also note that the less-nashorn section is modeled after the less-node section, but it's implementation is not a copy of node, but instead implemented like node. |
@seven-phases-max Thoughts about merging? |
I don't know - I'm so totally not connected to Java and Java-specific Less impl. so I barely can't have any opinion (I guess we could simply rely on @artfiedler's opinion - if he thinks it's fine to put all that efforts and make a PR then I guess it's fine). |
@seven-phases-max What about merging vs a separate less/less-nashorn repo? |
Well, a separate repo is of course preferred (considering that ideally and potentially it has its own specific test environment, issues and finally a maintainer(s)). |
A separate repo sounds like total overkill, the core of less is the same, and all the tests. To make them all one the lessc and lessjjsc could be abstracted into a LessCompiler, and the lessjjsc differences could be provided in a JJSLessCompiler implemention file. There still would be two bin files however, My guess is the lessc version would be two lines of code (shebang and require the lesscompiler) and the lessjjsc would have just an additional require function ontop of that with different shebang and require JJSLessCompiler. Think of "jjs" as "nodejs" it executes javascript, this isn't a java implementation but a nashorn (java's javascript engine) implementation. |
Well, a separate repo does not necessary mean a complete and totally independent fork (as in "copy-paste" everything)... A repo may have just |
@artfiedler What @seven-phases-max said. You could also add Less.js as a dependency (or peer dependency). As a separate repo, you could be added as the maintainer of that repo (it could still even live under the Less org). It would also allow issues to be environment specific, which would be more manageable. We could alternatively make a less-nashorn repo and make it a submodule of Less. That would keep it structurally identical to the current environment stuff, but give environments their own commit histories (and issues, Github maintainers, etc). How do other projects manage these "environment build" scenarios? |
This needs a decision. I think the lean though is toward something in the less org but less-nashorn. (or less-java?). |
@artfiedler Please set up a working less-java repo and I think we'd be happy to add it under the Less org here with you as the principle maintainer for that repo. |
@artfiedler Great Job! |
@artfiedler Awesome, it is just what we need! |
I am looking forward to this PR coming through |
we had create a repo lessc4j, using codes from this pull request, so we can use Java API to compile less files. |
@artfiedler good job! I hope you'll find a way to get this integrated into the "less"-repos. |
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. |
@wendal good job! |
Closing this since there's no activity and no apparent interest in setting up a separate repo. There are also Less Java ports here -> https://github.com/LucasBassetti/awesome-less#java. We really don't want to get into a situation like the So, if there's a active maintainer of a Java-wrapped Less repo, then we could perhaps move it under the Less org here on Github and assign that person. Either way, supporting browser/Node is complicated enough in this repo. |
It seems like someone could take @wendal's repo, use something like |
Point maybe mute as nashorn is already being deprecated in java. I had wrote a pure java version as well but never got around to posting. The way I coded it I had hoped you guys could just modify your build script to generate the jjs version as it shouldn't really need maintenance as it just ran on a simulated nodejs environment inside java, less js's base code wasn't modified as I remember. |
@artfiedler Hmm okay, so you agree this shouldn't be re-opened? |
This should resolve multiple open issues [Issue #2063] [Issue #2316]
Requirements: jdk8 (I tested with jdk1.8.0_102)
I created lessjjsc instead of modifying lessc because I was not sure how to do a fallback Shebang if (!node) then jjs. I also wasn't having luck figuring out how to make jjs include -- in the shebang. Do note that nodejs is much faster than nashorn but it should be useful regardless.
Ways to run from bash (tested on windows)
> .class {
> width: 17pt + 5px;
> }
> EOF
>> Type .less input, when done end with Ctrl-D
> .class {
> width: 20px + 7pt;
> }^D
To run on windows/linux without bash or without shebang
Commands are the same just prefix with jjs
This should run on any system that has jdk1.8 no additional libs or requirements.
Testing
I got the majority of the test cases working, I don't have grunt, browserfy, and 993285409238409238 other things and I've never used them so this is how I ran my tests...
less.js-2.7.1> jjs test\index.js
> (snip)
> 6 Failed, 311 passed
Notes
The 6 that fail are related to SourceMap's I did not implement that in the environment.js so it throws and error instead.
I also was testing @import (inline) "https://lesscss.org/public/css/index.css"; and that works but there are a few // TODO:'s around for instance in the url-manager I put together joining base + relative url's but wasn't quite sure how to test. Also diff(left,right) there is a TODO for in case the line count doesn't match for the test cases for now everything seems to match so that works.
I choose to base the modifications off of the 2.7.1 tag because that's the production version listed on the website... I should be able to update for 3.x I have not looked into that at all though.