fix: Push adapter not loading on some versions of Node 22 (#9524)

This commit is contained in:
Daniel
2025-01-12 05:01:28 +11:00
committed by GitHub
parent 93b2bb7d77
commit ff7f671c79

View File

@@ -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;