trunk-rs / trunk

Build, bundle & ship your Rust WASM application to the web.

Home Page:https://trunkrs.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improvement: Use the original artifact name instead of hashed name for wasm-opt and wasm-bindgen.

basro opened this issue · comments

From what I understand trunk is currently appending the file hash to the rust build output wasm and then calling wasm-bindgen and wasm-opt on that.

Every time a new build happens the hash will change and the target/wasm-opt and target/wasm-bindgen folders receive a new file mypackage-<HASH>_bg.wasm

This will lead to the directories very quickly reaching gigabytes in size, specially when using trunk watch or trunk serve.

I propose that wasm-bindgen and wasm-opt are called with the original target name (eg mypackage_bg.wasm without the hash), stepping over previous builds each time.

The hash would be added to the filename in the final step when it's being copied into the dist folder.

This could also help with implementing #658 since the target folder will contain a file with the previous build.

@basro I created a PR for this, it would be great if you could give it a try too.

I apologize, since opening these issues I've moved to using wasm-pack + vite instead of trunk. I no longer have a project using trunk to easily test it on and because all my needs are fulfilled with my current setup I've lost interest in trunk for the moment.