cheatcode / joystick

A full-stack JavaScript framework for building stable, easy-to-maintain apps and websites.
https://cheatcode.co/joystick
Other
209 stars 11 forks source link

Consider support for a /wasm folder at the root that can ship .wasm to the browser #354

Open rglover opened 11 months ago

rglover commented 11 months ago

Wrote down a note in my sketchbook about this and I think it would work quite well. The real advantage with WASM is in the browser, not on a third-party platform.

Why: I can write resource-intensive code that needs to run on a per-user basis (e.g., calculating some statistics) and run it on a user's hardware. The advantage is that I'm not resource-capped by a remote instance or any convoluted deployment system.

In Joystick, I think we could set up a way to make it so you could load WASM modules at the component level (e.g., add an option called wasm to the component options):

import calca
const MyComponent = joystick.component({
  wasm: [
    'calculate_monthly_report',
  ],
  events: {
    'click .generate-report': async (event, instance) => {
      const report = await instance.wasm.calculate_monthly_report();
      console.log(report);
    },
  },
});

The whole idea here being that I can call WASM code via my UI and Joystick automatically ships the specified wasm modules down to the client.

In theory, this could help with a lot of performance stuff, but, you'd need to be mindful about security. It seems like the sandboxed nature of WASM modules would help with most of this.

rglover commented 2 months ago

See implementation notes: https://claude.ai/chat/f8048055-0675-4369-8cd9-23e73d426deb