Files
revive/js/build.js
T
xermicus 4a9b651235 Support solc v0.8.29 (#261)
No observable changes w.r.t. YUL compilation.
- Mark solc v0.8.29 as the latest supported version
- Add integration test for solc v0.8.29 specific feature
- Use the latest version on CI
- Drive-by fix linter complaints and a two types in the CI yaml files

---------

Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
Signed-off-by: xermicus <cyrill@parity.io>
2025-03-18 13:01:15 +01:00

54 lines
1.5 KiB
JavaScript

const fs = require("fs");
const path = require("path");
const { minify } = require("terser");
const SOLJSON_URI =
"https://binaries.soliditylang.org/wasm/soljson-v0.8.29+commit.ab55807c.js";
const RESOLC_WASM_URI = "http://127.0.0.1:8080/resolc.wasm";
const RESOLC_WASM_TARGET_DIR = path.join(
__dirname,
"../target/wasm32-unknown-emscripten/release",
);
const RESOLC_JS = path.join(RESOLC_WASM_TARGET_DIR, "resolc.js");
const RESOLC_WEB_JS = path.join(RESOLC_WASM_TARGET_DIR, "resolc_web.js");
const resolcJs = fs.readFileSync(RESOLC_JS, "utf-8");
const packedJsContent = `
if (typeof importScripts === "function") {
importScripts("${SOLJSON_URI}");
var moduleArgs = {
wasmBinary: (function () {
var xhr = new XMLHttpRequest();
xhr.open("GET", "${RESOLC_WASM_URI}", false);
xhr.responseType = "arraybuffer";
xhr.send(null);
return new Uint8Array(xhr.response);
})(),
soljson: Module
};
} else {
console.log("Not a WebWorker, skipping Soljson and WASM loading.");
}
${resolcJs}
createRevive = createRevive.bind(null, moduleArgs);
`;
minify(packedJsContent)
.then((minifiedJs) => {
if (minifiedJs.error) {
console.error("Error during minification:", minifiedJs.error);
process.exit(1);
}
fs.writeFileSync(RESOLC_WEB_JS, minifiedJs.code, "utf-8");
console.log(`Combined script written to ${RESOLC_WEB_JS}`);
})
.catch((err) => {
console.error("Minification failed:", err);
process.exit(1);
});