* Generates runtime code for this runtime module. * @returns {string | null} runtime code
()
| 19 | * @returns {string | null} runtime code |
| 20 | */ |
| 21 | generate() { |
| 22 | const compilation = /** @type {Compilation} */ (this.compilation); |
| 23 | const { runtimeTemplate } = compilation; |
| 24 | // prefer a global `Worker` when present (web, Bun, polyfills), else `worker_threads.Worker` |
| 25 | const nodeWorker = runtimeTemplate.getBuiltinModule( |
| 26 | runtimeTemplate.renderNodePrefixForCoreModule("worker_threads"), |
| 27 | ".Worker" |
| 28 | ); |
| 29 | return `${RuntimeGlobals.worker} = typeof Worker !== "undefined" ? Worker : ${nodeWorker};`; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | module.exports = WorkerRuntimeModule; |
nothing calls this directly
no test coverage detected