build: Add metadata header to all bundles

main
Vendicated 2 years ago
parent 0af4579204
commit a13c0df1cd
No known key found for this signature in database
GPG Key ID: EC781ADFB93EFFA3

@ -31,7 +31,7 @@ jobs:
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
- name: Build web - name: Build web
run: pnpm buildWeb run: pnpm buildWeb --standalone
- name: Build - name: Build
run: pnpm build --standalone run: pnpm build --standalone

@ -19,7 +19,7 @@
import esbuild from "esbuild"; import esbuild from "esbuild";
import { commonOpts, gitHash, globPlugins, isStandalone, watch } from "./common.mjs"; import { commonOpts, globPlugins, isStandalone, watch } from "./common.mjs";
const defines = { const defines = {
IS_STANDALONE: isStandalone, IS_STANDALONE: isStandalone,
@ -30,12 +30,6 @@ if (defines.IS_STANDALONE === "false")
// for the specific platform we're on // for the specific platform we're on
defines["process.platform"] = JSON.stringify(process.platform); defines["process.platform"] = JSON.stringify(process.platform);
const header = `
// Vencord ${gitHash}
// Standalone: ${defines.IS_STANDALONE}
// Platform: ${defines["process.platform"] || "Universal"}
`.trim();
/** /**
* @type {esbuild.BuildOptions} * @type {esbuild.BuildOptions}
*/ */
@ -48,9 +42,6 @@ const nodeCommonOpts = {
bundle: true, bundle: true,
external: ["electron", ...commonOpts.external], external: ["electron", ...commonOpts.external],
define: defines, define: defines,
banner: {
js: header
}
}; };
await Promise.all([ await Promise.all([

@ -24,6 +24,14 @@ import { promisify } from "util";
export const watch = process.argv.includes("--watch"); export const watch = process.argv.includes("--watch");
export const isStandalone = JSON.stringify(process.argv.includes("--standalone")); export const isStandalone = JSON.stringify(process.argv.includes("--standalone"));
export const gitHash = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim();
export const banner = {
js: `
// Vencord ${gitHash}
// Standalone: ${isStandalone}
// Platform: ${isStandalone === "false" ? process.platform : "Universal"}
`.trim()
};
// https://github.com/evanw/esbuild/issues/619#issuecomment-751995294 // https://github.com/evanw/esbuild/issues/619#issuecomment-751995294
/** /**
@ -78,7 +86,6 @@ export const globPlugins = {
} }
}; };
export const gitHash = execSync("git rev-parse --short HEAD", { encoding: "utf-8" }).trim();
/** /**
* @type {esbuild.Plugin} * @type {esbuild.Plugin}
*/ */
@ -150,6 +157,7 @@ export const commonOpts = {
minify: !watch, minify: !watch,
sourcemap: watch ? "inline" : "", sourcemap: watch ? "inline" : "",
legalComments: "linked", legalComments: "linked",
banner,
plugins: [fileIncludePlugin, gitHashPlugin, gitRemotePlugin], plugins: [fileIncludePlugin, gitHashPlugin, gitRemotePlugin],
external: ["~plugins", "~git-hash", "~git-remote"], external: ["~plugins", "~git-hash", "~git-remote"],
inject: ["./scripts/build/inject/react.mjs"], inject: ["./scripts/build/inject/react.mjs"],

Loading…
Cancel
Save