Rebuild mp3-encoder 1.65.2 Use a clean directory with Bash, GNU make, tar, Node.js 22+, pnpm 9.7.0 and Emscripten 4.0.21. On Windows, use MSYS2 UCRT64 with the make package and native Windows Node.js and pnpm on PATH. Activate the Emscripten SDK (source /path/to/emsdk/emsdk_env.sh) and check emcc --version before building. Emscripten compiler revision: d6f42310010ddec0753a69bab01a4b33aae255b7 Mediabunny release: v1.65.2 (173f6b70765fa3a6ffc1c82737514416fa559ef5). Download these site files into that directory and verify their SHA-256 hashes. /analysis/v1/mediabunny-1.65.2-source-complete.tar.gz 0aac703055636530596fb3ed9cd6de03e0f212046c326f8cd05fa19db6ffeaa2 /analysis/v1/mediabunny-mp3-encoder-1.65.2-build-inputs.tar.gz 639193d6b942cce865e041d43a5aeb7e2c54ddaaad9b541a011d19089808e9e2 /analysis/v1/lame-3.100.tar.gz ddfe36cab873794038ae2c1210557ad34857a4b6bdc515785d1da9e175b1da1e The source archive for lame is from https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz LAME configure is given --build=aarch64-unknown-linux-gnu below. On an x86-64 host, configure otherwise enables TAKEHIRO_IEEE754_HACK and USE_FAST_LOG. The pinned triplet keeps the generic code path that the published WASM uses. With it, the unmodified rebuild matches the published WASM and module byte for byte. # Windows SDK and MSYS2 Bash use different command entry points. ar=emar ranlib=emranlib if [[ -n "${MSYSTEM:-}" ]]; then emconfigure() { "$EMSDK_PYTHON" "$EMSDK/upstream/emscripten/emconfigure.py" "$(cygpath -m /usr/bin/bash.exe)" "$@"; } emmake() { shift; "$EMSDK_PYTHON" "$EMSDK/upstream/emscripten/emmake.py" "$(cygpath -m /usr/bin/make.exe)" "$@"; } export PATH="$(cygpath -u "$EMSDK")/upstream/bin:$PATH" ar=llvm-ar ranlib=llvm-ranlib fi tar -xzf mediabunny-1.65.2-source-complete.tar.gz tar -xzf mediabunny-mp3-encoder-1.65.2-build-inputs.tar.gz tar -xzf lame-3.100.tar.gz (cd lame-3.100 && emconfigure ./configure \ --build=aarch64-unknown-linux-gnu \ AR="$ar" RANLIB="$ranlib" \ CFLAGS="-DNDEBUG -DNO_STDIO -O3 -msimd128" \ --disable-dependency-tracking \ --disable-shared \ --disable-gtktest \ --disable-analyzer-hooks \ --disable-decoder \ --disable-frontend emmake make clean emmake make) cd mediabunny-1.65.2/packages/mp3-encoder mkdir -p build cp ../../../lame-3.100/libmp3lame/.libs/libmp3lame.a build/ emcc src/lame-bridge.c build/libmp3lame.a \ -s MODULARIZE=1 \ -s EXPORT_ES6=1 \ -s SINGLE_FILE=1 \ -s ALLOW_MEMORY_GROWTH=1 \ -s ENVIRONMENT=web,worker \ -s EXPORTED_RUNTIME_METHODS=cwrap,HEAPU8 \ -s EXPORTED_FUNCTIONS=_malloc,_free \ -msimd128 \ -O3 \ -o build/lame.js cd ../.. # Install the exact bundler versions from the upstream lockfile in an isolated directory. tools="$(mktemp -d)" printf '{}\n' > "$tools/package.json" pnpm --dir "$tools" add --save-exact esbuild@0.25.1 esbuild-plugin-external-global@1.0.1 tsx@4.19.4 find-cache-dir@5.0.0 node --input-type=module - "$tools" <<'JS' import { symlinkSync } from 'node:fs'; import { resolve } from 'node:path'; const target = resolve(process.argv[2], 'node_modules'); symlinkSync(target, 'node_modules', process.platform === 'win32' ? 'junction' : 'dir'); JS # Select only the core and this extension in the original upstream bundler. node --input-type=module - mp3EncoderVariants <<'JS' import { readFileSync, writeFileSync } from 'node:fs'; const keep = new Set(['mediabunnyVariants', process.argv[2]]); const source = readFileSync('scripts/bundle.ts', 'utf8'); const target = source .replace(/^const (\w+Variants) = await createVariants\([\s\S]*?^\);$/gm, (block, name) => keep.has(name) ? block : '') .replace(/^\t\.\.\.(\w+Variants),$/gm, (line, name) => keep.has(name) ? line : ''); writeFileSync('scripts/bundle-audio.ts', target); JS node node_modules/tsx/dist/cli.mjs scripts/bundle-audio.ts The original published bytes are available in https://registry.npmjs.org/@mediabunny/mp3-encoder/-/mp3-encoder-1.65.2.tgz Package SHA-256: 038175adb96faece6d12be6c8d282dd47f1d3dfbdb65993887ec2384b73ef57c Unmodified minified module SHA-256: 3fd0628ceaca730cd8354229d4b289e20151860d2b99c760f2dbe41b8e61774c Rewrite the bare imports to load the same core module as the export Worker. node --input-type=module - <<'JS' import { readFileSync, writeFileSync } from 'node:fs'; const source = readFileSync('packages/mp3-encoder/dist/bundles/mediabunny-mp3-encoder.min.mjs', 'utf8'); const before = 'from"mediabunny"'; if (source.split(before).length - 1 !== 1) throw new Error('Unexpected import count'); writeFileSync('mediabunny-mp3-encoder-1.65.2.min.mjs', source.replaceAll(before, 'from"./mediabunny-1.65.2.min.mjs"')); JS Site module SHA-256 before local modifications: e888ee6d646b58faab7da5c4e341ba13ebfb3aa91e8274462fc8e07dffdba6b0 To use a modified library, edit its extracted source before building. Serve the resulting module at /analysis/v1/audio-export-94ebadd9b56f/mediabunny-mp3-encoder-1.65.2.min.mjs in a local copy of the site, with the existing core module beside it. Use a fresh browser context to bypass any cached copy. Run a new audio export.