From eaeac1b887168561039c56e77b24c8fc01a825b0 Mon Sep 17 00:00:00 2001 From: Ulrik Strid Date: Mon, 15 Apr 2024 15:15:13 +0200 Subject: [PATCH] Fix rust-wasm-cross --- examples/rust-wasm-cross/.test.js | 1 + examples/rust-wasm-cross/.test.sh | 5 ++--- examples/rust-wasm-cross/app/Cargo.toml | 4 ++-- examples/rust-wasm-cross/devenv.nix | 12 +++++++----- examples/rust-wasm-cross/devenv.yaml | 2 ++ 5 files changed, 14 insertions(+), 10 deletions(-) create mode 100644 examples/rust-wasm-cross/.test.js diff --git a/examples/rust-wasm-cross/.test.js b/examples/rust-wasm-cross/.test.js new file mode 100644 index 000000000..1d5c2f1ea --- /dev/null +++ b/examples/rust-wasm-cross/.test.js @@ -0,0 +1 @@ +import("./app/pkg/app.js").then((app) => app.main()); diff --git a/examples/rust-wasm-cross/.test.sh b/examples/rust-wasm-cross/.test.sh index 341415f21..cfe2f4e0a 100755 --- a/examples/rust-wasm-cross/.test.sh +++ b/examples/rust-wasm-cross/.test.sh @@ -12,7 +12,6 @@ fi [[ "$CARGO_INSTALL_ROOT" == "$DEVENV_STATE/cargo-install" ]] echo "$PATH" | grep -- "$CARGO_INSTALL_ROOT/bin" -cd app -wasm-pack build --target nodejs +wasm-pack build ./app --target nodejs -node <<< "import('./pkg/app.js').then(app => app.main());" +node .test.js diff --git a/examples/rust-wasm-cross/app/Cargo.toml b/examples/rust-wasm-cross/app/Cargo.toml index 95bad7c3a..ad5d442c3 100644 --- a/examples/rust-wasm-cross/app/Cargo.toml +++ b/examples/rust-wasm-cross/app/Cargo.toml @@ -11,8 +11,8 @@ edition = "2021" [dependencies] wasm-bindgen = "0.2.84" -[workspace] - [profile.release] # Tell `rustc` to optimize for small code size. opt-level = "s" + +[workspace] diff --git a/examples/rust-wasm-cross/devenv.nix b/examples/rust-wasm-cross/devenv.nix index 04a4f550d..4d3780957 100644 --- a/examples/rust-wasm-cross/devenv.nix +++ b/examples/rust-wasm-cross/devenv.nix @@ -8,16 +8,18 @@ targets = [ "wasm32-unknown-unknown" ]; - components = [ "rustc" "cargo" "clippy" "rustfmt" "rust-analyzer" ]; + components = [ "rustc" "cargo" "clippy" "rustfmt" "rust-analyzer" "rust-std" ]; }; - pre-commit.hooks = { - rustfmt.enable = true; - clippy.enable = true; - }; + # These break us + # pre-commit.hooks = { + # rustfmt.enable = true; + # clippy.enable = true; + # }; packages = [ pkgs.wasm-pack + pkgs.nodejs ] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk; [ frameworks.Security ]); diff --git a/examples/rust-wasm-cross/devenv.yaml b/examples/rust-wasm-cross/devenv.yaml index aecda8b76..099875363 100644 --- a/examples/rust-wasm-cross/devenv.yaml +++ b/examples/rust-wasm-cross/devenv.yaml @@ -4,3 +4,5 @@ inputs: inputs: nixpkgs: follows: nixpkgs + devenv: + url: path:../../src/modules