Skip to content

Commit

Permalink
xtask: Don't run wasm-pack if no change.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Mar 9, 2024
1 parent e0c6c4c commit c26bb12
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tools/xtask/src/xtask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,20 @@ fn update_server_static(config: &Config, time_log: &mut Vec<Timing>) -> Result<(
) {
let _t = CaptureTime::new(time_log, "wasm-pack build");
let _pushd: Pushd = pushd("all-is-cubes-wasm")?;
cmd!("wasm-pack build --dev --target web").run()?;

// Run the compilation if needed, which ensures that the wasm binary is fresh.
// Note: This must use the same profile as the wasm-pack command is! (Both are dev for now)
cargo().arg("build").arg(TARGET_WASM).run()?;

// Run wasm-pack if and only if we need to.
// This is because it unconditionally runs `wasm-opt` which is slow and also means
// the files will be touched unnecessarily.
if newer_than(
["target/wasm32-unknown-unknown/debug/all_is_cubes_wasm.wasm"],
["pkg/all_is_cubes_wasm.js"],
) {
cmd!("wasm-pack build --dev --target web").run()?;
}
}

// Combine the static files and build results in the same way that webpack used to
Expand Down

0 comments on commit c26bb12

Please sign in to comment.