Skip to content

Commit 7ca5747

Browse files
committed
Drop less, move to lightningcss
1 parent 354197e commit 7ca5747

File tree

14 files changed

+71
-87
lines changed

14 files changed

+71
-87
lines changed

cppjswasm/.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Makefile linguist-documentation
99
*.html text=auto eol=lf
1010
*.js text=auto eol=lf
1111
*.json text=auto eol=lf
12-
*.less text=auto eol=lf
1312
*.md text=auto eol=lf
1413
*.py text=auto eol=lf
1514
*.toml text=auto eol=lf

cppjswasm/js/build.mjs.jinja

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { NodeModulesExternal } from "@finos/perspective-esbuild-plugin/external.js";
22
import { build } from "@finos/perspective-esbuild-plugin/build.js";
3-
import { BuildCss } from "@prospective.co/procss/target/cjs/procss.js";
3+
import { transform } from "lightningcss";
44
import { getarg } from "./tools/getarg.mjs";
55
import fs from "fs";
66
import cpy from "cpy";
7-
import path_mod from "path";
87

98
const DEBUG = getarg("--debug");
109

@@ -40,31 +39,29 @@ const BUILD = [
4039

4140
async function compile_css() {
4241
const process_path = (path) => {
43-
const outpath = path.replace("src/less", "dist/css");
42+
const outpath = path.replace("src/css", "dist/css");
4443
fs.mkdirSync(outpath, { recursive: true });
4544

46-
fs.readdirSync(path).forEach((file_or_folder) => {
47-
if (file_or_folder.endsWith(".less")) {
48-
const outfile = file_or_folder.replace(".less", ".css");
49-
const builder = new BuildCss("");
50-
builder.add(
51-
`${path}/${file_or_folder}`,
52-
fs
53-
.readFileSync(path_mod.join(`${path}/${file_or_folder}`))
54-
.toString(),
55-
);
56-
fs.writeFileSync(
57-
`${path.replace("src/less", "dist/css")}/${outfile}`,
58-
builder.compile().get(outfile),
59-
);
60-
} else {
61-
process_path(`${path}/${file_or_folder}`);
45+
fs.readdirSync(path, { withFileTypes: true }).forEach((entry) => {
46+
const input = `${path}/${entry.name}`;
47+
const output = `${outpath}/${entry.name}`;
48+
49+
if (entry.isDirectory()) {
50+
process_path(input);
51+
} else if (entry.isFile() && entry.name.endsWith(".css")) {
52+
const source = fs.readFileSync(input);
53+
const { code } = transform({
54+
filename: entry.name,
55+
code: source,
56+
minify: !DEBUG,
57+
sourceMap: false,
58+
});
59+
fs.writeFileSync(output, code);
6260
}
6361
});
6462
};
65-
// recursively process all less files in src/less
66-
process_path("src/less");
67-
cpy("src/css/*", "dist/css/");
63+
64+
process_path("src/css");
6865
}
6966

7067
async function copy_html() {

cppjswasm/js/package.json.jinja

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
"build": "npm-run-all build:cpp build:prod",
3333
"clean": "rm -rf dist lib playwright-report ../{{module}}/extension",
3434
"dev": "npm-run-all -p start watch",
35-
"lint:js": "prettier --check \"src/**/*.{js,ts,jsx,tsx,less,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"",
35+
"lint:js": "prettier --check \"src/**/*.{js,ts,jsx,tsx,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"",
3636
"lint:cpp": "clang-format --dry-run -Werror -style=file:../.clang-format src/cpp/*.cpp",
3737
"lint": "npm-run-all lint:*",
38-
"fix:js": "prettier --write \"src/**/*.{js,ts,jsx,tsx,less,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"",
38+
"fix:js": "prettier --write \"src/**/*.{js,ts,jsx,tsx,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"",
3939
"fix:cpp": "clang-format -i -style=file:../.clang-format src/cpp/*.cpp",
4040
"fix": "npm-run-all fix:*",
4141
"preinstall": "npx only-allow pnpm",
@@ -44,16 +44,15 @@
4444
"start:tests": "http-server -p 3000 ",
4545
"test:js": "playwright test",
4646
"test": "npm-run-all test:*",
47-
"watch": "nodemon --watch src -e ts,less,html,cpp,hpp --exec \"pnpm build:debug\""
47+
"watch": "nodemon --watch src -e ts,css,html,cpp,hpp --exec \"pnpm build:debug\""
4848
},
4949
"dependencies": {},
5050
"devDependencies": {
5151
"@finos/perspective-esbuild-plugin": "^3.2.1",
5252
"@playwright/test": "^1.56.1",
53-
"@prospective.co/procss": "^0.1.17",
5453
"cpy": "^12.1.0",
5554
"esbuild": "^0.27.2",
56-
"esbuild-plugin-less": "^1.3.35",
55+
"lightningcss": "^1.29.3",
5756
"http-server": "^14.1.1",
5857
"nodemon": "^3.1.10",
5958
"npm-run-all": "^4.1.5",

js/.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Makefile linguist-documentation
77
*.html text=auto eol=lf
88
*.js text=auto eol=lf
99
*.json text=auto eol=lf
10-
*.less text=auto eol=lf
1110
*.md text=auto eol=lf
1211
*.py text=auto eol=lf
1312
*.toml text=auto eol=lf

js/js/build.mjs.jinja

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { NodeModulesExternal } from "@finos/perspective-esbuild-plugin/external.js";
22
import { build } from "@finos/perspective-esbuild-plugin/build.js";
3-
import { BuildCss } from "@prospective.co/procss/target/cjs/procss.js";
3+
import { transform } from "lightningcss";
44
import { getarg } from "./tools/getarg.mjs";
55
import fs from "fs";
66
import cpy from "cpy";
7-
import path_mod from "path";
87

98
const DEBUG = getarg("--debug");
109

@@ -40,31 +39,29 @@ const BUILD = [
4039

4140
async function compile_css() {
4241
const process_path = (path) => {
43-
const outpath = path.replace("src/less", "dist/css");
42+
const outpath = path.replace("src/css", "dist/css");
4443
fs.mkdirSync(outpath, { recursive: true });
4544

46-
fs.readdirSync(path).forEach((file_or_folder) => {
47-
if (file_or_folder.endsWith(".less")) {
48-
const outfile = file_or_folder.replace(".less", ".css");
49-
const builder = new BuildCss("");
50-
builder.add(
51-
`${path}/${file_or_folder}`,
52-
fs
53-
.readFileSync(path_mod.join(`${path}/${file_or_folder}`))
54-
.toString(),
55-
);
56-
fs.writeFileSync(
57-
`${path.replace("src/less", "dist/css")}/${outfile}`,
58-
builder.compile().get(outfile),
59-
);
60-
} else {
61-
process_path(`${path}/${file_or_folder}`);
45+
fs.readdirSync(path, { withFileTypes: true }).forEach((entry) => {
46+
const input = `${path}/${entry.name}`;
47+
const output = `${outpath}/${entry.name}`;
48+
49+
if (entry.isDirectory()) {
50+
process_path(input);
51+
} else if (entry.isFile() && entry.name.endsWith(".css")) {
52+
const source = fs.readFileSync(input);
53+
const { code } = transform({
54+
filename: entry.name,
55+
code: source,
56+
minify: !DEBUG,
57+
sourceMap: false,
58+
});
59+
fs.writeFileSync(output, code);
6260
}
6361
});
6462
};
65-
// recursively process all less files in src/less
66-
process_path("src/less");
67-
cpy("src/css/*", "dist/css/");
63+
64+
process_path("src/css");
6865
}
6966

7067
async function copy_html() {

js/js/package.json.jinja

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,22 @@
3030
"build": "node build.mjs",
3131
"clean": "rm -rf dist playwright-report ../{{module}}/extension",
3232
"dev": "npm-run-all -p start watch",
33-
"lint": "prettier --check \"src/**/*.{js,ts,jsx,tsx,less,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"",
34-
"fix": "prettier --write \"src/**/*.{js,ts,jsx,tsx,less,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"",
33+
"lint": "prettier --check \"src/**/*.{js,ts,jsx,tsx,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"",
34+
"fix": "prettier --write \"src/**/*.{js,ts,jsx,tsx,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"",
3535
"preinstall": "npx only-allow pnpm",
3636
"prepack": "npm run build",
3737
"start": "http-server -p 3000 -o examples/",
3838
"start:tests": "http-server -p 3000 ",
3939
"test": "TZ=UTC playwright test",
40-
"watch": "nodemon --watch src -e ts,less,html --exec \"pnpm build:debug\""
40+
"watch": "nodemon --watch src -e ts,css,html --exec \"pnpm build:debug\""
4141
},
4242
"dependencies": {},
4343
"devDependencies": {
4444
"@finos/perspective-esbuild-plugin": "^3.2.1",
4545
"@playwright/test": "^1.56.1",
46-
"@prospective.co/procss": "^0.1.17",
4746
"cpy": "^12.1.0",
4847
"esbuild": "^0.27.2",
49-
"esbuild-plugin-less": "^1.3.35",
48+
"lightningcss": "^1.29.3",
5049
"http-server": "^14.1.1",
5150
"nodemon": "^3.1.10",
5251
"npm-run-all": "^4.1.5",

jupyter/.gitattributes

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Makefile linguist-documentation
77
*.html text=auto eol=lf
88
*.js text=auto eol=lf
99
*.json text=auto eol=lf
10-
*.less text=auto eol=lf
1110
*.md text=auto eol=lf
1211
*.py text=auto eol=lf
1312
*.toml text=auto eol=lf

jupyter/js/jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ const esModules = [
1818
module.exports = {
1919
moduleDirectories: ["node_modules", "src", "tests"],
2020
moduleNameMapper: {
21-
"\\.(css|less|sass|scss)$": "<rootDir>/tests/styleMock.js",
21+
"\\.(css|sass|scss)$": "<rootDir>/tests/styleMock.js",
2222
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tests/fileMock.js",
2323
},
2424
reporters: [ "default", "jest-junit" ],
2525
setupFiles: ["<rootDir>/tests/setup.js"],
2626
testEnvironment: "jsdom",
2727
transform: {
2828
"^.+\\.jsx?$": "babel-jest",
29-
".+\\.(css|styl|less|sass|scss)$": "jest-transform-css",
29+
".+\\.(css|styl|sass|scss)$": "jest-transform-css",
3030
},
3131
transformIgnorePatterns: [`/node_modules/.pnpm/(?!(${esModules}))`],
3232
};

0 commit comments

Comments
 (0)