diff --git a/common/predictive-text/worker/index.ts b/common/predictive-text/worker/index.ts index 7c14f86c20..cab8577f0e 100644 --- a/common/predictive-text/worker/index.ts +++ b/common/predictive-text/worker/index.ts @@ -1,4 +1,14 @@ // Dummy module for getting environment setup. -module.exports ={ - hello: () => 'hello' +class MyWorker { + public hello() { + return 'hello'; + } +} + +// The technique below allows code to work both in-browser and in Node. +if(typeof module !== 'undefined' && typeof module.exports !== 'undefined') { + module.exports = new MyWorker(); +} else { + //@ts-ignore + window.worker = new MyWorker(); } \ No newline at end of file