-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add JS Packaging #93
Comments
Recording some notes on the Our goal in selecting a packaging approach is maximum support across targets with the best possible developer ergonomics. As noted above, our initial goal will be to support the UCAN validator, which lives in a web app. In the long run, we may need to use multiple approaches to support all targets. wasm-pack
The The The wasm-bindgen
One benefit of this approach is that we can include a custom entry point that calls the Unfortunately, this approach relies on top-level await to load the module. A custom entry point might look like this: import init from './ucan-wasm.js';
await init();
export * from './ucan-wasm.js'; Top-level await makes a module asynchronous, which means Top-level await is available in all modern browsers, but support is still lacking in some bundlers like Let's pick one
|
The other option is to not use |
The scope of JS packaging is somewhat narrow compared to packaging in general, and with that in mind it can pay off to have opinions. We don't currently have a recorded use case for packaging as Wasm for use outside of JS (although I'm sure such use cases exist). @fabricedesre could you share any examples that come to mind that may show off the advantages of the less bloated
The issue states that Node.js and "other" JS environments are in scope for JS packaging. Should I understand that the initial use case is scoped to main-thread web (excluding web workers, I suppose, since we're assuming ESM)? As a general comment: JS bundling is a fraught exercise. There are about as many opinions as there are tools available for bundling, and no clear consensus in the community on the topic of tool interoperability. So, even if we bless a bundler strategy such as In other projects I have worked on, we have assumed that the NPM package consumer is probably using a bundler of their choice. This frees the package maintainer from having a strong opinion on bundling. Instead, they can worry about distributing a package that has a very good chance of being easily bundled. And today we have such niceties as ESM and Import Maps on the web, and configurable package entrypoints in Node.js, making this an easier strategy than it has been historically. With the above in mind, it seems like This is an aside: this article crossed my feed today from a former colleague; it may contain some topical pointers: https://www.donmccurdy.com/2023/05/24/publishing-webassembly-modules-with-assemblyscript/ |
Thanks for the Don McCurdy article! Good to see this approach. 🙏
Yep, the initial use case is main-thread web only. My initial thought was to only package for that, but it does seem like it would be better to package for a couple of environments.
@hugomrdias mentioned Automerge, which also packages for multiple environments. From their
I would be open to trying |
Let me try to re-vive my wit-bindgen branch. When I first tried I hit bytecodealliance/wit-bindgen#305 but that got fixed since. |
FWIW we already have support for RSA keys generated with Web Crypto in the |
Summary
Problem
We do not package
rs-ucan
for JavaScript environments.Impact
rs-ucan
cannot be used in web browsers, node, and other JavaScript environments.Solution
Add a crate that acts as a thin layer over the
ucan
anducan-key-support
crates. The crate should compile to Wasm and provide JS packaging.Detail
Is your feature request related to a problem? Please describe.
We want to use
rs-ucan
in the UCAN validator. See #19 (comment) for more detail.Describe the solution you'd like
Add a
ucan-wasm
crate that produces a JS-packaged version ofrs-ucan
.Additional context
Implementing initial support with a limited set of features and targets will probably be best. This approach will let us get the machinery in place and support the UCAN validator as a first target.
ETA: 2023-09-01
The text was updated successfully, but these errors were encountered: