Skip to content

Commit

Permalink
esm: throw ERR_REQUIRE_ESM instead of ERR_INTERNAL_ASSERTION
Browse files Browse the repository at this point in the history
PR-URL: #54868
Backport-PR-URL: #56927
Fixes: #54773
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Refs: #52697
  • Loading branch information
aduh95 authored and marco-ippolito committed Feb 11, 2025
1 parent d1331fc commit 4813a6a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/internal/modules/esm/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,6 @@ class ModuleLoader {
* @returns {ModuleJobBase}
*/
getModuleJobForRequire(specifier, parentURL, importAttributes) {
assert(getOptionValue('--experimental-require-module'));

const parsed = URLParse(specifier);
if (parsed != null) {
const protocol = parsed.protocol;
Expand All @@ -338,6 +336,9 @@ class ModuleLoader {
}

const { url, format } = resolveResult;
if (!getOptionValue('--experimental-require-module')) {
throw new ERR_REQUIRE_ESM(url, true);
}
const resolvedImportAttributes = resolveResult.importAttributes ?? importAttributes;
let job = this.loadCache.get(url, resolvedImportAttributes.type);
if (job !== undefined) {
Expand Down

0 comments on commit 4813a6a

Please sign in to comment.