trunk-rs / trunk

Build, bundle & ship your Rust WASM application to the web.
https://trunkrs.dev/
Apache License 2.0
3.55k stars 253 forks source link

Expose watch status to hooks #818

Open Madoshakalaka opened 4 months ago

Madoshakalaka commented 4 months ago

I wish trunk emits "build success/error" messages during a watch task as I'm making a statusline plugin for trunk in neovim.

ctron commented 4 months ago

When using trunk serve, you can already have that in the browser. So there's a websocket which emits that state. I think you should be able to use the same.

Madoshakalaka commented 4 months ago

unfortunately I can't use that. I use trunk in an SSR project and builds the SSR server after the frontend. I run trunk watch and touch .build_trigger in one of the hooks, which triggers the SSR server to build. The problem is, sometimes the frontend fails to build and I can't immediately know why without switching tabs/navigating (especially when rust-analyzer uses every feature flag from the whole workspace which differs from those used in frontend building so I can't detect it in the editor)

ctron commented 4 months ago

Ah, I see. Yes that makes sense. And it might be good idea to have that.

Just thinking about possible ways to transport that information, what about using the same serialization (JSON) and writing that to some file? (dist folder, target folder?) and then providing an env-var for the hooks pointing to that file. That file might exist in any way, having an "ok" status by default.