Skip to content

Commit

Permalink
fix: Push adapter not loading on some versions of Node 22 (#9524)
Browse files Browse the repository at this point in the history
  • Loading branch information
dblythy authored Jan 11, 2025
1 parent 93b2bb7 commit ff7f671
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/Adapters/AdapterLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,8 @@ export function loadAdapter<T>(adapter, defaultAdapter, options): T {
}

export async function loadModule(modulePath) {
let module;
try {
module = require(modulePath);
} catch (err) {
if (err.code === 'ERR_REQUIRE_ESM') {
module = await import(modulePath);
if (module.default) {
module = module.default;
}
} else {
throw err;
}
}
return module;
const module = await import(modulePath);
return module?.default || module;
}

export default loadAdapter;

0 comments on commit ff7f671

Please sign in to comment.