From 6196ec5f74faa0b783a1b3d75eadcd6cad5f651e Mon Sep 17 00:00:00 2001 From: memdmp Date: Mon, 24 Feb 2025 04:42:53 +0100 Subject: fix: split bundles, reproducible builds (hopefully) --- contrib/compress-worker.mjs | 13 +++++++++++++ contrib/ensure-reproducible-builds.sh | 29 +++++++++++++++++++++++++++++ contrib/strip-srcmap.sh | 6 ++++++ 3 files changed, 48 insertions(+) create mode 100755 contrib/compress-worker.mjs create mode 100755 contrib/ensure-reproducible-builds.sh create mode 100755 contrib/strip-srcmap.sh (limited to 'contrib') diff --git a/contrib/compress-worker.mjs b/contrib/compress-worker.mjs new file mode 100755 index 0000000..5c26694 --- /dev/null +++ b/contrib/compress-worker.mjs @@ -0,0 +1,13 @@ +#!/usr/bin/env node +import { readFileSync, writeFileSync } from 'node:fs'; +import { brotliCompressSync } from 'zlib'; + +writeFileSync( + 'static/generated/ts-worker.js.br', + brotliCompressSync( + readFileSync( + 'node_modules/monaco-editor/esm/vs/language/typescript/ts.worker.js' + ), + {} + ) +); diff --git a/contrib/ensure-reproducible-builds.sh b/contrib/ensure-reproducible-builds.sh new file mode 100755 index 0000000..f9b880a --- /dev/null +++ b/contrib/ensure-reproducible-builds.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env zsh +set -e +echo "First Build" +make mozaddons +# Zips are unstable with hashes +cd artifacts +ZIPNAME="$(jq -r '.name + "-" + .version + "-unsigned.zip"' ../manifest.json)" +unzip "$ZIPNAME" +rm "$ZIPNAME" +HASH1="$( (find . -type f -print0 | sort -z | xargs -0 sha512sum; + find . \( -type f -o -type d \) -print0 | sort -z | \ + xargs -0 stat -c '%n %a') \ + | sha512sum)" +cd .. +echo "Got Hash $HASH1" +sleep 1; +echo "Second Build" +make mozaddons +# Zips are unstable with hashes +cd artifacts +unzip "$ZIPNAME" +rm "$ZIPNAME" +HASH2="$( (find . -type f -print0 | sort -z | xargs -0 sha512sum; + find . \( -type f -o -type d \) -print0 | sort -z | \ + xargs -0 stat -c '%n %a') \ + | sha512sum)" +cd .. +echo "Got Hash $HASH2" +if [[ "$HASH1" != "$HASH2" ]]; then echo -e "\x1b[0;31mNot reproducible!\x1b[0m"; fi; \ No newline at end of file diff --git a/contrib/strip-srcmap.sh b/contrib/strip-srcmap.sh new file mode 100755 index 0000000..a87ab03 --- /dev/null +++ b/contrib/strip-srcmap.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env zsh +set -eax +# some source maps are >20MB, we can't keep that going. +for f in $(find build/uwu -name '*.js' -or -name '*.mjs'); do + grep -v sourceMappingURL= "$f" > /tmp/a && mv /tmp/a "$f" +done -- cgit v1.2.3