Skip to content

Commit 6b9b366

Browse files
committed
Remap build paths in wasm output and regenerate for wasm-bindgen 0.2.121
1 parent e20a184 commit 6b9b366

5 files changed

Lines changed: 134 additions & 129 deletions

File tree

crates/yaak-templates/build-wasm.cjs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
const { execSync } = require("node:child_process");
22
const fs = require("node:fs");
3+
const os = require("node:os");
34
const path = require("node:path");
45

56
if (process.env.SKIP_WASM_BUILD === "1") {
67
console.log("Skipping wasm-pack build (SKIP_WASM_BUILD=1)");
78
return;
89
}
910

10-
execSync("wasm-pack build --target bundler", { stdio: "inherit" });
11+
// Remap machine-specific paths that rustc embeds into the binary (panic
12+
// location strings), so builds are reproducible across machines
13+
const sysroot = execSync("rustc --print sysroot").toString().trim();
14+
const cargoHome = process.env.CARGO_HOME ?? path.join(os.homedir(), ".cargo");
15+
16+
execSync("wasm-pack build --target bundler", {
17+
stdio: "inherit",
18+
env: {
19+
...process.env,
20+
RUSTFLAGS: `--remap-path-prefix=${cargoHome}=/cargo --remap-path-prefix=${sysroot}=/rustc`,
21+
},
22+
});
1123

1224
// Rewrite the generated entry to use Vite's ?init import style instead of
1325
// the ES Module Integration style that wasm-pack generates, which Vite/rolldown

crates/yaak-templates/pkg/yaak_templates.d.ts

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/yaak-templates/pkg/yaak_templates_bg.js

Lines changed: 116 additions & 126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.95 KB
Binary file not shown.

crates/yaak-templates/pkg/yaak_templates_bg.wasm.d.ts

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)