Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed Jul 24, 2022
1 parent 5a15e7a commit dfad8f5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/internal/process/esm_loader.js
Expand Up @@ -58,23 +58,23 @@ async function initializeLoader() {
const { getOptionValue } = require('internal/options');
const customLoaders = getOptionValue('--experimental-loader');
const preloadModules = getOptionValue('--experimental-import');
const keyedExportsList = await loadInternalModules(customLoaders);
const keyedExportsList = await loadModulesInIsolation(customLoaders);

// Hooks must then be added to external/public loader
// (so they're triggered in userland)
// TODO(@JakobJingleheimer) this should be synchronous
await esmLoader.addCustomLoaders(keyedExportsList);

// Preload after loaders are added so they can be used
if (preloadModules?.length) {
await loadInternalModules(preloadModules);
await loadModulesInIsolation(preloadModules);
}

isESMInitialized = true;
}

async function loadInternalModules(requests) {
if (!ArrayIsArray(requests) || requests.length === 0)
return;
async function loadModulesInIsolation(specifiers) {
if (!ArrayIsArray(specifiers) || specifiers.length === 0) return;

let cwd;
try {
Expand All @@ -90,7 +90,7 @@ async function loadInternalModules(requests) {

// Importation must be handled by internal loader to avoid poluting userland
return internalEsmLoader.import(
requests,
specifiers,
pathToFileURL(cwd).href,
ObjectCreate(null),
);
Expand Down

0 comments on commit dfad8f5

Please sign in to comment.