-
Notifications
You must be signed in to change notification settings - Fork 1
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
3.0 Branch Updates #20
Comments
The 3.x pre-release branch is now published to NPM under the tag "next", per convention. |
Having a hook into the formal evaluation cycle means you offer users a means to avoid having to write some quite tricky code to create the evaluation tree by hand. That's always a good thing, imho. |
@rjgotten You're right. It's a fairly simple thing to include, and the context for |
Did much of the work over Christmas break. Just need to add tests for sending arguments to plugins. 3.0 alpha 1 is released under the "next" tag on NPM. |
Wrote a ton of documentation tonight. If anyone wants to help me out, that would be great. Example: https://github.com/less/less-docs/blob/3.x/content/features/plugins.md |
Better? Yes. Architecturally, the best way to do it would be to chain the evaluation of the AST together using a It would also enable functions that require data asynchronously, which could be interesting. Processing It would be a radical, ra-di-cal departure from the current compiler though. So not something I would attempt to undertake until a next major version. |
Cool and shining until the very moment one import uses data from another, then all that cryptic async stuff becomes totally useless. |
@rjgotten - I don't get it. If an |
@matthew-dean
Hence: 'might'. Ofcourse not everything parallelizes as well as the ideal. |
Okay, how? I tried to get it to work and I never could. I could create an import node, but I could never get it to do anything (as in, actually import a Less file). Can you test this? And once you verify that it's possible, can you add tests into the repo? |
I meant from a control flow perspective it's possible. Sorry for the confusion. |
I pushed v3.0.0-alpha.3 today. Question on my mind: how forward-looking is the plugin syntax considering |
I don't think the ES6 module syntax can be easily unified with AMD/CJS syntax in a single runtime file. Maybe the correct way forwards here is to do away with both AMD and ES6 module syntax and go a different path: enable Less to run from within a web worker. That way you can use a combination of CJS This would also lessen the load on the main UI thread of the browser, which could be desirable to speed up start-up and reduce stutter when using hot reloading. (And a considerable bonus: |
I think any XHR script requests should be protected from XSS already, no? I couldn't ever get clear feedback about this. Whether we needed special XSS protection in As for this:
O_O I mean, sure, but... ⌛️ Also, if Less is going to be re-written for speed, it should probably be done in Web Assembly, lol. Either way, I'm not sure how web workers address plugins or the correct way people should be including / calling them. You know.... technically, in the browser, all we should really allow in v3.0+ is |
XHR is not vulnerable. However, AMD modules typically are not loaded via an XHR transport. They're loaded as script tags. As for
Web workers have a built-in synchronous way of loading scripts: the The two paired up works nicely. You can do away with asynchronous dependency resolution and all its complications, and the browser doesn't need a full module loader baked into Less, since the built-in function already does most of the heavy lifting. You just need a little bit of paving over its top to shim a functional subset of Simple single-file plugins wouldn't even need to fetch dependencies and for those all of this is really a theoretical discussion to begin with, I think. |
Hmm... I didn't know this. Node.js doesn't have web workers (although of course there are libs to simulate), and if you used require, it'd be in the same thread, different from web workers. But I guess single-thread in Node.js is not a big deal since it's not performing a bunch of extra work like the browser is. How do you feel about this:
|
In the browser only allowing But you'd need to make it very clear to plugin authors that they should not be assuming CJS |
@rjgotten I removed UMD definition from Less.js and less-docs for |
If there are no complaints, I'll merge RC1 into master sometime this week and publish 3.0. |
Closing as 3.0 is released. Any future 4.0 thread can pull/reference from this one. |
This is a tracking list of changes for the 3.x branch.
3.0 Change List
General
less.postProcessor
option removed. (PostProcessor plugins are still fine.)parent
property, which allows:if()
function added with PR #3079Plugin changes
@plugin
! Also aligned is the auto-searching behavior of lessc. That is, invoking@plugin "clean-css";
will attempt (in a Node environment) to load "less-plugin-clean-css" and "clean-css" modules, before looking in the local directory (same file path as invoking.less
file) forclean-css.js
andless-plugin-clean-css.js
. The browser environment will of course only look for the last two single file matches.@plugin
-@plugin (args) "plugin-name"
. Like lessc,args
is an arbitrary stringinstall()
function is now optional. It will be invoked once for the first@plugin
call.use()
function. This gets called when the@plugin
statement is first evaluated (pre-eval of the Less tree).eval()
function. This gets called during Less's evaluation cycle. The purpose for this is that plugins can create scoped nodes and immediately evaluate them in the current context.Inline plugins can either usePlanning on changing this based on feedback.registerPlugin({...})
or CommonJS-stylemodule.exports = {...}
with the plugin object signature. However, plugins are now not required to return anything.@plugin
will still be visited. The plugin manager now returns a dynamic visitor iterator.3.0 Tests needed
Tests for seeing that Browserify'd Node plugins work seamlessly withNot a compatible system@plugin
Tests for sending arguments toMoved to 3.1@plugin
To Deprecate in 3.0
@plugin
syntax. As far as I can tell, this is mainly used to import libraries by injecting text with an@import
at-rule. There has to be a better way to simply add imports at the point of@plugin
evaluation, but I haven't been able to figure it out. If it's to perform other conversions of styles before Less evaluation, there are plenty of other better-supported tools that do this, such as Gulp or PostCSS.less.postProcessor
option, which was a specialized option.) This feature was created to add Autoprefixer and Clean-CSS support, but now there are much better task runners (Grunt / Gulp, etc) - See: Error: ENOENT with lessc & plugin-autoprefix & plugin-clean-css less.js#2612 (comment)Move to 3.1
@plugin
(like@plugin(arg: val)
?)Move to 4.0
I'll keep this updated as proposals get finalized.
The text was updated successfully, but these errors were encountered: