MCPcopy
hub / github.com/webpack/webpack / getBuiltinModule

Method getBuiltinModule

lib/RuntimeTemplate.js:400–406  ·  view source on GitHub ↗

* Reads a node builtin via `process.getBuiltinModule()`, guarded to stay falsy off node so universal `["node", "web"]` bundles don't crash (also falsy on node <22.3). * @param {string} request builtin module request as a JS string expression, e.g. from `renderNodePrefixForCoreModule` * @param {s

(request, access = "")

Source from the content-addressed store, hash-verified

398 * @returns {string} guarded expression
399 */
400 getBuiltinModule(request, access = "") {
401 const getter = `process.getBuiltinModule(${request})${access}`;
402 if (this.outputOptions.environment.nodeBuiltinModuleGetter) {
403 return `typeof process !== "undefined" && ${getter}`;
404 }
405 return `typeof process !== "undefined" && typeof process.getBuiltinModule === "function" && ${getter}`;
406 }
407
408 /**
409 * Renders an object-literal method, using method shorthand when supported

Callers 2

generateMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected