Skip to content

Commit 4813a6a

Browse files
aduh95marco-ippolito
authored andcommitted
esm: throw ERR_REQUIRE_ESM instead of ERR_INTERNAL_ASSERTION
PR-URL: #54868 Backport-PR-URL: #56927 Fixes: #54773 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Refs: #52697
1 parent d1331fc commit 4813a6a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/internal/modules/esm/loader.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,6 @@ class ModuleLoader {
318318
* @returns {ModuleJobBase}
319319
*/
320320
getModuleJobForRequire(specifier, parentURL, importAttributes) {
321-
assert(getOptionValue('--experimental-require-module'));
322-
323321
const parsed = URLParse(specifier);
324322
if (parsed != null) {
325323
const protocol = parsed.protocol;
@@ -338,6 +336,9 @@ class ModuleLoader {
338336
}
339337

340338
const { url, format } = resolveResult;
339+
if (!getOptionValue('--experimental-require-module')) {
340+
throw new ERR_REQUIRE_ESM(url, true);
341+
}
341342
const resolvedImportAttributes = resolveResult.importAttributes ?? importAttributes;
342343
let job = this.loadCache.get(url, resolvedImportAttributes.type);
343344
if (job !== undefined) {

0 commit comments

Comments
 (0)