-
Notifications
You must be signed in to change notification settings - Fork 251
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
Support relaxed kebab case for filenames in compose
#1440
Comments
Thanks for the report! I fear though I may be missing the context necessary to reproduce this. This repository has libraries used in a bunch of other places so errors from these libraries may require code/reproductions from other places to investigate. Would you happen to have a repository and/or instructions of how to reproduce this? |
Sorry, should have given a MRE: cargo component new bin-foo
cd bin-foo
cargo component build
ls target/wasm32-wasi/debug/
# bin-foo.wasm is created
cd ..
cargo component new --lib lib-foo
cd lib-foo
cargo component build
ls target/wasm32-wasi/debug/
# lib_foo.wasm is created... but we need `-` not `_` 😭
cd ..
wasm-tools compose bin-foo/target/wasm32-wasi/debug/bin-foo.wasm -d lib-foo/target/wasm32-wasi/debug/lib_foo.wasm
# error: `lib_foo` is not in kebab case (at offset 0x0) So without modifying somethings along the chain here to compose, you must manually edit the name to use it (or make a soft link to it with the right name) Confirmed not to be fixed with |
Thanks! The issue here looks like it's inferring the name of the component from Could you detail a bit more about how this component is used within your build though? For example with composing components and |
In that MRE there isn't the correct imports/exports configured of course, the issue here is that wasm-tools rejects any filename not in kebab-case completely, hence I cannot use any lib.rs generated output as AFAIK there is no way to insist that cargo output that case (per the OP issue as well as rust-lang/cargo#13541). Here is a justfile that has a AFAIK, there is no reason to enforce kebab-case for file names (of course there is for symbols in wit)... is there? |
Probably the simplest fix here is to simply have it kebab-case the stem so that any file name will work. |
compose
compose
I am guessing that filename parsing is in a few subcommands, so there could be a few places where some conversion should happen? I see https://github.com/rutrum/convert-case might be a reasonable dependency add if you wanted to support arbitrary filenames -> import name used. Alternatively, just some patch like Happy to make a PR if pointed to the right place(s) that should include the conversion and approach desired. 😁 |
We already use Happy to review a PR if you feel inclined to submit one! |
Rust
[lib]
artifacts generated bycargo component
are not compatible with kebab case, see bytecodealliance/cargo-component#250 (comment) for context:It's a real unfortunate hack to need to do something like this in a build or make script:
I am all ears on how to better manage this case mismatch, other than the hack above. 🙏
The text was updated successfully, but these errors were encountered: