We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
ERR_REQUIRE_ESM
ERR_INTERNAL_ASSERTION
1 parent d1331fc commit 4813a6aCopy full SHA for 4813a6a
lib/internal/modules/esm/loader.js
@@ -318,8 +318,6 @@ class ModuleLoader {
318
* @returns {ModuleJobBase}
319
*/
320
getModuleJobForRequire(specifier, parentURL, importAttributes) {
321
- assert(getOptionValue('--experimental-require-module'));
322
-
323
const parsed = URLParse(specifier);
324
if (parsed != null) {
325
const protocol = parsed.protocol;
@@ -338,6 +336,9 @@ class ModuleLoader {
338
336
}
339
337
340
const { url, format } = resolveResult;
+ if (!getOptionValue('--experimental-require-module')) {
+ throw new ERR_REQUIRE_ESM(url, true);
341
+ }
342
const resolvedImportAttributes = resolveResult.importAttributes ?? importAttributes;
343
let job = this.loadCache.get(url, resolvedImportAttributes.type);
344
if (job !== undefined) {
0 commit comments