mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
esm: throw ERR_REQUIRE_ESM instead of ERR_INTERNAL_ASSERTION
PR-URL: https://github.com/nodejs/node/pull/54868 Backport-PR-URL: https://github.com/nodejs/node/pull/56927 Fixes: https://github.com/nodejs/node/issues/54773 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Refs: https://github.com/nodejs/node/issues/52697
This commit is contained in:
1 parent
d1331fccb2
commit
4813a6a66c
1 file changed
+3
-2
@@ -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;
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user