Been playing around with js-component-tools to interact with wasm components. The js that is produced from transpilation seems to be making an attempt to import from packages that I don't believe I have access to. Is there a way that one is able to access these imports? Here are the import statements that appear to be problematic.
import { exit as lowering3Callee } from 'wasi-exit';
import { dropInputStream as lowering0Callee, dropOutputStream as lowering1Callee, write as lowering5Callee } from 'wasi-io';
import { print as lowering4Callee } from 'print';
import { print as lowering8Callee } from 'wasi-stderr';
import { close as lowering2Callee, writeViaStream as lowering6Callee, appendViaStream as lowering7Callee } from 'wasi-filesystem';
I believe the CLI should have various options to map these to different imports or local files, but I don't know the names of the options off-hand myself
Thanks! I'll try looking into that
So I see how to use the cli options to map to local files and things... but are there recommended implementations of these things to point to locally from this js setting?
You can find a shim (that implements the most basic functionality) for this here: https://github.com/bytecodealliance/jco/tree/main/packages/preview2-shim
@Eduardo Rodrigues Thanks! great to know. Will have to tinker a bit with providing the shim implementations to the transpiled js now
After some more experimentation, I noticed that when using the mapping flag to point to the local shim, that the import paths seem to be relative to the transpiled js file. Found the easiest way to make things work was to copy/paste the shim into the generated js, so as to avoid referencing file paths outside of the generated code. Would it be helpful to include the shim in the transpilation output? Or to make the possibility configurable?
If it's helpful, I could open a PR
I agree is a little bit annoying, but we probably need to wait for more implementation coverage as well as stabilization of the WASI preview2 definition.
Last updated: Nov 22 2024 at 16:03 UTC