bytecodealliance / bytecodealliance/ComponentizeJS

ReferenceError when resource has no functions

Ouverte
#221 2 commentaires 1 réaction 0 personnes assignées Voir sur GitHub
Langage dominant
Rust
Étoiles
391
Forks
53
Merge moyen
3 j 5 h
PR mergées (30 j)
1

Description

Having an empty resource:
```wit
interface execution {

resource join-set-id {
// id: func() -> string;
}

new-join-set: func() -> join-set-id;
}
```
Calling `new-join-set` from a JavaScript guest fails with an error: `ReferenceError: import_execution_1_0_0$JoinSetId is not defined`.
This is because the generated `initializer.js`does not contain `class import_execution_1_0_0$JoinSetId {...}`, but tries to use it in the generated `new-join-set` function: `var rsc2 = new.target === import_execution_1_0_0$JoinSetId ? this : Object.create(import_execution_1_0_0$JoinSetId.prototype);`

The workaround is to add a function, which triggers the `class` generation.
Tested with componentize-js version 0.18.2 .

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Reproduce the empty-resource WIT example with componentize-js 0.18.2 and inspect the generated initializer.js. Trace the generated new-join-set function and verify that the empty resource produces its JoinSetId class and no longer raises a ReferenceError when called from a JavaScript guest.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
javascript, wasm
Domaine
tooling
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
48/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.