* This is a singleton ESM loader that integrates the loader hooks, if any. * It it used by other internal built-ins when they need to load user-land ESM code * while also respecting hooks. * When built-ins need access to this loader, they should do * require('internal/module/esm/loader').getOrIn
(asyncLoaderHooks)
| 953 | * @returns {ModuleLoader} |
| 954 | */ |
| 955 | function getOrInitializeCascadedLoader(asyncLoaderHooks) { |
| 956 | if (!cascadedLoader) { |
| 957 | cascadedLoader = createModuleLoader(asyncLoaderHooks); |
| 958 | // import.meta.resolve is not allowed in the async loader hook worker thread. |
| 959 | // So only set up the import.meta.resolve initializer when we are initializing |
| 960 | // the non-loader-hook-thread cascaded loader. When the native land doesn't see it, |
| 961 | // it knows the loader is running on the loader hook thread. |
| 962 | if (!(asyncLoaderHooks?.isForAsyncLoaderHookWorker)) { |
| 963 | setImportMetaResolveInitializer(createImportMetaResolve.bind(null, cascadedLoader)); |
| 964 | } |
| 965 | } |
| 966 | return cascadedLoader; |
| 967 | } |
| 968 | |
| 969 | function isCascadedLoaderInitialized() { |
| 970 | return cascadedLoader !== undefined; |
no test coverage detected
searching dependent graphs…