less 5.0.0-alpha.7 → 5.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/dist/less-browser-dev.js +384 -384
- package/dist/less-node.cjs +67 -21
- package/lib/options.d.ts +32 -0
- package/lib/options.js +65 -19
- package/package.json +8 -8
package/dist/less-node.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Less - Leaner CSS v5.0.0-alpha.
|
|
2
|
+
* Less - Leaner CSS v5.0.0-alpha.8
|
|
3
3
|
* http://lesscss.org
|
|
4
4
|
*
|
|
5
5
|
* Copyright (c) 2009-2026, Alexis Sellier <self@cloudhead.net>
|
|
@@ -105,19 +105,9 @@ const logger = {
|
|
|
105
105
|
*/
|
|
106
106
|
|
|
107
107
|
const unsupportedAlphaOptions = new Map([
|
|
108
|
-
['sourceMap', 'source maps are not supported'],
|
|
109
|
-
['sourceMapFilename', 'source maps are not supported'],
|
|
110
|
-
['sourceMapRootpath', 'source maps are not supported'],
|
|
111
|
-
['sourceMapBasepath', 'source maps are not supported'],
|
|
112
|
-
['sourceMapURL', 'source maps are not supported'],
|
|
113
|
-
['sourceMapFileInline', 'source maps are not supported'],
|
|
114
108
|
['globalVars', 'global variable injection is not supported'],
|
|
115
109
|
['modifyVars', 'modify-var injection is not supported'],
|
|
116
|
-
['rootpath', 'URL rootpath rewriting is not supported'],
|
|
117
|
-
['rewriteUrls', 'URL rewriting is not supported'],
|
|
118
|
-
['urlArgs', 'URL argument rewriting is not supported'],
|
|
119
110
|
['javascriptEnabled', 'JavaScript evaluation is not supported'],
|
|
120
|
-
['compress', 'compressed output is not supported'],
|
|
121
111
|
]);
|
|
122
112
|
|
|
123
113
|
function validateAlphaOptions(options) {
|
|
@@ -180,6 +170,36 @@ function resolveCollapseNesting(value) {
|
|
|
180
170
|
);
|
|
181
171
|
}
|
|
182
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Build the compiler's `output.sourceMap` value from Less options. Source maps
|
|
175
|
+
* are enabled when `sourceMap` is truthy; the object form (or the flat legacy
|
|
176
|
+
* `sourceMap*` options) configures the details. Returns `undefined` when no
|
|
177
|
+
* source map is requested.
|
|
178
|
+
* @param {import('./options.js').LessRenderOptions} opts
|
|
179
|
+
* @returns {undefined | true | Record<string, unknown>}
|
|
180
|
+
*/
|
|
181
|
+
function resolveSourceMap(opts) {
|
|
182
|
+
if (!opts.sourceMap) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
185
|
+
const config = (typeof opts.sourceMap === 'object' && opts.sourceMap !== null)
|
|
186
|
+
? { ...opts.sourceMap }
|
|
187
|
+
: {};
|
|
188
|
+
// Fold the flat legacy `sourceMap*` options into the object form the compiler
|
|
189
|
+
// reads; an explicit object sub-option wins over its flat alias.
|
|
190
|
+
const flat = [
|
|
191
|
+
'sourceMapURL', 'sourceMapFilename', 'sourceMapFullFilename',
|
|
192
|
+
'sourceMapRootpath', 'sourceMapBasepath', 'sourceMapFileInline',
|
|
193
|
+
'sourceMapOutputFilename', 'outputSourceFiles', 'disableSourcemapAnnotation'
|
|
194
|
+
];
|
|
195
|
+
for (const key of flat) {
|
|
196
|
+
if (opts[key] !== undefined && config[key] === undefined) {
|
|
197
|
+
config[key] = opts[key];
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return Object.keys(config).length > 0 ? config : true;
|
|
201
|
+
}
|
|
202
|
+
|
|
183
203
|
/**
|
|
184
204
|
* Map Less render options to Jess compiler config.
|
|
185
205
|
* @param {import('./options.js').LessRenderOptions} [options] Less-style options
|
|
@@ -214,11 +234,37 @@ function createLessOptions(options) {
|
|
|
214
234
|
);
|
|
215
235
|
}
|
|
216
236
|
|
|
217
|
-
|
|
237
|
+
// URL rewriting lives on the Less plugin (it rewrites `url(...)` during
|
|
238
|
+
// serialization), not in `output`. Only forward keys the caller set so the
|
|
239
|
+
// plugin's own v5 defaults apply otherwise.
|
|
240
|
+
const lessPluginOptions = {};
|
|
241
|
+
if (opts.rootpath !== undefined) lessPluginOptions.rootpath = opts.rootpath;
|
|
242
|
+
if (opts.rewriteUrls !== undefined) lessPluginOptions.rewriteUrls = opts.rewriteUrls;
|
|
243
|
+
if (opts.urlArgs !== undefined) lessPluginOptions.urlArgs = opts.urlArgs;
|
|
244
|
+
|
|
245
|
+
const plugins = [lessPlugin__default["default"](lessPluginOptions)];
|
|
218
246
|
if (!skipLessCompat) {
|
|
219
247
|
plugins.push(pluginLessCompat.lessCompatPlugin({ plugins: lessPlugins }));
|
|
220
248
|
}
|
|
221
249
|
|
|
250
|
+
// The projection/serialization options the compiler reads off `output`:
|
|
251
|
+
// `collapseNesting` (nesting flatten mode), `compress` (minified output), and
|
|
252
|
+
// `sourceMap`. Emitted as a single file-less array entry so an explicit render
|
|
253
|
+
// option overrides a file-local styles.config for every key (the config merge
|
|
254
|
+
// appends it as the override default); left `{}` when the caller set none.
|
|
255
|
+
const outputEntry = {};
|
|
256
|
+
if (opts.collapseNesting !== undefined) {
|
|
257
|
+
outputEntry.collapseNesting = resolveCollapseNesting(opts.collapseNesting);
|
|
258
|
+
}
|
|
259
|
+
if (opts.compress !== undefined) {
|
|
260
|
+
outputEntry.compress = opts.compress;
|
|
261
|
+
}
|
|
262
|
+
const sourceMap = resolveSourceMap(opts);
|
|
263
|
+
if (sourceMap !== undefined) {
|
|
264
|
+
outputEntry.sourceMap = sourceMap;
|
|
265
|
+
}
|
|
266
|
+
const output = Object.keys(outputEntry).length > 0 ? [outputEntry] : {};
|
|
267
|
+
|
|
222
268
|
const configOptions = {
|
|
223
269
|
compile: {
|
|
224
270
|
searchPaths: opts.paths || [],
|
|
@@ -226,14 +272,7 @@ function createLessOptions(options) {
|
|
|
226
272
|
...(unitMode !== undefined && { unitMode }),
|
|
227
273
|
plugins,
|
|
228
274
|
},
|
|
229
|
-
|
|
230
|
-
// flattened projection. Pass the enum through unchanged; Jess owns the one
|
|
231
|
-
// renderer and its output mode. A file's styles.config may use an output
|
|
232
|
-
// array — a file-less output entry is the compiler's documented per-render
|
|
233
|
-
// override, so an explicit public Less option stays authoritative over it.
|
|
234
|
-
output: opts.collapseNesting !== undefined
|
|
235
|
-
? [{ collapseNesting: resolveCollapseNesting(opts.collapseNesting) }]
|
|
236
|
-
: {},
|
|
275
|
+
output,
|
|
237
276
|
language: {},
|
|
238
277
|
};
|
|
239
278
|
|
|
@@ -261,6 +300,13 @@ function mapRenderResult(result, options) {
|
|
|
261
300
|
css: result.css ?? '',
|
|
262
301
|
};
|
|
263
302
|
|
|
303
|
+
// Less 4.x returns the source map as `result.map` (a JSON string) when one was
|
|
304
|
+
// requested; forward it so `less.render(src, { sourceMap: true })` behaves the
|
|
305
|
+
// same. The compiler writes the `sourceMappingURL` annotation into `css` itself.
|
|
306
|
+
if (result.map !== undefined) {
|
|
307
|
+
out.map = result.map;
|
|
308
|
+
}
|
|
309
|
+
|
|
264
310
|
if (result.imports && Array.isArray(result.imports)) {
|
|
265
311
|
out.imports = result.imports;
|
|
266
312
|
}
|
|
@@ -279,7 +325,7 @@ function mapRenderResult(result, options) {
|
|
|
279
325
|
* @module less/lib/version
|
|
280
326
|
*/
|
|
281
327
|
|
|
282
|
-
const semver = "5.0.0-alpha.
|
|
328
|
+
const semver = "5.0.0-alpha.8";
|
|
283
329
|
const parsed = parseNodeVersion__default["default"](`v${semver}`);
|
|
284
330
|
|
|
285
331
|
const version = {
|
package/lib/options.d.ts
CHANGED
|
@@ -21,6 +21,38 @@ export interface LessRenderOptions {
|
|
|
21
21
|
* deprecated alias for `'native'`.
|
|
22
22
|
*/
|
|
23
23
|
collapseNesting?: boolean | 'native' | 'compact';
|
|
24
|
+
/** Minified output. */
|
|
25
|
+
compress?: boolean;
|
|
26
|
+
/** Prepend a path to every rewritten `url(...)` and imported reference. */
|
|
27
|
+
rootpath?: string;
|
|
28
|
+
/** Rewrite relative `url(...)` against the importing file: `'all'` | `'local'` | `'off'` (or boolean). */
|
|
29
|
+
rewriteUrls?: boolean | 'all' | 'local' | 'off';
|
|
30
|
+
/** Append a query string to every non-data `url(...)`. */
|
|
31
|
+
urlArgs?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Emit a source map. `true` turns it on with defaults; the object form (or the
|
|
34
|
+
* flat legacy `sourceMap*` options) configures it. Returned as `result.map`.
|
|
35
|
+
*/
|
|
36
|
+
sourceMap?: boolean | {
|
|
37
|
+
sourceMapURL?: string;
|
|
38
|
+
sourceMapFilename?: string;
|
|
39
|
+
sourceMapFullFilename?: string;
|
|
40
|
+
sourceMapRootpath?: string;
|
|
41
|
+
sourceMapBasepath?: string;
|
|
42
|
+
sourceMapFileInline?: boolean;
|
|
43
|
+
sourceMapOutputFilename?: string;
|
|
44
|
+
outputSourceFiles?: boolean;
|
|
45
|
+
disableSourcemapAnnotation?: boolean;
|
|
46
|
+
};
|
|
47
|
+
sourceMapURL?: string;
|
|
48
|
+
sourceMapFilename?: string;
|
|
49
|
+
sourceMapFullFilename?: string;
|
|
50
|
+
sourceMapRootpath?: string;
|
|
51
|
+
sourceMapBasepath?: string;
|
|
52
|
+
sourceMapFileInline?: boolean;
|
|
53
|
+
sourceMapOutputFilename?: string;
|
|
54
|
+
outputSourceFiles?: boolean;
|
|
55
|
+
disableSourcemapAnnotation?: boolean;
|
|
24
56
|
/** @internal Jess alpha benchmark-only flag for source graphs already proven @plugin-free. */
|
|
25
57
|
__jessSkipLessCompatWhenPluginFree?: boolean;
|
|
26
58
|
}
|
package/lib/options.js
CHANGED
|
@@ -8,19 +8,9 @@ import { lessCompatPlugin } from '@jesscss/plugin-less-compat';
|
|
|
8
8
|
import { logger } from './logger.js';
|
|
9
9
|
|
|
10
10
|
const unsupportedAlphaOptions = new Map([
|
|
11
|
-
['sourceMap', 'source maps are not supported'],
|
|
12
|
-
['sourceMapFilename', 'source maps are not supported'],
|
|
13
|
-
['sourceMapRootpath', 'source maps are not supported'],
|
|
14
|
-
['sourceMapBasepath', 'source maps are not supported'],
|
|
15
|
-
['sourceMapURL', 'source maps are not supported'],
|
|
16
|
-
['sourceMapFileInline', 'source maps are not supported'],
|
|
17
11
|
['globalVars', 'global variable injection is not supported'],
|
|
18
12
|
['modifyVars', 'modify-var injection is not supported'],
|
|
19
|
-
['rootpath', 'URL rootpath rewriting is not supported'],
|
|
20
|
-
['rewriteUrls', 'URL rewriting is not supported'],
|
|
21
|
-
['urlArgs', 'URL argument rewriting is not supported'],
|
|
22
13
|
['javascriptEnabled', 'JavaScript evaluation is not supported'],
|
|
23
|
-
['compress', 'compressed output is not supported'],
|
|
24
14
|
]);
|
|
25
15
|
|
|
26
16
|
function validateAlphaOptions(options) {
|
|
@@ -83,6 +73,36 @@ function resolveCollapseNesting(value) {
|
|
|
83
73
|
);
|
|
84
74
|
}
|
|
85
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Build the compiler's `output.sourceMap` value from Less options. Source maps
|
|
78
|
+
* are enabled when `sourceMap` is truthy; the object form (or the flat legacy
|
|
79
|
+
* `sourceMap*` options) configures the details. Returns `undefined` when no
|
|
80
|
+
* source map is requested.
|
|
81
|
+
* @param {import('./options.js').LessRenderOptions} opts
|
|
82
|
+
* @returns {undefined | true | Record<string, unknown>}
|
|
83
|
+
*/
|
|
84
|
+
function resolveSourceMap(opts) {
|
|
85
|
+
if (!opts.sourceMap) {
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
const config = (typeof opts.sourceMap === 'object' && opts.sourceMap !== null)
|
|
89
|
+
? { ...opts.sourceMap }
|
|
90
|
+
: {};
|
|
91
|
+
// Fold the flat legacy `sourceMap*` options into the object form the compiler
|
|
92
|
+
// reads; an explicit object sub-option wins over its flat alias.
|
|
93
|
+
const flat = [
|
|
94
|
+
'sourceMapURL', 'sourceMapFilename', 'sourceMapFullFilename',
|
|
95
|
+
'sourceMapRootpath', 'sourceMapBasepath', 'sourceMapFileInline',
|
|
96
|
+
'sourceMapOutputFilename', 'outputSourceFiles', 'disableSourcemapAnnotation'
|
|
97
|
+
];
|
|
98
|
+
for (const key of flat) {
|
|
99
|
+
if (opts[key] !== undefined && config[key] === undefined) {
|
|
100
|
+
config[key] = opts[key];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return Object.keys(config).length > 0 ? config : true;
|
|
104
|
+
}
|
|
105
|
+
|
|
86
106
|
/**
|
|
87
107
|
* Map Less render options to Jess compiler config.
|
|
88
108
|
* @param {import('./options.js').LessRenderOptions} [options] Less-style options
|
|
@@ -117,11 +137,37 @@ export function createLessOptions(options) {
|
|
|
117
137
|
);
|
|
118
138
|
}
|
|
119
139
|
|
|
120
|
-
|
|
140
|
+
// URL rewriting lives on the Less plugin (it rewrites `url(...)` during
|
|
141
|
+
// serialization), not in `output`. Only forward keys the caller set so the
|
|
142
|
+
// plugin's own v5 defaults apply otherwise.
|
|
143
|
+
const lessPluginOptions = {};
|
|
144
|
+
if (opts.rootpath !== undefined) lessPluginOptions.rootpath = opts.rootpath;
|
|
145
|
+
if (opts.rewriteUrls !== undefined) lessPluginOptions.rewriteUrls = opts.rewriteUrls;
|
|
146
|
+
if (opts.urlArgs !== undefined) lessPluginOptions.urlArgs = opts.urlArgs;
|
|
147
|
+
|
|
148
|
+
const plugins = [lessPlugin(lessPluginOptions)];
|
|
121
149
|
if (!skipLessCompat) {
|
|
122
150
|
plugins.push(lessCompatPlugin({ plugins: lessPlugins }));
|
|
123
151
|
}
|
|
124
152
|
|
|
153
|
+
// The projection/serialization options the compiler reads off `output`:
|
|
154
|
+
// `collapseNesting` (nesting flatten mode), `compress` (minified output), and
|
|
155
|
+
// `sourceMap`. Emitted as a single file-less array entry so an explicit render
|
|
156
|
+
// option overrides a file-local styles.config for every key (the config merge
|
|
157
|
+
// appends it as the override default); left `{}` when the caller set none.
|
|
158
|
+
const outputEntry = {};
|
|
159
|
+
if (opts.collapseNesting !== undefined) {
|
|
160
|
+
outputEntry.collapseNesting = resolveCollapseNesting(opts.collapseNesting);
|
|
161
|
+
}
|
|
162
|
+
if (opts.compress !== undefined) {
|
|
163
|
+
outputEntry.compress = opts.compress;
|
|
164
|
+
}
|
|
165
|
+
const sourceMap = resolveSourceMap(opts);
|
|
166
|
+
if (sourceMap !== undefined) {
|
|
167
|
+
outputEntry.sourceMap = sourceMap;
|
|
168
|
+
}
|
|
169
|
+
const output = Object.keys(outputEntry).length > 0 ? [outputEntry] : {};
|
|
170
|
+
|
|
125
171
|
const configOptions = {
|
|
126
172
|
compile: {
|
|
127
173
|
searchPaths: opts.paths || [],
|
|
@@ -129,14 +175,7 @@ export function createLessOptions(options) {
|
|
|
129
175
|
...(unitMode !== undefined && { unitMode }),
|
|
130
176
|
plugins,
|
|
131
177
|
},
|
|
132
|
-
|
|
133
|
-
// flattened projection. Pass the enum through unchanged; Jess owns the one
|
|
134
|
-
// renderer and its output mode. A file's styles.config may use an output
|
|
135
|
-
// array — a file-less output entry is the compiler's documented per-render
|
|
136
|
-
// override, so an explicit public Less option stays authoritative over it.
|
|
137
|
-
output: opts.collapseNesting !== undefined
|
|
138
|
-
? [{ collapseNesting: resolveCollapseNesting(opts.collapseNesting) }]
|
|
139
|
-
: {},
|
|
178
|
+
output,
|
|
140
179
|
language: {},
|
|
141
180
|
};
|
|
142
181
|
|
|
@@ -165,6 +204,13 @@ export function mapRenderResult(result, options) {
|
|
|
165
204
|
css: result.css ?? '',
|
|
166
205
|
};
|
|
167
206
|
|
|
207
|
+
// Less 4.x returns the source map as `result.map` (a JSON string) when one was
|
|
208
|
+
// requested; forward it so `less.render(src, { sourceMap: true })` behaves the
|
|
209
|
+
// same. The compiler writes the `sourceMappingURL` annotation into `css` itself.
|
|
210
|
+
if (result.map !== undefined) {
|
|
211
|
+
out.map = result.map;
|
|
212
|
+
}
|
|
213
|
+
|
|
168
214
|
if (result.imports && Array.isArray(result.imports)) {
|
|
169
215
|
out.imports = result.imports;
|
|
170
216
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "less",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.8",
|
|
4
4
|
"description": "Leaner CSS",
|
|
5
5
|
"homepage": "http://lesscss.org",
|
|
6
6
|
"author": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"scripts": {
|
|
54
54
|
"quicktest": "npm run test:legacy-node",
|
|
55
|
-
"test:alpha": "npm run typecheck && npm run build && npm run test:lessc && node test/jess-alpha-fast-path.mjs && node test/alpha-support.mjs && node test/alpha-fixtures.mjs",
|
|
55
|
+
"test:alpha": "npm run typecheck && npm run build && npm run test:lessc && node test/jess-alpha-fast-path.mjs && node test/alpha-support.mjs && node test/alpha-sourcemaps.mjs && node test/alpha-fixtures.mjs",
|
|
56
56
|
"test:lessc": "node test/lessc-alpha.mjs",
|
|
57
57
|
"test": "npm run test:alpha",
|
|
58
58
|
"test:module": "node test/test-es6.js && node test/test-cjs.cjs",
|
|
@@ -141,15 +141,15 @@
|
|
|
141
141
|
"rawcurrent": "https://raw.github.com/less/less.js/v",
|
|
142
142
|
"sourcearchive": "https://github.com/less/less.js/archive/v",
|
|
143
143
|
"dependencies": {
|
|
144
|
-
"@jesscss/compiler": "2.0.0-alpha.
|
|
145
|
-
"@jesscss/core": "2.0.0-alpha.
|
|
146
|
-
"@jesscss/plugin-less": "2.0.0-alpha.
|
|
147
|
-
"@jesscss/plugin-less-compat": "2.0.0-alpha.
|
|
148
|
-
"@jesscss/plugin-node-modules": "2.0.0-alpha.
|
|
144
|
+
"@jesscss/compiler": "2.0.0-alpha.21",
|
|
145
|
+
"@jesscss/core": "2.0.0-alpha.21",
|
|
146
|
+
"@jesscss/plugin-less": "2.0.0-alpha.21",
|
|
147
|
+
"@jesscss/plugin-less-compat": "2.0.0-alpha.21",
|
|
148
|
+
"@jesscss/plugin-node-modules": "2.0.0-alpha.21",
|
|
149
149
|
"parse-node-version": "^1.0.1"
|
|
150
150
|
},
|
|
151
151
|
"peerDependencies": {
|
|
152
|
-
"@jesscss/plugin-js": "2.0.0-alpha.
|
|
152
|
+
"@jesscss/plugin-js": "2.0.0-alpha.21"
|
|
153
153
|
},
|
|
154
154
|
"peerDependenciesMeta": {
|
|
155
155
|
"@jesscss/plugin-js": {
|