I am encountering an issue with my worker.js file:
self.importScripts('/static/utils/utils.js')
onmessage = (e) => {
let a = e.data[0]
let b = e.data[1]
let c = func1(a,b)
postMessage(c)
}
The structure of the utils.js file is as follows:
module.exports = {
func1: function(a,b){
return a+b
}
An error message keeps popping up:
Uncaught ReferenceError: module is not defined
at utils.js:1
Curiously, although server side imports like require and import are not functioning properly, I am puzzled by the fact that importScripts is causing issues - https://developer.mozilla.org/en-US/docs/Web/API/WorkerGlobalScope/importScripts