bytecodealliance/wac

Provide option to downgrade `unknown import` errors to warnings

salmans opened this issue · 1 comments

When instantiating a component, it's probably safe to supply it with additional imports that aren't declared in its world. For example, consider a component that declares an import foo in its world but it doesn't use foo in its implementation. Consequently, foo won't be present in the component's WIT that is generated by witgen, which will cause a confusing unknown import error by wac. I think downgrading the error to a warning would be enough to let the user know about a potential logical error while allowing wac to run successfully.

I'm also running into this issue. For languages with good dead code elimination like Rust the resulting component binary might not reflect the exact targeted world if the any imports are not used - those imports will simply be removed. It would be nice if supply imports that don't exist was simply a warning as supplying an import that doesn't exist is essentially a noop.

Of course, this will largely go away with a programatic API where the actual world of the component can be dynamically inspected and only imports it actually requires can be provided.