fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.29k stars 301 forks source link

Web target with hash included in wasm pkg files to solve cache issues #2384

Open Slixe opened 2 weeks ago

Slixe commented 2 weeks ago

Is your feature request related to a problem? Please describe. I have an web application using WebAssembly behind cloudflare, even if the cache is fully disabled, some browsers still keep the old WASM & js files when we do an update.

Describe the solution you'd like Having a hash concatened to the filename for easier update would be better.

Describe alternatives you've considered Doing by hand using a bash script. But I don't know where it's exactly loaded by flutter.

fzyzcjy commented 2 weeks ago

Looks reasonable! Looks like it is loaded in https://github.com/fzyzcjy/flutter_rust_bridge/blob/acf0d3248b2cd1edc2514d17a03e982f0fa6df78/frb_dart/lib/src/wasm_module/_web.dart#L12, loaded from https://github.com/fzyzcjy/flutter_rust_bridge/blob/master/frb_dart/lib/src/loader/_web.dart. It may not be too hard, and we even has some (pseudo) content hash computed in https://github.com/fzyzcjy/flutter_rust_bridge/blob/acf0d3248b2cd1edc2514d17a03e982f0fa6df78/frb_example/flutter_via_create/lib/src/rust/frb_generated.dart#L71.

Feel free to PR for this! Alternatively, I may work on this feature request later.