Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
MoLow committed Jul 25, 2022
1 parent 672af5d commit ed204e6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/internal/process/esm_loader.js
Original file line number Diff line number Diff line change
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 ed204e6

Please sign in to comment.