mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Feat/lightningcss (#6427)
* Added lightning css for minification of css * Added esbuild for minification * Upgraded to Node 22 * Fixed. * Temporary change branch * Rebased changes.
This commit is contained in:
parent
b376688f75
commit
426174d491
8 changed files with 5329 additions and 3946 deletions
6
.github/workflows/backend-tests.yml
vendored
6
.github/workflows/backend-tests.yml
vendored
|
@ -24,7 +24,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node: [18, 20, 21]
|
node: [18, 20, 22]
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout repository
|
name: Checkout repository
|
||||||
|
@ -81,7 +81,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node: [18, 20, 21]
|
node: [18, 20, 22]
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout repository
|
name: Checkout repository
|
||||||
|
@ -211,7 +211,7 @@ jobs:
|
||||||
-
|
-
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 21
|
node-version: 22
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
|
|
2
.github/workflows/frontend-admin-tests.yml
vendored
2
.github/workflows/frontend-admin-tests.yml
vendored
|
@ -18,7 +18,7 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node: [20, 21]
|
node: [20, 22]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
|
|
6
.github/workflows/frontend-tests.yml
vendored
6
.github/workflows/frontend-tests.yml
vendored
|
@ -26,7 +26,7 @@ jobs:
|
||||||
-
|
-
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 21
|
node-version: 22
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
|
@ -92,7 +92,7 @@ jobs:
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 21
|
node-version: 22
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
|
@ -159,7 +159,7 @@ jobs:
|
||||||
-
|
-
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 21
|
node-version: 22
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
|
|
|
@ -24,13 +24,13 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
node: [18, 20, 21]
|
node: [18, 20, 22]
|
||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Check out latest release
|
name: Check out latest release
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: master
|
ref: develop #FIXME change to master when doing release
|
||||||
-
|
-
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
|
|
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
|
@ -34,7 +34,7 @@ jobs:
|
||||||
-
|
-
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: 21
|
node-version: 22
|
||||||
- uses: pnpm/action-setup@v4
|
- uses: pnpm/action-setup@v4
|
||||||
name: Install pnpm
|
name: Install pnpm
|
||||||
with:
|
with:
|
||||||
|
|
9207
pnpm-lock.yaml
9207
pnpm-lock.yaml
File diff suppressed because it is too large
Load diff
|
@ -3,31 +3,45 @@
|
||||||
* Worker thread to minify JS & CSS files out of the main NodeJS thread
|
* Worker thread to minify JS & CSS files out of the main NodeJS thread
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const CleanCSS = require('clean-css');
|
|
||||||
const Terser = require('terser');
|
|
||||||
const fsp = require('fs').promises;
|
const fsp = require('fs').promises;
|
||||||
const path = require('path');
|
import path from 'node:path'
|
||||||
const Threads = require('threads');
|
import {expose} from 'threads'
|
||||||
|
import lightminify from 'lightningcss'
|
||||||
|
import {transform} from 'esbuild';
|
||||||
|
|
||||||
const compressJS = (content) => Terser.minify(content);
|
/*
|
||||||
|
* Minify JS content
|
||||||
|
* @param {string} content - JS content to minify
|
||||||
|
*/
|
||||||
|
const compressJS = async (content) => {
|
||||||
|
return await transform(content, {minify: true});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Minify CSS content
|
||||||
|
* @param {string} filename - name of the file
|
||||||
|
* @param {string} ROOT_DIR - the root dir of Etherpad
|
||||||
|
*/
|
||||||
const compressCSS = async (filename, ROOT_DIR) => {
|
const compressCSS = async (filename, ROOT_DIR) => {
|
||||||
const absPath = path.resolve(ROOT_DIR, filename);
|
const absPath = path.resolve(ROOT_DIR, filename);
|
||||||
try {
|
try {
|
||||||
const basePath = path.dirname(absPath);
|
const basePath = path.dirname(absPath);
|
||||||
const output = await new CleanCSS({
|
const file = await fsp.readFile(absPath, 'utf8');
|
||||||
rebase: true,
|
let { code } = lightminify.transform({
|
||||||
rebaseTo: basePath,
|
errorRecovery: true,
|
||||||
}).minify([absPath]);
|
filename: basePath,
|
||||||
return output.styles;
|
minify: true,
|
||||||
|
code: Buffer.from(file, 'utf8')
|
||||||
|
});
|
||||||
|
return code.toString();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// on error, just yield the un-minified original, but write a log message
|
// on error, just yield the un-minified original, but write a log message
|
||||||
console.error(`Unexpected error minifying ${filename} (${absPath}): ${error}`);
|
console.error(`Unexpected error minifying ${filename} (${absPath}): ${JSON.stringify(error)}`);
|
||||||
return await fsp.readFile(absPath, 'utf8');
|
return await fsp.readFile(absPath, 'utf8');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Threads.expose({
|
expose({
|
||||||
compressJS,
|
compressJS: compressJS,
|
||||||
compressCSS,
|
compressCSS,
|
||||||
});
|
});
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async": "^3.2.5",
|
"async": "^3.2.5",
|
||||||
"axios": "^1.7.2",
|
"axios": "^1.7.2",
|
||||||
"clean-css": "^5.3.3",
|
|
||||||
"cookie-parser": "^1.4.6",
|
"cookie-parser": "^1.4.6",
|
||||||
"cross-spawn": "^7.0.3",
|
"cross-spawn": "^7.0.3",
|
||||||
"ejs": "^3.1.10",
|
"ejs": "^3.1.10",
|
||||||
|
@ -51,9 +50,11 @@
|
||||||
"jsonminify": "0.4.2",
|
"jsonminify": "0.4.2",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"languages4translatewiki": "0.1.3",
|
"languages4translatewiki": "0.1.3",
|
||||||
|
"lightningcss": "^1.25.1",
|
||||||
"live-plugin-manager": "^1.0.0",
|
"live-plugin-manager": "^1.0.0",
|
||||||
"lodash.clonedeep": "4.5.0",
|
"lodash.clonedeep": "4.5.0",
|
||||||
"log4js": "^6.9.1",
|
"log4js": "^6.9.1",
|
||||||
|
"lru-cache": "^10.2.0",
|
||||||
"measured-core": "^2.0.0",
|
"measured-core": "^2.0.0",
|
||||||
"mime-types": "^2.1.35",
|
"mime-types": "^2.1.35",
|
||||||
"oidc-provider": "^8.4.5",
|
"oidc-provider": "^8.4.5",
|
||||||
|
@ -68,15 +69,13 @@
|
||||||
"socket.io": "^4.7.5",
|
"socket.io": "^4.7.5",
|
||||||
"socket.io-client": "^4.7.5",
|
"socket.io-client": "^4.7.5",
|
||||||
"superagent": "^9.0.2",
|
"superagent": "^9.0.2",
|
||||||
"terser": "^5.30.3",
|
|
||||||
"threads": "^1.7.0",
|
"threads": "^1.7.0",
|
||||||
"tinycon": "0.6.8",
|
"tinycon": "0.6.8",
|
||||||
"tsx": "^4.11.2",
|
"tsx": "^4.11.2",
|
||||||
"ueberdb2": "^4.2.63",
|
"ueberdb2": "^4.2.63",
|
||||||
"underscore": "1.13.6",
|
"underscore": "1.13.6",
|
||||||
"unorm": "1.6.0",
|
"unorm": "1.6.0",
|
||||||
"wtfnode": "^0.9.2",
|
"wtfnode": "^0.9.2"
|
||||||
"lru-cache": "^10.2.0"
|
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"etherpad-healthcheck": "../bin/etherpad-healthcheck",
|
"etherpad-healthcheck": "../bin/etherpad-healthcheck",
|
||||||
|
@ -97,6 +96,7 @@
|
||||||
"@types/sinon": "^17.0.3",
|
"@types/sinon": "^17.0.3",
|
||||||
"@types/supertest": "^6.0.2",
|
"@types/supertest": "^6.0.2",
|
||||||
"@types/underscore": "^1.11.15",
|
"@types/underscore": "^1.11.15",
|
||||||
|
"esbuild": "^0.21.4",
|
||||||
"eslint": "^9.2.0",
|
"eslint": "^9.2.0",
|
||||||
"eslint-config-etherpad": "^4.0.4",
|
"eslint-config-etherpad": "^4.0.4",
|
||||||
"etherpad-cli-client": "^3.0.2",
|
"etherpad-cli-client": "^3.0.2",
|
||||||
|
|
Loading…
Reference in a new issue