Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the ESM loader even if the loader.type wasn't properly set to "mo… #53

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/loadLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ module.exports = function loadLoader(loader, callback) {
try {
var module = require(loader.path);
} catch(e) {
// Sometimes the caller got it wrong and forgot to set up the loader.type.
if(!loader.type && e instanceof Error && e.code === "ERR_REQUIRE_ESM") {
const loaderWithType = Object.assign({}, loader);
loaderWithType.type = "module";
loadLoader(loaderWithType, callback);
return;
}
// it is possible for node to choke on a require if the FD descriptor
// limit has been reached. give it a chance to recover.
if(e instanceof Error && e.code === "EMFILE") {
Expand Down
Loading