You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
component new: Failed to resolve import env::console_log #2483
../wasm-tools/wasm-tools component new quic.embedded.wasm -o quic.component.wasm
error: failed to encode a component from module
Caused by:
0: failed to decode world from module
1: module was not valid
2: failed to resolve import `env::console_log`
3: import interface `env` is missing function `console_log` that is required by the module
From what I can see, the WIT is fine and wasm-tools is doing the right thing, but the WAT being passed to watToWit does not match the naming scheme wasm-tools expects for the specified WIT interface. Specifically, wasm-tools expects an import named "console-log" from a module named "env" based on the declared name in the WIT file. Instead, it's finding an import named "console_log" from the module named "env" and doesn't know what to do with it.
I think it should be the other way around. wasm-tools should be flexible enough, and/or the WIT/Component Model should be adaptible enough to handle whatever is thrown at it.
WIT has to deal with whatever is in the WAT and WASM.
WIT is intended to provide a human-readable representation of the Component Model type system, which does not cover every possible existing ABI and naming convention used in Wasm modules that exist in the wild. The expectation is that the module author (or binding generator) will have the Component Model "canonical" ABI and naming convention in mind when creating the application, which may require source code modifications.
I do recall there was a plan to eventually support other (i.e. "non-canonical") ABIs and/or naming conventions in the Component Model, but I'm not aware of any existing support for that in the specification or in wasm-tools.
The expectation is that the module author (or binding generator) will have the Component Model "canonical" ABI and naming convention in mind when creating the application, which may require source code modifications.
Yeah, that doesn't make sense to me.
I didn't have WebAssembly Components in mind when I created the WASM. I'm just trying to port the working code to different programming languages/application layers.
This appears to me to be a bug in the core design.
Who cares if the source code has an underscore or a dash? That's far too restrictive. If anything wasm-tools/the specification should just handle both; or internally map what it can't handle for whatever reason, to what it can handle.
Realistically, I shouldn't have had to go to Google Gemini to create WIT from WAT. All of that conversion should be baked in to one of these WebAssembly Component Model programs.
You said the WIT looks fine.
From what I can see, the WIT is fine
So, if the WIT is fine, there shouldn't be any issues creating a component. But there is, and that issue is seen downstream bytecodealliance/jco#1362 (comment).
Can't have valid WIT, yet at the same time suggest to change the whole source code to accomodate a program that can't handle valid WIT.
The expectation is that the module author (or binding generator) will have the Component Model "canonical" ABI and naming convention in mind when creating the application, which may require source code modifications.
If that's the case you folks should consider updating all of those examples/tutorials in your documentations to say exactly that.
I havn't read anywhere in the tutorials/examples of creating compoenents from existing WAT that the import/export names need to be changed to accomodate a specific design goal, and refer to that specification section that says you MUST use dashes in source code.
Part of what I'm doing here is vetting the WebAssembly Component Model.
I don't see what all the hubbub is about. I don't see any advantages in the design cf. core modules. But I'm testing it out for empirical evidence. Then I encounter this subtle, yet turns out to be a show-stopping 'lil inconsitency.
@guest271314 we appreciate feedback and questions, but I'd ask you to be mindful of the fact that you're discussing a project that many people have been working on for many years, as well as that we're all people with limited amounts of time. That means you have to do some amount of research yourself, instead of asking other people to answer any question you might have. It also means assuming that not everything you don't immediately understand is wrong or broken.
You've voiced your opinion on all this here and in other issues such as in JCO—please be assured that we've heard it.
I'll go ahead and close this issue, since it's answered as much as it can be.
Activity
dicej commentedon Apr 7, 2026
From what I can see, the WIT is fine and
wasm-toolsis doing the right thing, but the WAT being passed towatToWitdoes not match the naming schemewasm-toolsexpects for the specified WIT interface. Specifically,wasm-toolsexpects an import named "console-log" from a module named "env" based on the declared name in the WIT file. Instead, it's finding an import named "console_log" from the module named "env" and doesn't know what to do with it.guest271314 commentedon Apr 7, 2026
I don't see why
wasm-toolsis expecting a dash there. WIT has to deal with whatever is in the WAT and WASM.guest271314 commentedon Apr 7, 2026
The source code has an underscore https://github.com/endel/quic-zig/blob/wasm-experiment/src/wasm_api.zig#L16
No idea why
wasm-toolsis expecting anything in particular from source code from the wild.dicej commentedon Apr 7, 2026
Does Zig have a way to specify the import name? In C, it would be:
In Rust:
In Go:
guest271314 commentedon Apr 7, 2026
Hmm. So the suggestion is to change working source code for
wasm-toolsto be able to handle it, where the source code works as-is as a WebAssembly core Module https://github.com/guest271314/webtransport/blob/wasm/webtransport-example.js#L53C1-L68C33?I think it should be the other way around.
wasm-toolsshould be flexible enough, and/or the WIT/Component Model should be adaptible enough to handle whatever is thrown at it.dicej commentedon Apr 7, 2026
WIT is intended to provide a human-readable representation of the Component Model type system, which does not cover every possible existing ABI and naming convention used in Wasm modules that exist in the wild. The expectation is that the module author (or binding generator) will have the Component Model "canonical" ABI and naming convention in mind when creating the application, which may require source code modifications.
I do recall there was a plan to eventually support other (i.e. "non-canonical") ABIs and/or naming conventions in the Component Model, but I'm not aware of any existing support for that in the specification or in
wasm-tools.guest271314 commentedon Apr 7, 2026
Yeah, that doesn't make sense to me.
I didn't have WebAssembly Components in mind when I created the WASM. I'm just trying to port the working code to different programming languages/application layers.
This appears to me to be a bug in the core design.
Who cares if the source code has an underscore or a dash? That's far too restrictive. If anything
wasm-tools/the specification should just handle both; or internally map what it can't handle for whatever reason, to what it can handle.Realistically, I shouldn't have had to go to Google Gemini to create WIT from WAT. All of that conversion should be baked in to one of these WebAssembly Component Model programs.
You said the WIT looks fine.
So, if the WIT is fine, there shouldn't be any issues creating a component. But there is, and that issue is seen downstream bytecodealliance/jco#1362 (comment).
Can't have valid WIT, yet at the same time suggest to change the whole source code to accomodate a program that can't handle valid WIT.
guest271314 commentedon Apr 7, 2026
@dicej
If that's the case you folks should consider updating all of those examples/tutorials in your documentations to say exactly that.
I havn't read anywhere in the tutorials/examples of creating compoenents from existing WAT that the import/export names need to be changed to accomodate a specific design goal, and refer to that specification section that says you MUST use dashes in source code.
guest271314 commentedon Apr 7, 2026
Part of what I'm doing here is vetting the WebAssembly Component Model.
I don't see what all the hubbub is about. I don't see any advantages in the design cf. core modules. But I'm testing it out for empirical evidence. Then I encounter this subtle, yet turns out to be a show-stopping 'lil inconsitency.
tschneidereit commentedon Apr 7, 2026
@guest271314 we appreciate feedback and questions, but I'd ask you to be mindful of the fact that you're discussing a project that many people have been working on for many years, as well as that we're all people with limited amounts of time. That means you have to do some amount of research yourself, instead of asking other people to answer any question you might have. It also means assuming that not everything you don't immediately understand is wrong or broken.
You've voiced your opinion on all this here and in other issues such as in JCO—please be assured that we've heard it.
I'll go ahead and close this issue, since it's answered as much as it can be.
guest271314 commentedon Apr 8, 2026
@tschneidereit I did my research. Just because something gets worked on a long time doesn't mean it works.
You close the issue but your gear is still broken in this case.