Fix build:wasm:dev for --dev builds (#6038)

This is useful since it preserves Rust backtraces in WASM.
This commit is contained in:
Jonathan Tran
2025-03-28 08:40:21 -04:00
committed by GitHub
parent 678ebbc310
commit b57d31c0e7
3 changed files with 37 additions and 1 deletions

View File

@ -0,0 +1,18 @@
# Stop the script when a cmdlet or a native command fails
# from https://www.meziantou.net/stop-the-script-when-an-error-occurs-in-powershell.htm
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
rm -Recurse -Force rust/kcl-wasm-lib/pkg
mkdir -p rust/kcl-wasm-lib/pkg
rm -Recurse -Force rust/kcl-lib/bindings
cd rust
$env:RUSTFLAGS='--cfg getrandom_backend="wasm_js"'
wasm-pack build kcl-wasm-lib --dev --target web --out-dir pkg
$env:RUSTFLAGS=''
cargo test -p kcl-lib export_bindings
cd ..
copy rust\kcl-wasm-lib\pkg\kcl_wasm_lib_bg.wasm public
yarn fmt:generated