MCPcopy
hub / github.com/webpack/webpack / generate

Method generate

lib/runtime/WorkerRuntimeModule.js:21–30  ·  view source on GitHub ↗

* Generates runtime code for this runtime module. * @returns {string | null} runtime code

()

Source from the content-addressed store, hash-verified

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
33module.exports = WorkerRuntimeModule;

Callers

nothing calls this directly

Calls 2

getBuiltinModuleMethod · 0.80

Tested by

no test coverage detected