Load Nodejs Module into A Web Worker

前端 未结 1 1179
终归单人心
终归单人心 2021-01-05 11:20

I\'m intending to use web worker inside my Node.js application for some concurrent tasks. However since the \'webworker-threads\' module follows the implementat

相关标签:
1条回答
  • 2021-01-05 12:06

    author of webworker-threads here. Thank you for using the module!

    There is a default native_fs_ object with the readFileSync you can use to read files.

    Beyond that, I've mostly relied on onejs to compile all required modules in package.json into a single JS file for importScripts to use, just like one would do when deploying to a client-side web worker environment. (There are also many alternatives to onejs -- browserify, etc.)

    Hope this helps!

    0 讨论(0)
提交回复
热议问题