Skip to content
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

Updgrade to less 2.0 #53

Closed
richdougherty opened this issue Nov 11, 2014 · 23 comments
Closed

Updgrade to less 2.0 #53

richdougherty opened this issue Nov 11, 2014 · 23 comments

Comments

@richdougherty
Copy link
Contributor

Less 2.0.0 was released on Nov 11: https://github.com/less/less.js/blob/master/CHANGELOG.md#200

@yatskevich
Copy link
Contributor

@richdougherty @jroper Less 2.5.0 was released on April 3.

What's needed to be done for sbt-less? Update docs and supported lessc arguments? Update lessc.js itself?

@richdougherty
Copy link
Contributor Author

Here's what needs doing:

  1. Update the less-node dependency. You'll need to find or package a WebJar.
  2. Update the sbt plugin, e.g. to add support for new options.
  3. Update the JavaScript driver. This driver is called by the sbt plugin and calls the main less code.

@jroper
Copy link
Member

jroper commented Apr 22, 2015

I've actually done some work on this. It's not a trivial upgrade, requires a fix to the less-node webjar, I've got it working on node, but for trireme, there's a few dependencies (eg, es6 promises) that we don't have webjars for yet, and I've been too busy to follow up.

@yatskevich
Copy link
Contributor

@richdougherty good plan!

@jroper would you be so kind to share your branch? I guess I'll be able to look at the upgrade over the weekend.

@jroper
Copy link
Member

jroper commented Apr 22, 2015

@yatskevich https://github.com/jroper/sbt-less/tree/bintray-upgrades

Note that I originally was just going to reconfigure it to publish to bintray (we're moving all plugins to bintray), and I decided to do a version refresh while I was at it, that's when I started down the rabbit hole of the upgrade.

The version of the less webjar that it refers to is here:

webjars/less#11

@yatskevich
Copy link
Contributor

Short summary:

  1. PR for es6-promise-node has been created (Update to es6-promise 2.1.1 webjars/es6-promise#2). Waiting for merge.
  2. Branch which uses "org.webjars" % "es6-promise-node" % "2.1.1" has been published
  3. All except one scripted tests are passing in the branch (sbt-less-plugin / error-output).
  4. It is caused by inconsistent line and column reporting by less compiler. I've submitted an issue Inconsistent error reporting when globalVars and/or modifyVars are being passed less/less.js#2573

@richdougherty
Copy link
Contributor Author

@yatskevich: Awesome, thanks. I think @jroper has access to the webjars repo, so he may be able to merge your PR.

@jroper
Copy link
Member

jroper commented Apr 26, 2015

We can update the scripted test to account for the less.js issue, just put a comment on it to explain why it's testing for the numbers its testing for, so that if/when less is fixed, and we upgrade, we know why the test fails. Alternatively, we can adjust the error reporting in sbt-less, since we know how many global vars/modify vars were added, so we can adjust the line numbers accordingly. Again, if you decide to do that, put a comment linking to the issue that explains why, so that if it's fixed in future, we know what to do.

@yatskevich
Copy link
Contributor

Yep, I was thinking about these options too.

I'd better keep sbt-less error reporting as close as possible to lessc reporting to avoid further confusion and adjust scripted test.

@yatskevich
Copy link
Contributor

Final version (PR #62) contains workaround for the lessc issue (if globalVars or modifyVars are not provided they are not passed to lessc). Original test (error-output) passes.
Separate test (error-output-global-vars) was added. It checks for weird values and has a reference to an issue in less.js repo.

@KarelCemus
Copy link

@yatskevich First thank you for your great work. Second, I tried to compile and use your snapshot version but it does not work for me. Are you sure its really resolved and working? Are all dependencies up-to-date? When I compile my project with this updated version of sbt-less plugin it throws the following error:

play.PlayExceptions$UnexpectedException: Unexpected exception[JsTaskFailure: SyntaxError: Unexpected token: u (/media/data/Projects/matahari/project/target/less/sbt-less.jar#65)   at /media/data/Projects/matahari/project/target/less/sbt-less.jar:65 (anonymous)
    at /media/data/Projects/matahari/project/target/less/sbt-less.jar:97 (anonymous)
    at fs.js:107 (anonymous)
    at trireme.js:822 (submitTick)
]
    at play.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:51) ~[na:na]
    at play.PlayReload$$anonfun$taskFailureHandler$1.apply(PlayReload.scala:44) ~[na:na]
    at scala.Option.map(Option.scala:145) ~[scala-library-2.11.6.jar:na]
    at play.PlayReload$.taskFailureHandler(PlayReload.scala:44) ~[na:na]
    at play.PlayReload$.compileFailure(PlayReload.scala:40) ~[na:na]
Caused by: com.typesafe.sbt.jse.SbtJsTask$JsTaskFailure: SyntaxError: Unexpected token: u (/media/data/Projects/matahari/project/target/less/sbt-less.jar#65)   at /media/data/Projects/matahari/project/target/less/sbt-less.jar:65 (anonymous)
    at /media/data/Projects/matahari/project/target/less/sbt-less.jar:97 (anonymous)
    at fs.js:107 (anonymous)
    at trireme.js:822 (submitTick)

    at com.typesafe.sbt.jse.SbtJsTask$$anonfun$com$typesafe$sbt$jse$SbtJsTask$$executeJsOnEngine$1.apply(SbtJsTask.scala:195) ~[na:na]
    at com.typesafe.sbt.jse.SbtJsTask$$anonfun$com$typesafe$sbt$jse$SbtJsTask$$executeJsOnEngine$1.apply(SbtJsTask.scala:167) ~[na:na]
    at scala.util.Success$$anonfun$map$1.apply(Try.scala:206) ~[scala-library-2.11.6.jar:na]
    at scala.util.Try$.apply(Try.scala:161) ~[scala-library-2.11.6.jar:na]
    at scala.util.Success.map(Try.scala:206) ~[scala-library-2.11.6.jar:na]

Would you look at this error and explained it to me, please? Is there any mistake in my configuration or so? With the current stable version the project works (but compiles wrong as I need Less v2.5).

Thanks!

@yatskevich
Copy link
Contributor

@KarelCemus Could you please share your configuration?

@KarelCemus
Copy link

In plugins.sbt I have these (and couple more but they should be unrelated):

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")

// newest version of sbt-web
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.2.0")

// plugin compiles less into css
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0-SNAPSHOT")

and in build.sbt

import com.typesafe.sbt.less.Import._

// configure LESS to compile only some files
includeFilter in(Assets, LessKeys.less) := "lib.less" || "admin.less" || "front.less"

And that's all related to Less. Would you like to see the whole project conf or is this enough?

@yatskevich
Copy link
Contributor

@KarelCemus config looks good to me. I guess the error is caused by contents of one of your less files. Have you tried compiling it with pure lessc?

@KarelCemus
Copy link

It doesn't compile even when the files are completely empty. And I think the files are good, I received them from our coder who uses Grunt so they should compile with pure lessc fine.

This is complete plugins.sbt in case of some interaction.

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.3.8")

// newest version of sbt-web
addSbtPlugin("com.typesafe.sbt" % "sbt-web" % "1.2.0")

// plugin compiles coffee script into javascript
addSbtPlugin("com.typesafe.sbt" % "sbt-coffeescript" % "1.0.0")

// plugin compiles less into css
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.0-SNAPSHOT")

// plugin computes md5 hashing to allow extensive caching only in production mode
addSbtPlugin("com.typesafe.sbt" % "sbt-digest" % "1.1.0")

// plugin prepares pregzipped files only in production mode
addSbtPlugin("com.typesafe.sbt" % "sbt-gzip" % "1.0.0")

// plugin performs requirejs optimization, it concatenates javascripts only in production mode
addSbtPlugin("com.typesafe.sbt" % "sbt-rjs" % "1.0.7")

// plugin performs css minification only in production mode
addSbtPlugin("net.ground5hark.sbt" % "sbt-css-compress" % "0.1.3")

// dependencies as a tree
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.4")

@KarelCemus
Copy link

@yatskevich I tried to figure out the problem and give you the smallest project to reproduce it and I found first real issue.

When there is file to compile and it is empty or contains only comments, it fails with the error I posted earlier. I confirmed that.

Now I have to find out how this relates to my project configuration.

Can you reproduce it yourself or should I give you the whole project? It's tiny.

@KarelCemus
Copy link

@yatskevich OK and this bug relates to my project. I have 4 main files and one of them was empty. So that's it, thank you for your assistance.

@huntc
Copy link
Contributor

huntc commented May 3, 2015

Just curious. Is this empty file issue a regression given the PR?

@jroper
Copy link
Member

jroper commented May 4, 2015

It could be a regression in less itself - maybe see what happens when you compile an empty less file with less.

@yatskevich
Copy link
Contributor

I verified that less 2.5 compiles empty file without an error. Will add corresponding test to the plugin's test suite.

@yatskevich
Copy link
Contributor

The issue is confirmed. It happens because less returns the following compilation result:

{ css: '', map: undefined, imports: [] }

So the error SyntaxError: Unexpected token: u is thrown by JSON.parse() while trying to parse undefined.

I've tested original less behavior and here is the result.
If you run lessc --source-map=empty.css.map empty.less empty.css where empty.less is an empty file you'll get two files - empty.css which is empty and empty.css.map which contains undefined as a string.

Would you expect the same result from sbt-less or a new issue should be submitted for less.js?

@jroper
Copy link
Member

jroper commented May 5, 2015

Seems like a new issue to me.

@yatskevich
Copy link
Contributor

They have this issue reported and closed already - less/less.js#2430, but my testing on 2.4.0 and 2.5.0 shows that it's not actually fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants