From 2f48a32a7f843c7e40a01877631ea2a1d626bca2 Mon Sep 17 00:00:00 2001 From: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com> Date: Sun, 10 Sep 2023 16:21:24 +0200 Subject: [PATCH] doc: esm/Loader --- lib/internal/modules/esm/loader.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/internal/modules/esm/loader.js b/lib/internal/modules/esm/loader.js index 14b78f660f1782..9354088bf7e838 100644 --- a/lib/internal/modules/esm/loader.js +++ b/lib/internal/modules/esm/loader.js @@ -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;