261020.1 · 1d7e0126f3e601103d93586a6f872144f2789dad
chore: self-maintain Node.js features
reading declarations
Changes to tools/build-wasm.js. All files
@@ -39,8 +39,9 @@ if (mode !== "--in-container") { args.push(`${process.getuid()}:${process.getegid()}`); } args.push("--mount");- args.push(`type=bind,source=${ROOT}/deps,target=/home/node/build/deps`);+ args.push(`type=bind,source=${ROOT}/crates,target=/home/node/build/crates`); if (mode !== "--dry-run") {+ fs.mkdirSync(path.join(ROOT, "lib"), { recursive: true }); args.push("--mount"); args.push(`type=bind,source=${ROOT}/lib,target=/home/node/build/lib`); } else {@@ -65,15 +66,24 @@ if (mode !== "--in-container") { process.exit(0); } +// wasm-bindgen-cli must match the wasm-bindgen crate in Cargo.lock exactly.+const wasmBindgenVersion = fs+ .readFileSync(resolve(ROOT, "crates/amaro/Cargo.lock"), "utf8")+ .match(/name = "wasm-bindgen"\nversion = "([^"]+)"/)?.[1];+if (!wasmBindgenVersion) {+ throw new Error("Could not find wasm-bindgen in crates/amaro/Cargo.lock");+}+ execSync( `cp -r /home/node/.rustup /home/node/home/.rustup && \ export HOME=/home/node/home && \ export PATH=/home/node/home/.cargo/bin:$PATH && \ rustc --version && \- cd deps/swc/bindings/binding_nodejs_support_wasm && \- cargo install --locked wasm-pack wasm-bindgen-cli@0.2.100 && \- ./scripts/build.sh -- --config ../../../../tools/config.toml && \- cp -r pkg/* ../../../../lib`,+ cd crates/amaro && \+ cargo install --locked wasm-pack wasm-bindgen-cli@${wasmBindgenVersion} && \+ wasm-pack build --out-name wasm --release --target nodejs -- --locked --config ../../tools/config.toml && \+ node ../../tools/patch-wasm.mjs pkg && \+ cp -r pkg/* ../../lib`, { stdio: "inherit", },