wasm-pack icon indicating copy to clipboard operation
wasm-pack copied to clipboard

Pass arguments to wasm-bindgen

Open akriegman opened this issue 4 years ago • 8 comments

💡 Feature description

Right now wasm-pack allows passing arguments to cargo build, but doesn't do the same for wasm-bindgen. I feel like this should be a pretty important feature to have. In my case, I want to use --weak-refs flag with wasm-bindgen, and at the moment I see no way to use this feature while using wasm-pack.

For the syntax, we could add a flag:

# Like this:
wasm-pack --wbg-arg --weak-refs --wbg-arg --reference-types
# Or this:
wasm-pack --wbg-args '--weak-refs --reference-types'

The only problem I see with this syntax is it's different from the syntax for passing arguments to cargo, which is done with the -- flag. That's a bit unfortunate, but ¯\_(ツ)_/¯.

So, what do people think?

akriegman avatar Dec 15 '21 21:12 akriegman

#937 adds --weak-refs like any other flag, but I agree that there should be a mechanism to pass arbitrary flags to wasm-bindgen

serprex avatar Dec 17 '21 13:12 serprex

+1 as I need --omit-default-module-path

tennox avatar Nov 21 '22 15:11 tennox

Hi @drager, I don't think this issue should be closed. To this day, there's no viable way of passing arbitrary arguments to wasm-bindgen. wasm-pack currently only supports passing a subset of the arguments that are explicitly filtered and captured in its source code (e.g., --weak-refs and --reference-types).

jkomyno avatar Dec 06 '23 15:12 jkomyno