* Load the source code of a module based on format. * @param {string} filename Filename of the module. * @param {string|undefined|null} format Format of the module. * @returns {string|null}
(filename, format)
| 1235 | * @returns {string|null} |
| 1236 | */ |
| 1237 | function defaultLoadImpl(filename, format) { |
| 1238 | switch (format) { |
| 1239 | case undefined: |
| 1240 | case null: |
| 1241 | case 'module': |
| 1242 | case 'commonjs': |
| 1243 | case 'json': |
| 1244 | case 'module-typescript': |
| 1245 | case 'commonjs-typescript': |
| 1246 | case 'typescript': { |
| 1247 | return fs.readFileSync(filename, 'utf8'); |
| 1248 | } |
| 1249 | case 'builtin': |
| 1250 | return null; |
| 1251 | default: |
| 1252 | // URL is not necessarily necessary/available - convert it on the spot for errors. |
| 1253 | throw new ERR_UNKNOWN_MODULE_FORMAT(format, convertCJSFilenameToURL(filename)); |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | /** |
| 1258 | * Construct a last nextLoad() for load hooks invoked for the CJS loader. |
no test coverage detected
searching dependent graphs…