fix: throw correct error when loading ESM with require
#11260
+28
−6
Merged
require
#11260