Skip to content

Commit

Permalink
Switch to the web Target of wasm-bindgen
Browse files Browse the repository at this point in the history
This allows us to skip letting `webpack` parse the wasm files, which
means we are not blocked by its limitations anymore. This allows us to
finally start using reference types.
  • Loading branch information
CryZe committed Nov 5, 2024
1 parent aeb016c commit 4f5d204
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 114 deletions.
18 changes: 9 additions & 9 deletions buildCore.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ let profile = "debug";
let cargoFlags = "";
let rustFlags =
"-C target-feature=+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext,+simd128,+extended-const,+multivalue";
let wasmBindgenFlags = "";
let wasmBindgenFlags = "--encode-into always --target web --reference-types";
let target = "wasm32-unknown-unknown";
let targetFolder = target;

Expand All @@ -28,12 +28,8 @@ if (process.argv.some((v) => v === "--unstable")) {
// Relaxed SIMD is not supported by Firefox and Safari yet.
rustFlags += ",+relaxed-simd";

// Tail calls are not supported by Safari yet.
// Tail calls are not supported by Safari yet until 18.2 (early December).
rustFlags += ",+tail-call";

// Reference types are broken in webpack (or rather its underlying webassemblyjs):
// https://github.com/LiveSplit/LiveSplitOne/issues/630
// wasmBindgenFlags += " --reference-types";
}

// Use the nightly toolchain, which enables some more optimizations.
Expand Down Expand Up @@ -81,6 +77,10 @@ execSync(
}
);

fs.createReadStream("livesplit-core/capi/bindings/wasm_bindgen/index.ts").pipe(
fs.createWriteStream("src/livesplit-core/index.ts")
);
fs.createReadStream(
"livesplit-core/capi/bindings/wasm_bindgen/web/index.ts"
).pipe(fs.createWriteStream("src/livesplit-core/index.ts"));

fs.createReadStream(
"livesplit-core/capi/bindings/wasm_bindgen/web/preload.ts"
).pipe(fs.createWriteStream("src/livesplit-core/preload.ts"));
Loading

0 comments on commit 4f5d204

Please sign in to comment.