Skip to content
Closed
Prev Previous commit
Next Next commit
fixup! fixup! module: unflag import assertions
  • Loading branch information
aduh95 committed Sep 12, 2021
commit 733deb87a9b07c5267f30c93e30bb8f76fa6a5ad
7 changes: 3 additions & 4 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const {
PromiseAll,
RegExpPrototypeExec,
SafeArrayIterator,
SafeMap,
SafeWeakMap,
globalThis,
} = primordials;
Expand Down Expand Up @@ -46,7 +45,7 @@ const { translators } = require(
'internal/modules/esm/translators');
const { getOptionValue } = require('internal/options');

const finalFormatCache = new SafeMap();
const finalFormatCache = new SafeWeakMap();

/**
* An ESMLoader instance is used as the main entry point for loading ES modules.
Expand Down Expand Up @@ -235,7 +234,7 @@ class ESMLoader {
// fulfill first.
await job.modulePromise;
Comment thread
aduh95 marked this conversation as resolved.

const finalFormat = finalFormatCache.get(url);
const finalFormat = finalFormatCache.get(job);
if (import_assertions.type === 'json' && finalFormat !== 'json') {
throw new ERR_FAILED_IMPORT_ASSERTION(
url, 'type', import_assertions.type, finalFormat);
Expand All @@ -259,7 +258,7 @@ class ESMLoader {
throw new ERR_FAILED_IMPORT_ASSERTION(
url, 'type', import_assertions.type, finalFormat);
} else if (import_assertions.type == null) {
finalFormatCache.set(url, finalFormat);
finalFormatCache.set(job, finalFormat);
}

const translator = translators.get(finalFormat);
Expand Down