Requests for comment/Change LESS compilation library
Appearance
Change LESS compilation library | |
---|---|
Component | Frontend |
Creation date | |
Author(s) | Dantman |
Document status | implemented See Phabricator. |
This document proposes changing the library we use to compile LESS in core.
Background
[edit]When LESS support was implemented in core lessphp (leafo, lessc) was used in the implementation however another LESS compiler written in PHP exists, less.php (oyejorge, Less_Parser).
Reasons to switch from lessc to Less_Parser
[edit]- lessc's original creator no longer has time for the project and most of the activity now appears to be maintenance.[1]
- Less_Parser has a better import path default, it doesn't add the current dir after the other import paths like lessc does which is part of the cause of bug 60368/bug 64595.
- Less_Parser also supports import callbacks and appears to allow different path roots to point to different folders
- AFAICT dynamically defined variables in Less_Parser (defined from PHP) override the static global ones in less files, which matches Less.js' behavior and may be of use to us.
- Less_Parser doesn't require the Ctypes extension like lessc does
- Less_Parser supports source maps which we had hopes to implement in core. lessc doesn't so it would be impossible to implement for LESS currently.
- Less_Parser has better feature parity with the official lesscss/less.js parser, while lessc is relatively out of date. lessc is missing a number of newer LESS constructs and is sometimes outright wrong in how it parses LESS, not following the official behaviour. lessc's parsing is close to that of less.js somewhere in between 1.3.x and 1.4.x (lessc implements some 1.4.x syntax while not implementing others) while Less_Parser's in theory implements everything implemented up to and including less.js 1.6.x.
.a:extend(.b) {}
& when (@my-option = true) {}
- Merge:
property+: value;
- min()/max()
- Parameter interpolation:
border-@{edge}: 0;
- default()
- lessc incorrectly parses LESS like this http://lesscss.org/features/#mixins-as-functions-feature[2]
- contrast() gives wrong output[3], no shade()[4], ...
Issues with the transition
[edit]- Less_Parser's performance may not be as good as lessc's (https://github.com/oyejorge/less.php/issues/60)
- Less_Parser does not currently support custom function, however there is a recent patchset that implements it.
- Not an issue.
$wgResourceLoaderLESSFunctions
has been deprecated already.
- Not an issue.
- Less.php/Less_Parser is Apache 2.0 licensed which may conflict with our use of GPL2 (strictly speaking less.js is also Apache 2.0 though it can be found in core at docs/kss/styleguide-template/public/less.js)
- Not an issue. Apache 2.0 can be safely bundled as its own library in a GPL2 product if credited separately. Already being done elsewhere in MediaWiki.