mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Again, try pure javascript
This commit is contained in:
parent
20420f865e
commit
95d436100d
1 changed files with 10 additions and 12 deletions
22
build.js
22
build.js
|
|
@ -26,15 +26,6 @@ async function clearOutputFolder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bundleSafeChain() {
|
async function bundleSafeChain() {
|
||||||
// Read the forge.js file and modify it to use pure JavaScript
|
|
||||||
const forgeContent = await readFile("./node_modules/node-forge/lib/forge.js", "utf-8");
|
|
||||||
const modifiedForge = forgeContent.replace(
|
|
||||||
"usePureJavaScript: false",
|
|
||||||
"usePureJavaScript: true"
|
|
||||||
);
|
|
||||||
await mkdir("./build/temp", { recursive: true });
|
|
||||||
await writeFile("./build/temp/forge.js", modifiedForge);
|
|
||||||
|
|
||||||
await build({
|
await build({
|
||||||
entryPoints: ["./packages/safe-chain/bin/safe-chain.js"],
|
entryPoints: ["./packages/safe-chain/bin/safe-chain.js"],
|
||||||
bundle: true,
|
bundle: true,
|
||||||
|
|
@ -42,10 +33,17 @@ async function bundleSafeChain() {
|
||||||
target: "node24",
|
target: "node24",
|
||||||
outfile: "./build/bin/safe-chain.cjs",
|
outfile: "./build/bin/safe-chain.cjs",
|
||||||
external: ["certifi"],
|
external: ["certifi"],
|
||||||
alias: {
|
|
||||||
"node-forge/lib/forge": "./build/temp/forge.js",
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Post-process: Replace all usePureJavaScript: false with true
|
||||||
|
// This ensures node-forge uses pure JavaScript crypto instead of native bindings
|
||||||
|
// which prevents segmentation faults in pkg binaries on Linux
|
||||||
|
let bundledContent = await readFile("./build/bin/safe-chain.cjs", "utf-8");
|
||||||
|
bundledContent = bundledContent.replace(
|
||||||
|
/usePureJavaScript:\s*false/g,
|
||||||
|
"usePureJavaScript: true"
|
||||||
|
);
|
||||||
|
await writeFile("./build/bin/safe-chain.cjs", bundledContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function copyShellScripts() {
|
async function copyShellScripts() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue