less 4.9.1 → 5.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/README.md +23 -5
  2. package/V5-STATUS.md +71 -0
  3. package/bin/lessc +302 -626
  4. package/dist/less-browser-dev.js +2550 -0
  5. package/dist/less-node.cjs +480 -14561
  6. package/index.cjs +5 -2
  7. package/lib/browser-dev.js +86 -0
  8. package/lib/index.js +164 -0
  9. package/lib/lessc-helper.js +64 -0
  10. package/lib/logger.js +76 -0
  11. package/lib/options.d.ts +82 -0
  12. package/lib/options.js +227 -0
  13. package/lib/types.js +20 -0
  14. package/lib/version.js +19 -0
  15. package/package.json +36 -40
  16. package/dist/less.cjs +0 -15218
  17. package/dist/less.js +0 -15218
  18. package/dist/less.min.js +0 -11
  19. package/dist/less.min.js.map +0 -1
  20. package/lib/less/constants.js +0 -13
  21. package/lib/less/contexts.js +0 -165
  22. package/lib/less/data/colors.js +0 -150
  23. package/lib/less/data/index.js +0 -4
  24. package/lib/less/data/unit-conversions.js +0 -21
  25. package/lib/less/default-options.js +0 -89
  26. package/lib/less/deprecation.js +0 -82
  27. package/lib/less/environment/abstract-file-manager.js +0 -140
  28. package/lib/less/environment/abstract-plugin-loader.js +0 -185
  29. package/lib/less/environment/environment-api.ts +0 -21
  30. package/lib/less/environment/environment.js +0 -59
  31. package/lib/less/environment/file-manager-api.ts +0 -77
  32. package/lib/less/functions/boolean.js +0 -29
  33. package/lib/less/functions/color-blending.js +0 -85
  34. package/lib/less/functions/color.js +0 -452
  35. package/lib/less/functions/data-uri.js +0 -74
  36. package/lib/less/functions/default.js +0 -26
  37. package/lib/less/functions/function-caller.js +0 -55
  38. package/lib/less/functions/function-registry.js +0 -36
  39. package/lib/less/functions/index.js +0 -35
  40. package/lib/less/functions/list.js +0 -158
  41. package/lib/less/functions/math-helper.js +0 -22
  42. package/lib/less/functions/math.js +0 -30
  43. package/lib/less/functions/number.js +0 -95
  44. package/lib/less/functions/string.js +0 -39
  45. package/lib/less/functions/style.js +0 -29
  46. package/lib/less/functions/svg.js +0 -87
  47. package/lib/less/functions/types.js +0 -70
  48. package/lib/less/import-manager.js +0 -183
  49. package/lib/less/index.js +0 -95
  50. package/lib/less/less-error.js +0 -166
  51. package/lib/less/logger.js +0 -34
  52. package/lib/less/parse-tree.js +0 -124
  53. package/lib/less/parse.js +0 -87
  54. package/lib/less/parser/lookup-pattern.js +0 -26
  55. package/lib/less/parser/parser-input.js +0 -400
  56. package/lib/less/parser/parser.js +0 -2998
  57. package/lib/less/plugin-manager.js +0 -168
  58. package/lib/less/render.js +0 -41
  59. package/lib/less/source-map-builder.js +0 -82
  60. package/lib/less/source-map-output.js +0 -151
  61. package/lib/less/transform-tree.js +0 -102
  62. package/lib/less/tree/anonymous.js +0 -61
  63. package/lib/less/tree/assignment.js +0 -48
  64. package/lib/less/tree/atrule-syntax.js +0 -8
  65. package/lib/less/tree/atrule.js +0 -340
  66. package/lib/less/tree/attribute.js +0 -63
  67. package/lib/less/tree/call.js +0 -132
  68. package/lib/less/tree/color.js +0 -285
  69. package/lib/less/tree/combinator.js +0 -38
  70. package/lib/less/tree/comment.js +0 -48
  71. package/lib/less/tree/condition.js +0 -65
  72. package/lib/less/tree/container.js +0 -104
  73. package/lib/less/tree/debug-info.js +0 -80
  74. package/lib/less/tree/declaration.js +0 -142
  75. package/lib/less/tree/detached-ruleset.js +0 -45
  76. package/lib/less/tree/dimension.js +0 -215
  77. package/lib/less/tree/element.js +0 -93
  78. package/lib/less/tree/expression.js +0 -100
  79. package/lib/less/tree/extend.js +0 -88
  80. package/lib/less/tree/import.js +0 -299
  81. package/lib/less/tree/index.js +0 -56
  82. package/lib/less/tree/interpolated-variable.js +0 -106
  83. package/lib/less/tree/javascript.js +0 -45
  84. package/lib/less/tree/js-eval-node.js +0 -80
  85. package/lib/less/tree/keyword.js +0 -28
  86. package/lib/less/tree/media.js +0 -90
  87. package/lib/less/tree/merge-rules.js +0 -47
  88. package/lib/less/tree/mixin-call.js +0 -283
  89. package/lib/less/tree/mixin-definition.js +0 -319
  90. package/lib/less/tree/namespace-value.js +0 -95
  91. package/lib/less/tree/negative.js +0 -37
  92. package/lib/less/tree/nested-at-rule.js +0 -239
  93. package/lib/less/tree/node.js +0 -310
  94. package/lib/less/tree/operation.js +0 -81
  95. package/lib/less/tree/paren.js +0 -41
  96. package/lib/less/tree/property.js +0 -96
  97. package/lib/less/tree/query-in-parens.js +0 -64
  98. package/lib/less/tree/quoted.js +0 -131
  99. package/lib/less/tree/ruleset.js +0 -1068
  100. package/lib/less/tree/selector.js +0 -201
  101. package/lib/less/tree/unicode-descriptor.js +0 -14
  102. package/lib/less/tree/unit.js +0 -170
  103. package/lib/less/tree/url.js +0 -83
  104. package/lib/less/tree/value.js +0 -60
  105. package/lib/less/tree/variable-call.js +0 -60
  106. package/lib/less/tree/variable.js +0 -85
  107. package/lib/less/utils.js +0 -126
  108. package/lib/less/visitors/extend-visitor.js +0 -505
  109. package/lib/less/visitors/import-sequencer.js +0 -56
  110. package/lib/less/visitors/import-visitor.js +0 -203
  111. package/lib/less/visitors/index.js +0 -15
  112. package/lib/less/visitors/join-selector-visitor.js +0 -65
  113. package/lib/less/visitors/set-tree-visibility-visitor.js +0 -57
  114. package/lib/less/visitors/to-css-visitor.js +0 -332
  115. package/lib/less/visitors/visitor.js +0 -165
  116. package/lib/less-browser/add-default-options.js +0 -53
  117. package/lib/less-browser/bootstrap.js +0 -67
  118. package/lib/less-browser/browser.js +0 -65
  119. package/lib/less-browser/cache.js +0 -43
  120. package/lib/less-browser/error-reporting.js +0 -170
  121. package/lib/less-browser/file-manager.js +0 -112
  122. package/lib/less-browser/image-size.js +0 -28
  123. package/lib/less-browser/index.js +0 -284
  124. package/lib/less-browser/log-listener.js +0 -42
  125. package/lib/less-browser/plugin-loader.js +0 -24
  126. package/lib/less-browser/utils.js +0 -30
  127. package/lib/less-node/environment.js +0 -43
  128. package/lib/less-node/file-manager.js +0 -156
  129. package/lib/less-node/fs.js +0 -14
  130. package/lib/less-node/image-size.js +0 -78
  131. package/lib/less-node/index.js +0 -31
  132. package/lib/less-node/lessc-helper.js +0 -95
  133. package/lib/less-node/plugin-loader.js +0 -62
  134. package/lib/less-node/url-file-manager.js +0 -60
package/README.md CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  > The dynamic stylesheet language. [lesscss.org](http://lesscss.org)
12
12
 
13
+ > [!IMPORTANT]
14
+ > This package README is for Less 5 alpha.1. Less 5 is a Jess-powered compiler
15
+ > preview for early testing and is not yet a drop-in replacement for Less 4.x.
16
+ > It covers Node.js `less.render()`, `less.renderFile()`, and `lessc`, plus
17
+ > variables, arithmetic, mixins, imports, and nested-rule output. Source maps,
18
+ > URL rewriting, and `compress` now work through the `less.render()` API; the
19
+ > legacy `@plugin` hook ABI is intentionally not carried over (function plugins
20
+ > are supported). See the **[Less 5 feature status](V5-STATUS.md)** for the full
21
+ > list of what is implemented, in progress, and intentionally not.
22
+
13
23
  Less extends CSS with variables, mixins, functions, nesting, and more — then compiles to standard CSS. Write cleaner stylesheets with less code.
14
24
 
15
25
  ```less
@@ -26,13 +36,21 @@ Less extends CSS with variables, mixins, functions, nesting, and more — then c
26
36
  ## Install
27
37
 
28
38
  ```sh
29
- npm install less
39
+ npm install less@alpha
40
+ ```
41
+
42
+ For a pinned first alpha:
43
+
44
+ ```sh
45
+ npm install less@5.0.0-alpha.1
30
46
  ```
31
47
 
32
48
  ## Usage
33
49
 
34
50
  ### Node.js
35
51
 
52
+ Less 5 alpha.1 requires Node.js `^20.19.0 || >=22.12.0`.
53
+
36
54
  ```js
37
55
  import less from 'less';
38
56
 
@@ -48,10 +66,10 @@ npx lessc styles.less styles.css
48
66
 
49
67
  ### Browser
50
68
 
51
- ```html
52
- <link rel="stylesheet/less" type="text/css" href="styles.less" />
53
- <script src="https://cdn.jsdelivr.net/npm/less"></script>
54
- ```
69
+ A browser build ships in the package (`dist/less-browser-dev.js`) and defines
70
+ `window.less` with the same render API; it powers the online playground. Full
71
+ browser-API parity with Less 4 is still being validated — see the
72
+ [feature status](V5-STATUS.md).
55
73
 
56
74
  ## Why Less?
57
75
 
package/V5-STATUS.md ADDED
@@ -0,0 +1,71 @@
1
+ # Less 5 (alpha) — feature status
2
+
3
+ Less 5 is a from-scratch compiler (the [Jess](https://github.com/jesscss/jess)
4
+ engine) behind the same `less.render(input, options)` / `lessc` interface Less 4
5
+ users know. The tables below compare Less 4 with the current Less 5 alpha —
6
+ what's implemented, what's still in progress, and what will **intentionally
7
+ not** be carried over (with the reason).
8
+
9
+ > **Status:** alpha, published under the npm `alpha` dist-tag
10
+ > (`npm install less@alpha`). APIs and output may still change. This page is kept
11
+ > honest by the `packages/less` alpha test suite — if a row here drifts from
12
+ > actual behavior, the suite fails.
13
+
14
+ The headline change: **Less 5 preserves your authored nesting by default** (it
15
+ emits nested CSS) instead of always flattening. Opt into flattened output with
16
+ `collapseNesting`.
17
+
18
+ **Legend:** ✅ supported · ⏳ in progress · ❌ not supported (by design) · ➖ not applicable
19
+
20
+ ## Language & output
21
+
22
+ | Feature | Less 4 | Less 5 | Notes |
23
+ | --- | :---: | :---: | --- |
24
+ | Variables, mixins (guards, named args), operations, functions | ✅ | ✅ | The Less builtin function library is ported. |
25
+ | `:extend` | ✅ | ✅ | |
26
+ | Nested-rule output | ➖ | ✅ | Less 4 always flattened; Less 5 **preserves** authored nesting by default. |
27
+ | `collapseNesting` (flatten instead) | ➖ | ✅ | `false` (default) / `'native'` (specificity-faithful) / `'compact'`. |
28
+ | `@media` query merging | ✅ | ❌ | Less 5 emits nested `@media` instead of rewriting to `@media (a) and (b)`. Browsers have nested `@media` far longer than native *selector* nesting, so nested output is safe — and merging can blow up combinatorially (each nested query multiplies out). |
29
+ | Inline JavaScript (backticks) | ✅ | ❌ | Removed. Script modules are the planned replacement for computed values; they are tracked separately from stylesheet composition below. |
30
+ | IE `progid:` / `filter` hacks | ✅ | ❌ | Removed. |
31
+
32
+ ## Options (`less.render` API)
33
+
34
+ | Feature | Less 4 | Less 5 | Notes |
35
+ | --- | :---: | :---: | --- |
36
+ | `math` modes | ✅ | ✅ | `always` / `parens-division` (default) / `parens`. |
37
+ | `unitMode` (formerly `strictUnits`) | ✅ | ✅ | `loose` / `preserve` (default) / `strict`. |
38
+ | `compress` | ✅ | ✅ | Minified, but not byte-identical to Less 4 `-x` (nesting preserved by default). |
39
+ | Source maps (`sourceMap`) | ✅ | ✅ | Returns `result.map`; annotation, inline data URI, `outputSourceFiles`, and the `rootpath`/`basepath`/`url` path variants all supported. |
40
+ | URL rewriting (`rewriteUrls` / `rootpath` / `urlArgs`) | ✅ | ✅ | Rewrites `url(...)` references. |
41
+ | `globalVars` / `modifyVars` injection | ✅ | ❌ | Not supported — these throw rather than silently no-op. |
42
+ | `javascriptEnabled` | ✅ | ❌ | JavaScript evaluation is not supported. |
43
+
44
+ ## Plugins (`@plugin`)
45
+
46
+ | Feature | Less 4 | Less 5 | Notes |
47
+ | --- | :---: | :---: | --- |
48
+ | Function plugins (`functions.add`) | ✅ | ✅ | Via the opt-in `@jesscss/plugin-less-compat` layer — the common `@plugin` shape. |
49
+ | npm-package imports | ✅ | ✅ | Native via `@jesscss/plugin-node-modules` (the `less-plugin-npm-import` case). |
50
+ | Visitor / tree-visitor ABI, full `less.tree` | ✅ | ❌ | Intentional — the Less 4 tree is not the Less 5 AST; a translation layer isn't worth it. |
51
+ | Pre-/post-processor hooks | ✅ | ❌ | Run PostCSS after Less; minification is native via `compress`. |
52
+ | File-manager hooks | ✅ | ❌ | The common case (npm import) is covered natively. |
53
+ | `@plugin (options)` + `registerPlugin` lifecycle | ✅ | ❌ | Deprecated Less 4 lifecycle; not built. |
54
+
55
+ ## Imports, CLI & tooling
56
+
57
+ | Feature | Less 4 | Less 5 | Notes |
58
+ | --- | :---: | :---: | --- |
59
+ | Sibling / relative `@import` | ✅ | ✅ | |
60
+ | Remote (`http(s)`) imports | ✅ | ⏳ | Gated behind an explicit network policy; not on by default. |
61
+ | `@compose` stylesheet modules | ➖ | ✅ | Isolated, non-transitive modules with inferred or explicit namespaces, `as *`, and per-edge `with` or shared `set` configuration. See the [canonical Modules and Imports source](https://github.com/jesscss/jess/blob/dev/packages/docs/docs-content/docs/shared/02-Language/14-modules-and-imports.mdx). |
62
+ | `@use` / `@from` script and data modules | ➖ | ⏳ | Reserved for JavaScript, TypeScript, JSON, and built-in modules; Less 5 does not recognize or execute them as modules yet. See the [canonical Modules and Imports source](https://github.com/jesscss/jess/blob/dev/packages/docs/docs-content/docs/shared/02-Language/14-modules-and-imports.mdx). |
63
+ | Browser build (`window.less`) | ✅ | ✅ | `dist/less-browser-dev.js` ships and powers the playground; full 4.x browser-API parity is ⏳. |
64
+ | `lessc` CLI (compile) | ✅ | ✅ | Compiles files. |
65
+ | `lessc` CLI **flags** for the newer options | ✅ | ✅ | `--compress`/`-x`, `--source-map[=file]` (+ `--source-map-inline` / `-include-source` / `-rootpath` / `-basepath` / `-url`), `--rewrite-urls` / `--rootpath` / `--url-args`, `--math` are all wired. |
66
+ | Diagnostics (`file:line:column` + excerpt) | ➖ | ✅ | Precise diagnostics, not raw parser offsets. |
67
+
68
+ ---
69
+
70
+ *Found a row that contradicts actual behavior? Please open an issue — a drift
71
+ between this page and the compiler is a bug.*