Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

New Js Example: Top level await implementation for modern Browsers

Aperta
#337 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, wasm
Ambito
documentation

Direzione di ricerca

Start with examples/javascript/index.html and the linked top-level-await references. Compare the current promise-based example with the supplied HTML example, then document the modern-browser variant and verify it in the Puppeteer setup described. Done means the example is readable, works with the RDKit WASM module, and is included in the documentation.

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

Descrizione

I've been struggling to get running the javascript example on the documentation.

As it is well known, since ES2022, we can use top level await in javascript modules.

I can confirm that below example works.

✅ Tested on PDF generation HTML template with Puppeteer, run in NodeJS application.
<head>
  <!-- ...other files and HTML tags... -->
  <!-- Load the RDKit JS file -->
  <script src="https://unpkg.com/@rdkit/rdkit/dist/RDKit_minimal.js"></script>

  <!-- Instantiate the WASM module. The inline script below could live elsewhere inside your application code. -->
  <script type="module">
      const RDKitModule = await initRDKitModule(); // <-- Top level await

      const smiles = "CC(=O)Oc1ccccc1C(=O)O";
      const mol = RDKitModule.get_mol(smiles);
      const svg = mol.get_svg();
      console.log(svg);
  </script>
  <!-- ...your application code goes here... -->
</head>

Conclusion

After all, I got the proposed js example working. I just moved all my javascript code inside the .then statement.

Yeap, it works, but looks very messy and decreases readability.
Since most of the users are running modern browsers and my team works only with >=ES6, I really wanted that juicy syntactic sugar 🍭

I suggest adding the above example in the docs?

what do you say @MichelML

Lingua principale
SCSS
Stelle
248
Fork
47
Merge medio
4m
PR unite (30g)
4

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rdkit/rdkit-js

Tutte le issue di rdkit/rdkit-js

Issue simili

Altre issue su Documentation

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.