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 <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> 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

Lines changed: 3 additions & 2 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy