Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would like a way to pass arguments to cargo, before "build" #923

Open
ijackson opened this issue Oct 9, 2020 · 0 comments · May be fixed by #924
Open

Would like a way to pass arguments to cargo, before "build" #923

ijackson opened this issue Oct 9, 2020 · 0 comments · May be fixed by #924

Comments

@ijackson
Copy link

ijackson commented Oct 9, 2020

Motivation

I would like to be able to pass global options to cargo. In particular, I use --locked and --offline quite heavily. --locked is useful to avoid unwanted updates. --offline is important if I'm in a poor (or expensive) network environment.

💡 Feature description

Currently, -- introduces options to cargo build. It's not so easy to shoehorn an additional free-form list of arguments. I suggest we take a leaf from compiler drivers like gcc, and introduce a repeatable option that adds one additional cargo argument.

💻 Basic example

So, you could say something like

   wasm-pack --cargo-opt=--locked --cargo-opt=--verbose --cargo-opt=--color=never build

If your cargo is actually rustup pretending to be cargo (so normally you can say cargo +nightly build) and you encounter #629, you could say

  wasm-pack --cargo-opt=+nightly build

Alternatives

The only plausible alternative for a user like me right now, without some change to wasm-pack, is to live with the unwanted lockfile updates, or to put a stunt wrapper for cargo on the PATH. Or to abandon wasm-pack and go to wasm-bindgen-cli.

As for the proposed command line syntax for wasm-pack, I think --cargo-opt=... is probably the best but I'm happy to implement whatever syntax you prefer. If you are looking for prior art, gcc has -Wl,--some-linker-option, but that's not very readable. -C... would be a possibility but steals a single-letter option.

I'm sure the value ought to be the whole thing passed to cargo, not just the part after --. Anything else would be really very confusing.

Another possibilty would be to do something more complicated, perhaps with --- meaning something special, but it doesn't seem desirable for wasm-pack's command line parsing to be funky and exciting. It should be straightforward, and rather unusual use cases like mine definitely don't need super-brief syntax.

ijackson added a commit to ijackson/wasm-pack that referenced this issue Oct 10, 2020
ijackson added a commit to ijackson/wasm-pack that referenced this issue Oct 10, 2020
@ijackson ijackson linked a pull request Oct 10, 2020 that will close this issue
3 tasks
ijackson added a commit to ijackson/wasm-pack that referenced this issue Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants