* Construct a last nextLoad() for load hooks invoked for the CJS loader. * @param {string} url URL passed from the hook. * @param {string} filename Filename inferred from the URL. * @returns {(url: string, context: ModuleLoadContext) => ModuleLoadResult}
(url, filename)
| 1261 | * @returns {(url: string, context: ModuleLoadContext) => ModuleLoadResult} |
| 1262 | */ |
| 1263 | function getDefaultLoad(url, filename) { |
| 1264 | return function defaultLoad(urlFromHook, context) { |
| 1265 | // If the url is the same as the original one, save the conversion. |
| 1266 | const isLoadingOriginalModule = (urlFromHook === url); |
| 1267 | const filenameFromHook = isLoadingOriginalModule ? filename : convertURLToCJSFilename(urlFromHook); |
| 1268 | const source = defaultLoadImpl(filenameFromHook, context.format); |
| 1269 | // Format from context is directly returned, because format detection should only be |
| 1270 | // done after the entire load chain is completed. |
| 1271 | return { source, format: context.format }; |
| 1272 | }; |
| 1273 | } |
| 1274 | |
| 1275 | /** |
| 1276 | * Load a specified builtin module, invoking load hooks if necessary. |
no test coverage detected
searching dependent graphs…