Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4813a6a

Browse filesBrowse 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
Copy full SHA for 4813a6a

File tree

1 file changed

+3
-2
lines changed
Filter options

1 file changed

+3
-2
lines changed

‎lib/internal/modules/esm/loader.js

Copy file name to clipboardExpand all lines: lib/internal/modules/esm/loader.js
+3-2Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.