trunk-rs / trunk

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

Delay asset pipeline until rust build finished #701

Open lpotthast opened 9 months ago

lpotthast commented 9 months ago

My use case includes copying SCSS files through a libraries build.rs file into my application root directory.

Building the styles (SASS) will only work with the output from this build script.

But the asset pipeline always runs in parallel / can not be configured to run after a finished rust build. Errors in the SASS pipeline lead to a retry, also skipping/aborting the rust build, leading to no build.rs being executed an and endless retry-loop.

Could such an optional behavior be integrated into trunk?

lpotthast commented 9 months ago

A not-so-great workaround would be to add a “pre-build” hook that executes a cargo check to enforce running the build once.

ctron commented 9 months ago

Interesting. Right now, there isn't a real scheduler/dependency tree in the trunk build pipeline. However, there's another use case, where web-workers might have a dependency on each other, and the application being last (in order to inject env-vars with cache busting name).

Your use case looks like one more use case for having dependencies between different build steps.

carloskiki commented 2 months ago

I have a very similar issue, but in my case the build always runs twice, which is annoying.

My build scripts generates some static assets to be served to the website.

There are two ways that I can think about to solve this:

ctron commented 2 months ago

Yea, in general it might be great to have a dependency graph inside of trunk for that. But I agree that having a simple flag of "run pipelines sequentially" might be a good alternative.