buildWeb: use fflate instead of yazl

This commit is contained in:
Vendicated 2022-10-22 23:35:30 +02:00
parent 35d2b8d1cf
commit a3b0556a9a
No known key found for this signature in database
GPG key ID: EC781ADFB93EFFA3
3 changed files with 22 additions and 25 deletions

View file

@ -44,8 +44,7 @@
"eslint-plugin-simple-import-sort": "^8.0.0", "eslint-plugin-simple-import-sort": "^8.0.0",
"standalone-electron-types": "^1.0.0", "standalone-electron-types": "^1.0.0",
"type-fest": "^3.1.0", "type-fest": "^3.1.0",
"typescript": "^4.8.4", "typescript": "^4.8.4"
"yazl": "^2.5.1"
}, },
"packageManager": "pnpm@7.13.4" "packageManager": "pnpm@7.13.4"
} }

View file

@ -15,7 +15,6 @@ specifiers:
standalone-electron-types: ^1.0.0 standalone-electron-types: ^1.0.0
type-fest: ^3.1.0 type-fest: ^3.1.0
typescript: ^4.8.4 typescript: ^4.8.4
yazl: ^2.5.1
dependencies: dependencies:
console-menu: 0.1.0 console-menu: 0.1.0
@ -34,7 +33,6 @@ devDependencies:
standalone-electron-types: 1.0.0 standalone-electron-types: 1.0.0
type-fest: 3.1.0 type-fest: 3.1.0
typescript: 4.8.4 typescript: 4.8.4
yazl: 2.5.1
packages: packages:
@ -270,10 +268,6 @@ packages:
fill-range: 7.0.1 fill-range: 7.0.1
dev: true dev: true
/buffer-crc32/0.2.13:
resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==}
dev: true
/callsites/3.1.0: /callsites/3.1.0:
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
engines: {node: '>=6'} engines: {node: '>=6'}
@ -1182,12 +1176,6 @@ packages:
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==} resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
dev: true dev: true
/yazl/2.5.1:
resolution: {integrity: sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==}
dependencies:
buffer-crc32: 0.2.13
dev: true
/yocto-queue/0.1.0: /yocto-queue/0.1.0:
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
engines: {node: '>=10'} engines: {node: '>=10'}

View file

@ -18,9 +18,12 @@
*/ */
import { createWriteStream, readFileSync } from "fs";
import yazl from "yazl";
import esbuild from "esbuild"; import esbuild from "esbuild";
import { zip } from "fflate";
import { readFileSync, writeFileSync } from "fs";
import { readFile } from "fs/promises";
import { join } from "path";
// wtf is this assert syntax // wtf is this assert syntax
import PackageJSON from "../../package.json" assert { type: "json" }; import PackageJSON from "../../package.json" assert { type: "json" };
import { commonOpts, fileIncludePlugin, gitHashPlugin, globPlugins } from "./common.mjs"; import { commonOpts, fileIncludePlugin, gitHashPlugin, globPlugins } from "./common.mjs";
@ -66,13 +69,20 @@ await Promise.all(
] ]
); );
const zip = new yazl.ZipFile(); zip({
zip.outputStream.pipe(createWriteStream("dist/extension.zip")).on("close", () => { dist: {
console.info("Extension written to dist/extension.zip"); "Vencord.js": readFileSync("dist/browser.js", "binary")
},
...Object.fromEntries(await Promise.all(["background.js", "content.js", "manifest.json"].map(async f => [
f,
await readFile(join("browser", f), "binary")
]))),
}, {}, (err, data) => {
if (err) {
console.error(err);
process.exitCode = 1;
} else {
writeFileSync("dist/extension.zip", data);
console.info("Extension written to dist/extension.zip");
}
}); });
zip.addFile("dist/browser.js", "dist/Vencord.js");
["background.js", "content.js", "manifest.json"].forEach(f => {
zip.addFile(`browser/${f}`, `${f}`);
});
zip.end();