Skip to content
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

Deno 2 WASI support #95

Open
G4Vi opened this issue Oct 14, 2024 · 1 comment
Open

Deno 2 WASI support #95

G4Vi opened this issue Oct 14, 2024 · 1 comment

Comments

@G4Vi
Copy link

G4Vi commented Oct 14, 2024

Deno removed wasi from their standard library, we should use the wasi polyfill instead on Deno 2.

From https://discord.com/channels/1011124058408112148/1156304630028959824/1295444183930110013:

main.ts

import createPlugin from "npm:@extism/extism";

const plugin = await createPlugin(
  "plugin.wasm",
  { useWasi: true, runInWorker: true },
);

let out = await plugin.call("greet", "a1");
console.log(out?.text());

lib.rs (compiled to wasm32-wasi w/ release)

use extism_pdk::*;

#[plugin_fn]
pub fn greet(name: String) -> FnResult<String> {
    Ok(format!("Hello, {}!", name))
}

result:

Uncaught (in worker "") Relative import path "wasi" not prefixed with / or ./ or ../ and not in import map from "data:text/javascript;base64,dm...lots of base64...

hint: If you want to use a built-in Node module, add a "node:" prefix (ex. "node:wasi").

at data:text/javascript;base64,dm...
@bhelx
Copy link
Contributor

bhelx commented Oct 14, 2024

Since wasi is deprecated in node as well, we might want to consider using the polyfill there too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants