* Helpers to load built-in modules for embedder modules. * @param {string} id * @returns {import('internal/bootstrap/realm.js').BuiltinModule}
(id)
| 145 | * @returns {import('internal/bootstrap/realm.js').BuiltinModule} |
| 146 | */ |
| 147 | function 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} */ |
| 169 | let $Module = null; |
no test coverage detected
searching dependent graphs…