Simple test project that sets up a hybrid cargo crate with a vite project

feat: enable wasm debug sourcemaps

Signed-off-by: Jonathan Basniak <9uknek65z@mozmail.com>

+30 -3
+11
Cargo.lock
··· 28 28 name = "com-gm112-rust-testlibrary" 29 29 version = "0.1.0" 30 30 dependencies = [ 31 + "console_error_panic_hook", 31 32 "wasm-bindgen", 32 33 "wasm-bindgen-test", 33 34 ] ··· 37 38 version = "0.1.0" 38 39 dependencies = [ 39 40 "com-gm112-rust-testlibrary", 41 + ] 42 + 43 + [[package]] 44 + name = "console_error_panic_hook" 45 + version = "0.1.7" 46 + source = "registry+https://github.com/rust-lang/crates.io-index" 47 + checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" 48 + dependencies = [ 49 + "cfg-if", 50 + "wasm-bindgen", 40 51 ] 41 52 42 53 [[package]]
+3
Cargo.toml
··· 1 1 [workspace] 2 2 members = ["com-gm112-rust-testlibrary", "com-gm112-rust-testproject"] 3 3 resolver = "3" 4 + 5 + [profile.release] 6 + opt-level = "s"
+9 -2
com-gm112-rust-testlibrary/Cargo.toml
··· 4 4 edition = "2024" 5 5 rust-version = "1.90.0" 6 6 7 - #crate-type = ["cdylib", "rlib"] # cdylib for Wasm, rlib for Rust libraries 8 - 9 7 [lib] 10 8 crate-type = ["cdylib", "rlib"] 11 9 10 + [features] 11 + default = ["console_error_panic_hook"] 12 + 12 13 [dependencies] 14 + console_error_panic_hook = { version = "0.1.7", optional = true } 13 15 wasm-bindgen = "0.2.104" 16 + 17 + [dev-dependencies] 14 18 wasm-bindgen-test = "0.3.54" 19 + 20 + [package.metadata.wasm-pack.profile.dev.wasm-bindgen] 21 + dwarf-debug-info = true
+1 -1
com-gm112-rust-testlibrary/package.json
··· 4 4 "type": "module", 5 5 "scripts": { 6 6 "prepare": "([ -d ./pkg ] || pnpm run build) || true", 7 - "build": "wasm-pack build --target bundler", 7 + "build": "wasm-pack build --target bundler --dev", 8 8 "build:prod": "wasm-pack build --target bundler --release", 9 9 "test": "wasm-pack test --node", 10 10 "format": "cargo fmt && cargo clippy --fix",
+4
com-gm112-rust-testlibrary/playground/vite.config.ts
··· 4 4 export default defineConfig({ 5 5 plugins: [wasm()], 6 6 root: 'app', 7 + build: { 8 + sourcemap: true, 9 + target: 'esnext', 10 + }, 7 11 })
+2
pnpm-lock.yaml
··· 41 41 42 42 com-gm112-rust-testlibrary: {} 43 43 44 + com-gm112-rust-testlibrary/pkg: {} 45 + 44 46 com-gm112-rust-testlibrary/playground: 45 47 dependencies: 46 48 '@vitest/browser':