Currently, we have two separate projects. One is the main project another one is an independent library which will be used by the first one.
In the library, I need to set up web workers to run heavy js code in a separate thread. Web worker finds file to execute by using url to the file. But the problem is that webworkers are trying to find the file by going to main project url localhost:3000/URL_TO_FILE instead of library directory.
The Library is located in node_modules. I need something like that:
let worker = new window.Worker('./local_library_folder/worker.js')
Current url is leading to main project root folder, otherwise web worker doesn't see the file
After a long search I have finally found a solution. This solved the problem https://github.com/webpack-contrib/worker-loader
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.