Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
reviews:
max_files: 200
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
test:
name: 'Tests on ${{matrix.os}} with Node "${{matrix.node}}"'
strategy:
fail-fast: false
matrix:
# Test all mainstream operating systems
os: [ubuntu-latest, macos-latest, windows-latest]
Expand Down Expand Up @@ -40,8 +41,7 @@ jobs:
run: pnpm install
- name: Print put node & npm version
run: node --version && pnpm --version
# Pin the version of Playwright to match package.json to avoid installing a newer version which may expect different binaries
- name: Install chromium
run: npx playwright@1.50.1 install chromium
run: pnpm exec playwright install chromium
- name: Run unit test
run: pnpm run test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ npm-debug.log
.nyc_output
coverage
*.lcov

# Build output
dist
11,964 changes: 0 additions & 11,964 deletions dist/less.js

This file was deleted.

11 changes: 0 additions & 11 deletions dist/less.min.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/less.min.js.map

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"github-changes": "^1.1.2",
"husky": "~9.1.7",
"npm-run-all": "^4.1.5",
"playwright": "1.50.1",
"semver": "^6.3.1"
},
"packageManager": "pnpm@8.15.0"
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions packages/less/.gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# project-specific
tmp
lib
dist
test/browser/less.min.js
test/browser/less.min.js.map
test/sourcemaps/**/*.map
test/sourcemaps/*.map
test/sourcemaps/*.css
test/less-bom
test/less-bom
lib/**/*.css.map
25 changes: 6 additions & 19 deletions packages/less/Gruntfile.js → packages/less/Gruntfile.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,16 @@ module.exports = function(grunt) {
}
},
build: {
command: [
/** Browser runtime */
"node build/rollup.js --dist",
/** Node.js runtime */
"npm run build"
].join(" && ")
command: "node build/rollup.js --dist"
},
testbuild: {
command: [
"npm run build",
"node build/rollup.js --browser --out=./tmp/browser/less.min.js"
].join(" && ")
},
testcjs: {
command: "npm run build"
command: "node build/rollup.js --browser --out=./tmp/browser/less.min.js"
},
testbrowser: {
command: "node build/rollup.js --browser --out=./tmp/browser/less.min.js"
},
test: {
command: 'npx ts-node test/test-es6.ts && node test/index.js'
command: 'node test/test-es6.js && node test/index.js'
},
generatebrowser: {
command: 'node test/browser/generator/generate.js'
Expand Down Expand Up @@ -265,11 +254,11 @@ module.exports = function(grunt) {
eslint: {
target: [
"test/**/*.js",
"src/less*/**/*.js",
"lib/less*/**/*.js",
"!test/less/errors/plugin/plugin-error.js"
],
options: {
configFile: ".eslintrc.js",
configFile: ".eslintrc.cjs",
fix: true
}
},
Expand Down Expand Up @@ -381,9 +370,8 @@ module.exports = function(grunt) {
// Run shell plugin test
grunt.registerTask("shell-plugin", ["shell:plugin"]);

// Quickly build and run Node tests
// Quickly run Node tests (no build step needed)
grunt.registerTask("quicktest", [
"shell:testcjs",
"shell:test"
]);

Expand All @@ -397,7 +385,6 @@ module.exports = function(grunt) {

// Run benchmark
grunt.registerTask("benchmark", [
"shell:testcjs",
"shell:benchmark"
]);
};
36 changes: 18 additions & 18 deletions packages/less/bin/lessc
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

/* eslint indent: [2, 2, {"SwitchCase": 1}] */

'use strict';
import path from 'path';
import os from 'os';
import { createRequire } from 'module';
import fs from '../lib/less-node/fs.js';
import * as utils from '../lib/less/utils.js';
import * as Constants from '../lib/less/constants.js';
import less from '../lib/less-node/index.js';

var path = require('path');
var fs = require('../lib/less-node/fs').default;
var os = require('os');
var utils = require('../lib/less/utils');
var Constants = require('../lib/less/constants');

var less = require('../lib/less-node').default;
const require = createRequire(import.meta.url);

var errno;
var mkdirp;

try {
errno = require('errno');
Expand Down Expand Up @@ -108,22 +107,22 @@ function render() {
}

// Handle explicit sourceMapFullFilename (from --source-map=filename)
// Normalization of other options (sourceMapBasepath, sourceMapRootpath, etc.)
// Normalization of other options (sourceMapBasepath, sourceMapRootpath, etc.)
// is handled automatically in parse-tree.js
if (sourceMapOptions.sourceMapFullFilename && !sourceMapFileInline) {
var mapFilename = path.resolve(process.cwd(), sourceMapOptions.sourceMapFullFilename);
var mapDir = path.dirname(mapFilename);

if (output) {
var outputDir = path.dirname(output);
// Set sourceMapOutputFilename relative to map directory
sourceMapOptions.sourceMapOutputFilename = path.join(
path.relative(mapDir, outputDir),
path.relative(mapDir, outputDir),
path.basename(output)
);
// Set sourceMapFilename relative to output directory (for sourceMappingURL comment)
sourceMapOptions.sourceMapFilename = path.join(
path.relative(outputDir, mapDir),
path.relative(outputDir, mapDir),
path.basename(sourceMapOptions.sourceMapFullFilename)
);
} else {
Expand Down Expand Up @@ -151,6 +150,7 @@ function render() {
return;
}

var mkdirp;
var ensureDirectory = function ensureDirectory(filepath) {
var dir = path.dirname(filepath);
var cmd;
Expand Down Expand Up @@ -189,7 +189,7 @@ function render() {

// To fix https://github.com/less/less.js/issues/3646
output = output.toString();

fs.writeFile(filename, output, 'utf8', function (err) {
if (err) {
var description = 'Error: ';
Expand Down Expand Up @@ -404,7 +404,7 @@ function processPluginQueue() {
case 'silent':
options.silent = silent = true;
break;

case 'quiet':
options.quiet = quiet = true;
break;
Expand Down Expand Up @@ -539,7 +539,7 @@ function processPluginQueue() {
}

break;

case 'ie-compat':
pendingDeprecations.push('Warning: The --ie-compat option is deprecated, as it has no effect on compilation.');
break;
Expand Down Expand Up @@ -652,7 +652,7 @@ function processPluginQueue() {
case 'disable-plugin-rule':
options.disablePluginRule = true;
break;

default:
queuePlugins.push({
name: arg,
Expand All @@ -675,4 +675,4 @@ function processPluginQueue() {
} else {
render();
}
})();
})();
7 changes: 5 additions & 2 deletions packages/less/build/banner.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { createRequire } from 'module';

const require = createRequire(import.meta.url);
const pkg = require('./../package.json');

module.exports =
export default
`/**
* Less - ${ pkg.description } v${ pkg.version }
* http://lesscss.org
*
*
* Copyright (c) 2009-${new Date().getFullYear()}, ${ pkg.author.name } <${ pkg.author.email }>
* Licensed under the ${ pkg.license } License.
*
Expand Down
38 changes: 14 additions & 24 deletions packages/less/build/rollup.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
const rollup = require('rollup');
const typescript = require('rollup-plugin-typescript2');
const commonjs = require('@rollup/plugin-commonjs');
const json = require('@rollup/plugin-json');
const resolve = require('@rollup/plugin-node-resolve').nodeResolve;
const terser = require('rollup-plugin-terser').terser;
const banner = require('./banner');
const path = require('path');
import { rollup } from 'rollup';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve as resolve } from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import banner from './banner.js';
import path from 'path';
import { fileURLToPath } from 'url';
import minimist from 'minimist';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
const rootPath = path.join(__dirname, '..');

const args = require('minimist')(process.argv.slice(2));
const args = minimist(process.argv.slice(2));

let outDir = args.dist ? './dist' : './tmp';

async function buildBrowser() {
let bundle = await rollup.rollup({
input: './src/less-browser/bootstrap.js',
let bundle = await rollup({
input: './lib/less-browser/bootstrap.js',
output: [
{
file: 'less.js',
Expand All @@ -30,18 +32,6 @@ async function buildBrowser() {
resolve(),
commonjs(),
json(),
typescript({
verbosity: 2,
tsconfigDefaults: {
compilerOptions: {
allowJs: true,
sourceMap: true,
target: 'ES5'
}
},
include: [ '*.ts', '**/*.ts', '*.js', '**/*.js' ],
exclude: ['node_modules'] // only transpile our source code
}),
terser({
compress: true,
include: [/^.+\.min\.js$/],
Expand All @@ -65,7 +55,7 @@ async function buildBrowser() {
format: 'umd',
name: 'less',
banner
});
});
}

if (!args.out || args.out.indexOf('less.min.js') > -1) {
Expand Down
Loading