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

[RDKit_minimal.js]: Assign `initRDKitModule` to WorkerGlobalScope if possible

Aperta
#326 7 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
javascript, wasm
Ambito
web-dev

Direzione di ricerca

Start in Code/MinimalLib and trace how RDKit_minimal.js is generated from the C++ source. Check the generated module-worker behavior when RDKit_minimal.js is imported with type: "module". Done means initRDKitModule is available through WorkerGlobalScope without importScripts.

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

Descrizione

Is your feature request related to a problem? Please describe.

We can only use RDKit.js inside a web worker in a legacy way:

// worker.js, a classic worker
importScripts("./RDKit_minimal.js")

initRDKitModule().then((rdkit) => {
    const mol = rdkit.get_mol(smiles)
    ...
    postMessage(...)
})
// use this classic worker file
const worker = new Worker("./worker.js")

While there is a preferred way to use web worker: use module type:

const worker = new Worker("./worker.js", { type: "module" })

In this way, we can't use importScripts anymore since now worker.js file is considered a module, and an error would occur:

image

So, I instead we should use import:

// worker.js, a module worker
import './RDKit_minimal.js'

// ...

Now here's the problem: I can't access the initRDKitModule function anymore since it didn't assigned to WorkerGlobalScope, so we can't directly do something like below, which I think would be an ideal way to use RDKit.js:

import './RDKit_minimal.js'

initRDKitModule() // uncaught ReferenceError: initRDKitModule is not defined

Describe the solution you'd like

initRDKitModule function should be assigned to WorkerGlobalScope in RDKit_minimal.js.

I tried and it seems to work by just adding these lines at the end of RDKit_minimal.js:

image

I think it should be added directly in the source code before JavaScript code generation, I don't know how to do it since it's written in c++.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

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

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 Web Dev

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.