Another trick — use comlink (https://github.com/GoogleChromeLabs/comlink) to make the worker thread into essentially an async API of your local methods.