extism / js-pdk

Write Extism plugins in JavaScript & TypeScript
BSD 3-Clause "New" or "Revised" License
56 stars 16 forks source link

Publish compiler as npm package #77

Open bhelx opened 6 months ago

bhelx commented 6 months ago

It might make sense to publish the whole package to npm and have the compiler published as a bin since that's how most people will be managing their other dependencies. We can also add it to the templates. There may be some trickiness around getting wasm-merge in place. Leaving this open for discussion and ideas on how to implement.

Phault commented 6 months ago

Seems fairly feasible to package it up. While I think it would be unwise to use this dependency due to its outdated dependencies, it can serve as a great reference either way: binary-install example. Someone also went through the trouble of rewriting it without axios: simple-binary-install.

Apparently binaryen npm package already contains wasm-merge and wasm-opt bins, and I can confirm extism-js works just fine with them. So this is just a matter of adding it as a peerDep.

Edit: Once again I've been duped by npm's hoisting behavior. Seems there's a bit more to it, on top of adding it as peerDep, as binaries of transient deps aren't hoisted.

So wasm-merge won't automatically become available for the plugin developer to directly call, unless they add it as a dep themselves. I believe it would be available to the extism-js binary that we'll bundle though, so it should be a non-issue.

ubiquitous-dev commented 5 months ago

This would be really awesome to see, it would make the process of using the pdk super streamlined for node devs. Also, it unlocks npx flows where you could execute a build without even having to install it locally, which is really great for quick-starting.