browserify / browserify/rustify

Should we register modules directly?

Aperta
#4 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
JavaScript
Stelle
491
Fork
6
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I was thinking: perhaps it would make sense to register modules directly?

E.g. turn this:
```js
var rust = require('rustify')

var wasm = rust`
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
`

WebAssembly.instantiate(wasm, {})
.then(function (res) {
var addOne = res.instance.exports.add_one
console.log(addOne(41))
console.log(addOne(68))
}).catch(function (e) {
console.error('Creating WASM module failed', e)
})
```
Into this:
```js
var rust = require('rustify')

var wasm = rust`
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
`

wasm.then((mod) => {
console.log(mod.add_one(41))
console.log(mod.add_one(68))
}).catch((e) => console.error('WASM error', e))
```

The benefit is that there's way less code to remember (ugh, `res.instance.exports`). The downside is that we're no long just exposing a Uint8Array, so doing things like registering a function twice is not going to be possible.

Would this be worth it?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start by comparing the current and proposed API examples in the issue and inspect the rustify transform entry point. The payload names no files or tests, and work is not complete until the project decides whether direct module registration is the desired interface and defines its behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, rust, wasm
Ambito
tooling
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.