I tried it with Bun and I feel weird showing examples that don't seem to run.
> $ npm install @wasmer/sdk
```js import { Wasmer } from "@wasmer/sdk";
let cowsay = Wasmer.fromRegistry("cowsay"); let instance = await cowsay.entrypoint.run({ args: "\"Hello world\"" }); let output = await instance.wait(); ```
I also tried to use the <script> approach and I cannot get it working on a local dev server due to CORS.
For the CORS with Vite you can just set a config like so in vite.config.ts
import { defineConfig } from "vite";
export default defineConfig({ server: { headers: { "Cross-Origin-Embedder-Policy": "require-corp", "Cross-Origin-Opener-Policy": "same-origin", }, }, });
I was then able to just use this code example with one caveat (https://github.com/wasmerio/wasmer-js?tab=readme-ov-file#use...)
I had to update the SDK import with crossorigin="anonymous"
Seems like they still have to update their stuff a fair few places...
Now I'm just struggling to use the package registry, none of the copy and paste examples have worked for me, but I'm sure I can figure it out. Will post here if I do.
I tried it with Bun and I feel weird showing examples that don't seem to run.
> $ npm install @wasmer/sdk
```js import { Wasmer } from "@wasmer/sdk";
let cowsay = Wasmer.fromRegistry("cowsay"); let instance = await cowsay.entrypoint.run({ args: "\"Hello world\"" }); let output = await instance.wait(); ```
I also tried to use the <script> approach and I cannot get it working on a local dev server due to CORS.