@jesscss/plugin-less-compat 2.0.0-alpha.6 → 2.0.0-alpha.8
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.
- package/README.md +40 -137
- package/lib/index.cjs +844 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +800 -10
- package/lib/less-adapter.cjs +216 -0
- package/lib/less-adapter.js +181 -0
- package/lib/less-compat-structures.cjs +378 -0
- package/lib/less-compat-structures.d.ts +2 -2
- package/lib/less-compat-structures.js +367 -512
- package/lib/nodes/at-rule.d.ts +2 -2
- package/lib/nodes/attribute-selector.d.ts +2 -2
- package/lib/nodes/call.d.ts +2 -2
- package/lib/nodes/color.d.ts +2 -1
- package/lib/nodes/combinator.d.ts +2 -1
- package/lib/nodes/comment.d.ts +2 -1
- package/lib/nodes/condition.d.ts +2 -2
- package/lib/nodes/declaration.d.ts +2 -2
- package/lib/nodes/dimension.d.ts +2 -1
- package/lib/nodes/expression.d.ts +2 -2
- package/lib/nodes/extend.d.ts +2 -1
- package/lib/nodes/import.d.ts +2 -2
- package/lib/nodes/keyword.d.ts +2 -1
- package/lib/nodes/list.d.ts +3 -2
- package/lib/nodes/mixin.d.ts +2 -2
- package/lib/nodes/negative.d.ts +2 -2
- package/lib/nodes/operation.d.ts +2 -2
- package/lib/nodes/paren.d.ts +2 -2
- package/lib/nodes/quoted.d.ts +2 -1
- package/lib/nodes/reference.d.ts +2 -1
- package/lib/nodes/ruleset.d.ts +2 -2
- package/lib/nodes/selector.d.ts +2 -2
- package/lib/nodes/sequence.d.ts +2 -2
- package/lib/nodes/url.d.ts +2 -1
- package/lib/nodes/var-declaration.d.ts +2 -2
- package/lib/plugin.d.ts +44 -16
- package/lib/transform/adapter.d.ts +9 -11
- package/lib/transform/index.cjs +13 -0
- package/lib/transform/index.d.ts +1 -1
- package/lib/transform/index.js +3 -8
- package/lib/transform/less-adapter.d.ts +29 -0
- package/lib/transform.cjs +1045 -0
- package/lib/transform.js +1015 -0
- package/lib/types.d.ts +153 -28
- package/package.json +6 -9
- package/lib/index.js.map +0 -1
- package/lib/less-compat-structures.js.map +0 -1
- package/lib/nodes/at-rule.js +0 -21
- package/lib/nodes/at-rule.js.map +0 -1
- package/lib/nodes/attribute-selector.js +0 -18
- package/lib/nodes/attribute-selector.js.map +0 -1
- package/lib/nodes/call.js +0 -27
- package/lib/nodes/call.js.map +0 -1
- package/lib/nodes/color.js +0 -23
- package/lib/nodes/color.js.map +0 -1
- package/lib/nodes/combinator.js +0 -7
- package/lib/nodes/combinator.js.map +0 -1
- package/lib/nodes/comment.js +0 -9
- package/lib/nodes/comment.js.map +0 -1
- package/lib/nodes/condition.js +0 -19
- package/lib/nodes/condition.js.map +0 -1
- package/lib/nodes/declaration.js +0 -38
- package/lib/nodes/declaration.js.map +0 -1
- package/lib/nodes/dimension.js +0 -9
- package/lib/nodes/dimension.js.map +0 -1
- package/lib/nodes/expression.js +0 -16
- package/lib/nodes/expression.js.map +0 -1
- package/lib/nodes/extend.js +0 -18
- package/lib/nodes/extend.js.map +0 -1
- package/lib/nodes/import.js +0 -22
- package/lib/nodes/import.js.map +0 -1
- package/lib/nodes/index.js +0 -308
- package/lib/nodes/index.js.map +0 -1
- package/lib/nodes/keyword.js +0 -8
- package/lib/nodes/keyword.js.map +0 -1
- package/lib/nodes/list.js +0 -61
- package/lib/nodes/list.js.map +0 -1
- package/lib/nodes/mixin.js +0 -22
- package/lib/nodes/mixin.js.map +0 -1
- package/lib/nodes/negative.js +0 -13
- package/lib/nodes/negative.js.map +0 -1
- package/lib/nodes/operation.js +0 -22
- package/lib/nodes/operation.js.map +0 -1
- package/lib/nodes/paren.js +0 -13
- package/lib/nodes/paren.js.map +0 -1
- package/lib/nodes/quoted.js +0 -23
- package/lib/nodes/quoted.js.map +0 -1
- package/lib/nodes/reference.js +0 -44
- package/lib/nodes/reference.js.map +0 -1
- package/lib/nodes/ruleset.js +0 -67
- package/lib/nodes/ruleset.js.map +0 -1
- package/lib/nodes/selector.js +0 -158
- package/lib/nodes/selector.js.map +0 -1
- package/lib/nodes/sequence.js +0 -56
- package/lib/nodes/sequence.js.map +0 -1
- package/lib/nodes/url.js +0 -13
- package/lib/nodes/url.js.map +0 -1
- package/lib/nodes/var-declaration.js +0 -21
- package/lib/nodes/var-declaration.js.map +0 -1
- package/lib/plugin-utils.js +0 -100
- package/lib/plugin-utils.js.map +0 -1
- package/lib/plugin.js +0 -1026
- package/lib/plugin.js.map +0 -1
- package/lib/transform/adapter.js +0 -111
- package/lib/transform/adapter.js.map +0 -1
- package/lib/transform/from-less.js +0 -170
- package/lib/transform/from-less.js.map +0 -1
- package/lib/transform/index.js.map +0 -1
- package/lib/transform/proxy.d.ts +0 -32
- package/lib/transform/proxy.js +0 -138
- package/lib/transform/proxy.js.map +0 -1
- package/lib/transform/to-less.js +0 -130
- package/lib/transform/to-less.js.map +0 -1
- package/lib/transform/type-map.js +0 -105
- package/lib/transform/type-map.js.map +0 -1
- package/lib/types.js +0 -5
- package/lib/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,139 +1,42 @@
|
|
|
1
1
|
# @jesscss/plugin-less-compat
|
|
2
2
|
|
|
3
|
-
Less.js compatibility
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const compiler = new Compiler({
|
|
44
|
-
plugins: [
|
|
45
|
-
lessPlugin(),
|
|
46
|
-
lessCompatPlugin({
|
|
47
|
-
visitors: [autoprefix]
|
|
48
|
-
})
|
|
49
|
-
]
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const result = await compiler.compile('styles.less');
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Advanced: Direct Transformation
|
|
56
|
-
|
|
57
|
-
```typescript
|
|
58
|
-
import { toLessTree, fromLessTree } from '@jesscss/plugin-less-compat/transform';
|
|
59
|
-
import customLessVisitor from './custom-visitor';
|
|
60
|
-
|
|
61
|
-
const jessTree = parseJess(source);
|
|
62
|
-
const lessTree = toLessTree(jessTree);
|
|
63
|
-
|
|
64
|
-
// Apply custom Less visitor
|
|
65
|
-
lessTree.accept(customLessVisitor);
|
|
66
|
-
|
|
67
|
-
// Convert back to Jess
|
|
68
|
-
const modifiedJessTree = fromLessTree(lessTree);
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Using with Multiple Less Plugins
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
import { lessCompatPlugin } from '@jesscss/plugin-less-compat';
|
|
75
|
-
import autoprefix from 'less-plugin-autoprefix';
|
|
76
|
-
import cleanCSS from 'less-plugin-clean-css';
|
|
77
|
-
|
|
78
|
-
const compiler = new Compiler({
|
|
79
|
-
plugins: [
|
|
80
|
-
lessPlugin(),
|
|
81
|
-
lessCompatPlugin({
|
|
82
|
-
visitors: [
|
|
83
|
-
autoprefix,
|
|
84
|
-
cleanCSS
|
|
85
|
-
]
|
|
86
|
-
})
|
|
87
|
-
]
|
|
88
|
-
});
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
## Supported Less Plugins
|
|
92
|
-
|
|
93
|
-
This package has been tested with:
|
|
94
|
-
|
|
95
|
-
- ✅ `less-plugin-autoprefix` - Automatic vendor prefixing
|
|
96
|
-
- ✅ `less-plugin-clean-css` - CSS minification
|
|
97
|
-
- ✅ `less-plugin-dls` - Design Language System support
|
|
98
|
-
|
|
99
|
-
Other Less.js plugins should work, but may require additional testing.
|
|
100
|
-
|
|
101
|
-
## API
|
|
102
|
-
|
|
103
|
-
### `lessCompatPlugin(options?)`
|
|
104
|
-
|
|
105
|
-
Creates a Jess plugin that enables Less.js compatibility.
|
|
106
|
-
|
|
107
|
-
**Options:**
|
|
108
|
-
- `visitors?: LessVisitor[]` - Array of Less.js visitors to apply
|
|
109
|
-
- `cache?: boolean` - Enable conversion caching (default: `true`)
|
|
110
|
-
|
|
111
|
-
### `toLessTree(jessRules: Rules)`
|
|
112
|
-
|
|
113
|
-
Converts a Jess `Rules` tree to a Less.js-compatible tree.
|
|
114
|
-
|
|
115
|
-
### `fromLessTree(lessTree: LessNode)`
|
|
116
|
-
|
|
117
|
-
Converts a Less.js tree back to a Jess `Rules` tree.
|
|
118
|
-
|
|
119
|
-
### `toLessNode(jessNode: Node, options?)`
|
|
120
|
-
|
|
121
|
-
Converts a single Jess node to a Less.js-compatible node.
|
|
122
|
-
|
|
123
|
-
### `fromLessNode(lessNode: LessNode, options?)`
|
|
124
|
-
|
|
125
|
-
Converts a single Less.js node back to a Jess node.
|
|
126
|
-
|
|
127
|
-
## Implementation Status
|
|
128
|
-
|
|
129
|
-
This package is currently in **alpha**.
|
|
130
|
-
|
|
131
|
-
Developer notes and historical analyses live in [DESIGN.md](./DESIGN.md) and `_archive/`.
|
|
132
|
-
|
|
133
|
-
## Contributing
|
|
134
|
-
|
|
135
|
-
Contributions welcome! Please see the main Jess repository for contribution guidelines.
|
|
136
|
-
|
|
137
|
-
## License
|
|
138
|
-
|
|
139
|
-
MIT
|
|
3
|
+
**The Less.js 4.x compatibility bridge — run existing Less plugins and visitors
|
|
4
|
+
against the Jess AST.**
|
|
5
|
+
|
|
6
|
+
[Jess](https://github.com/jesscss/jess) *is* Less.js v5, but the Less 4.x
|
|
7
|
+
ecosystem has years of plugins and visitors written against the old Less AST.
|
|
8
|
+
This package bridges the two: it converts a Jess `Rules` tree to a
|
|
9
|
+
Less.js-compatible tree, runs Less 4.x visitors over it, and converts the result
|
|
10
|
+
back — so tools like autoprefixing or minification plugins can keep working
|
|
11
|
+
against Jess-compiled stylesheets.
|
|
12
|
+
|
|
13
|
+
It's the load-bearing piece of the eventual **`less@5` adoption layer**: the seam
|
|
14
|
+
that lets a Less 4.x project move onto Jess without abandoning its existing plugin
|
|
15
|
+
setup.
|
|
16
|
+
|
|
17
|
+
## How it works
|
|
18
|
+
|
|
19
|
+
- **Bidirectional transformation** between Jess AST nodes and Less.js AST nodes,
|
|
20
|
+
with lazy per-field conversion so only the fields a visitor touches are
|
|
21
|
+
materialized.
|
|
22
|
+
- **Visitor support** — Less 4.x visitors run over the converted tree.
|
|
23
|
+
- Package resolution for `@plugin "name"` is delegated to
|
|
24
|
+
[`@jesscss/plugin-node-modules`](../jess-plugin-node-modules).
|
|
25
|
+
|
|
26
|
+
## Status
|
|
27
|
+
|
|
28
|
+
**Alpha / experimental.** It works for the plugins it has been exercised against
|
|
29
|
+
(e.g. `less-plugin-autoprefix`, `less-plugin-clean-css`, `less-plugin-dls`), but
|
|
30
|
+
it has not been validated across the whole Less plugin ecosystem, and the surface
|
|
31
|
+
may change. If you need broad, battle-tested Less-plugin support today, use
|
|
32
|
+
Less.js directly.
|
|
33
|
+
|
|
34
|
+
The programmatic plugin/compiler API is **not yet stabilized** — the `jess` /
|
|
35
|
+
`lessc` CLIs are the public surface for the alpha. Watch the
|
|
36
|
+
[docs site](https://jesscss.github.io/) for the API once it settles. Current
|
|
37
|
+
design notes live in [DESIGN.md](./DESIGN.md).
|
|
38
|
+
|
|
39
|
+
- Project overview & positioning: <https://github.com/jesscss/jess#readme>
|
|
40
|
+
- Docs: <https://jesscss.github.io/> (currently pre-alpha content)
|
|
41
|
+
- Issues: <https://github.com/jesscss/jess/issues>
|
|
42
|
+
- License: MIT
|