mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-07-17 02:01:26 +02:00
Remap build paths in wasm output and regenerate for wasm-bindgen 0.2.121
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
const { execSync } = require("node:child_process");
|
||||
const fs = require("node:fs");
|
||||
const os = require("node:os");
|
||||
const path = require("node:path");
|
||||
|
||||
if (process.env.SKIP_WASM_BUILD === "1") {
|
||||
@@ -7,7 +8,18 @@ if (process.env.SKIP_WASM_BUILD === "1") {
|
||||
return;
|
||||
}
|
||||
|
||||
execSync("wasm-pack build --target bundler", { stdio: "inherit" });
|
||||
// Remap machine-specific paths that rustc embeds into the binary (panic
|
||||
// location strings), so builds are reproducible across machines
|
||||
const sysroot = execSync("rustc --print sysroot").toString().trim();
|
||||
const cargoHome = process.env.CARGO_HOME ?? path.join(os.homedir(), ".cargo");
|
||||
|
||||
execSync("wasm-pack build --target bundler", {
|
||||
stdio: "inherit",
|
||||
env: {
|
||||
...process.env,
|
||||
RUSTFLAGS: `--remap-path-prefix=${cargoHome}=/cargo --remap-path-prefix=${sysroot}=/rustc`,
|
||||
},
|
||||
});
|
||||
|
||||
// Rewrite the generated entry to use Vite's ?init import style instead of
|
||||
// the ES Module Integration style that wasm-pack generates, which Vite/rolldown
|
||||
|
||||
Reference in New Issue
Block a user