You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
/* eslint-disable */
|
|
|
|
import { spawnSync } from "child_process";
|
|
import { writeFileSync, readFileSync } from "fs";
|
|
|
|
import esbuild from "esbuild";
|
|
import { extheader } from "./extheader.js";
|
|
|
|
let res = spawnSync("git", ["rev-list", "--count", "HEAD"]);
|
|
let rev = +res.stdout;
|
|
|
|
(async () => {
|
|
let res;
|
|
|
|
res = await esbuild.build({
|
|
entryPoints: ["src/main.js"],
|
|
bundle: true,
|
|
treeShaking: true,
|
|
outfile: "./dist/main.js",
|
|
define: {
|
|
global: "window",
|
|
execution_mode: JSON.stringify(process.argv[2] || "userscript"),
|
|
isBackground: JSON.stringify("false"),
|
|
BUILD_VERSION: JSON.stringify([0, rev]),
|
|
},
|
|
// inject: ["./esbuild.inject.js"],
|
|
plugins: [],
|
|
loader: { ".bin": "text", ".wasm": "binary" },
|
|
metafile: true,
|
|
});
|
|
|
|
console.log(res.metafile.inputs);
|
|
console.log(
|
|
Object.entries(res.metafile.inputs)
|
|
.sort((a, b) => a[1].bytes - b[1].bytes)
|
|
.map((e) => `${e[0]} -> ${e[1].bytes}`)
|
|
.join("\n")
|
|
);
|
|
writeFileSync("./JKCS.user.js", extheader + readFileSync("./dist/main.js"));
|
|
writeFileSync("./JKCS.meta.js", extheader);
|
|
})();
|
|
|