MCPcopy Index your code
hub / github.com/nodejs/node / loadBuiltinModuleForEmbedder

Function loadBuiltinModuleForEmbedder

lib/internal/modules/helpers.js:147–166  ·  view source on GitHub ↗

* Helpers to load built-in modules for embedder modules. * @param {string} id * @returns {import('internal/bootstrap/realm.js').BuiltinModule}

(id)

Source from the content-addressed store, hash-verified

145 * @returns {import('internal/bootstrap/realm.js').BuiltinModule}
146 */
147function loadBuiltinModuleForEmbedder(id) {
148 const normalized = BuiltinModule.normalizeRequirableId(id);
149 if (normalized) {
150 const mod = loadBuiltinModule(normalized);
151 if (mod) {
152 return mod;
153 }
154 }
155 if (isSEABuiltinWarningNeeded() && !warnedAboutBuiltins) {
156 emitWarningSync(
157 'Currently the require() provided to the main script embedded into ' +
158 'single-executable applications only supports loading built-in modules.\n' +
159 'To load a module from disk after the single executable application is ' +
160 'launched, use require("module").createRequire().\n' +
161 'Support for bundled module loading or virtual file systems are under ' +
162 'discussions in https://github.com/nodejs/single-executable');
163 warnedAboutBuiltins = true;
164 }
165 throw new ERR_UNKNOWN_BUILTIN_MODULE(id);
166}
167
168/** @type {Module} */
169let $Module = null;

Callers 2

embedderRequireFunction · 0.85

Calls 4

loadBuiltinModuleFunction · 0.85
emitWarningSyncFunction · 0.85
normalizeRequirableIdMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…