Skip to content

Commit 1d4b97e

Browse files
authored
linera-web: make location-independent (#4030)
## Motivation When we merged `linera-web` into this repository, I left some relative paths in `build.bash` that break the build script. It would be nice to migrate back to `wasm-pack`, a more standard tool in the Rust world, but so far `wasm-pack` hasn't made a release that contains the necessary PR drager/wasm-pack#1443. ## Proposal Instead of using relative paths, extract the necessary paths from `cargo metadata`. ## Test Plan Tested locally. (We should really run `pnpm build` as part of the CI job, not just `cargo build`.) ## Release Plan - Nothing to do / These changes follow the usual release cycle. ## Links - [reviewer checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
1 parent 5b6c22e commit 1d4b97e

File tree

4 files changed

+7
-9
lines changed

4 files changed

+7
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ linera-faucet-server = { version = "0.15.0", path = "linera-faucet/server" }
285285
linera-indexer = { version = "0.15.0", path = "./linera-indexer/lib" }
286286
linera-indexer-graphql-client = { version = "0.15.0", path = "./linera-indexer/graphql-client" }
287287
linera-indexer-plugins = { version = "0.15.0", path = "./linera-indexer/plugins" }
288+
linera-persistent = { version = "0.15.0", path = "./linera-persistent" }
288289
linera-rpc = { version = "0.15.0", path = "./linera-rpc" }
289290
linera-sdk = { version = "0.15.0", path = "./linera-sdk" }
290291
linera-sdk-derive = { version = "0.15.0", path = "./linera-sdk-derive" }

default.nix

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
openssl
1717
protobuf
1818
git
19+
wasm-bindgen-cli
20+
pnpm
1921
];
2022
checkInputs = with pkgs; [
2123
# for native testing
@@ -27,7 +29,6 @@
2729
# for Wasm testing
2830
chromium
2931
chromedriver
30-
wasm-pack
3132
];
3233
passthru = { inherit rust-toolchain; };
3334
RUST_SRC_PATH = rust-toolchain.availableComponents.rust-src;

linera-web/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ crate-type = ["cdylib", "rlib"]
1717
console_error_panic_hook.workspace = true
1818
futures.workspace = true
1919
js-sys.workspace = true
20-
linera-persistent = { version = "0.15.0", path = "../linera-persistent" }
20+
linera-persistent.workspace = true
2121
log.workspace = true
2222
nonzero_lit.workspace = true
2323
serde.workspace = true

linera-web/build.bash

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@ cd $(dirname -- "${BASH_SOURCE[0]}")
77
wasm_bindgen_cli_version=$(wasm-bindgen --version)
88
wasm_bindgen_cli_version=${wasm_bindgen_cli_version##* }
99

10-
wasm_bindgen_cargo_version=
11-
if type -P tomlq > /dev/null
12-
then
13-
wasm_bindgen_cargo_version=$(tomlq -r < Cargo.lock '.package[]|select(.name == "wasm-bindgen")|.version')
14-
fi
10+
wasm_bindgen_cargo_version=$(cargo metadata --format-version 1 | jq -r '.packages[] | select(.name == "wasm-bindgen").version')
11+
target_dir=$(cargo metadata --format-version 1 | jq -r .target_directory)
1512

1613
if [[ "$wasm_bindgen_cargo_version" != "$wasm_bindgen_cli_version" ]]
1714
then
@@ -30,9 +27,8 @@ fi
3027
cargo build --lib --target wasm32-unknown-unknown $profile_flag
3128

3229
wasm-bindgen \
33-
target/wasm32-unknown-unknown/$profile_dir/linera_web.wasm \
30+
"$target_dir"/wasm32-unknown-unknown/$profile_dir/linera_web.wasm \
3431
--out-dir dist \
3532
--typescript \
3633
--target web \
3734
--split-linked-modules
38-

0 commit comments

Comments
 (0)