Add --bin-skip flag to build command #212
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Utility
In certain pipelines, it is convenient to use
cargo-leptos
to build the lib target and associated files only. This can be done currently by re-implementing the functionalitycargo-leptos
provides manually, but that may require parsing the project'sCargo.toml
, and it certainly requires more knowledge of the build process than is otherwise required to successfully usecargo-leptos
.An example where this is especially useful is a deploy pipeline for an AWS Lambda function. The server binary destined for the function must, among other things, target a particular architecture.
cargo-lambda
makes this very easy to achieve. Of course, the lib target and associated files do not require anything different, so they can be built withcargo-leptos
as normal. Here's what this might look like currently:In this sequence, the bin target is built twice. With a
--bin-skip
flag, it would only be built once:Implementation
My implementation is rather quick and dirty. I wanted to avoid adding a flag to all the subcommands when it only makes sense for
build
. Duplicating a large struct only to change one member is not ideal though. If there's a better approach for this feature, I'm all ears! I also totally understand if this feature isn't all that appropriate at the end of the day.It may also make more sense to provide mutually exclusive flags (or an option of some sort) so either target can be skipped.