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

Support workspaces and -p

ctron opened this issue · comments

Coming out of a discussion on #670 … it might make more sense to support workspace projects and the ability to run trunk build -p frontend, which would:

  • Lookup the frontend crate inside the workspace
  • Then run trunk build/watch/serve --config <frontend>/Trunk.toml

is this meaning that we can use workspace with multiple crates to reduce the compilation time?

is this meaning that we can use workspace with multiple crates to reduce the compilation time?

You can already do that, assuming that workspace is an "all WASM" workspace. But you can split up your code like that already.

Even adding the ability to use -p when calling trunk would still mean that the workspaces needs to be compiled a second time for the "wasm" target. I guess this somehow also ties in #605. As it would make sense to a have different build profile for that part of the build.

@ctron Do you have recommendations for the implementation?

This is now a high priority item for me, since most of the repos I work will workspace examples or demos.

Thanks!

I would add a new --package argument to the CLI. There will be another discrepancy, as that's a clap only field, should be skipped from serde I guess.

And then, during the initialization of the configuration, perform the lookup, and change the base directory. Not actually change, but start processing with a different path.

Something else that should come with this is that Trunk should detect changes in the workspace by default.

No need for a Trunk.toml or watch list addition to the parent and member packages.