Skip to content

Commit

Permalink
doc: esm/Loader
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobJingleheimer committed Sep 10, 2023
1 parent 9aecac7 commit 2f48a32
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,28 @@ const {
} = require('internal/modules/esm/utils');
let defaultResolve, defaultLoad, defaultLoadSync, importMetaInitializer;

/**
* Generate a resolve cache (to store the final result of a resolve-chain for a particular module).
* @returns {import('./module_map.js').ResolveCache')}
*/
function newResolveCache() {
const { ResolveCache } = require('internal/modules/esm/module_map');
return new ResolveCache();
}

/**
* Generate a load cache (to store the final result of a load-chain for a particular module).
* @returns {import('./module_map.js').LoadCache')}
*/
function newLoadCache() {
const { LoadCache } = require('internal/modules/esm/module_map');
return new LoadCache();
}

/**
* Lazy-load translators to avoid potentially unnecessary work at startup (ex if ESM is not used).
* @returns {import('./translators.js').Translators}
*/
function getTranslators() {
const { translators } = require('internal/modules/esm/translators');
return translators;
Expand Down

0 comments on commit 2f48a32

Please sign in to comment.