mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
14 lines
306 B
JavaScript
14 lines
306 B
JavaScript
'use strict';
|
|
|
|
module.exports = async (modPath) => {
|
|
try {
|
|
return require(modPath);
|
|
} catch (error) {
|
|
// Fallback to import() if the runtime supports native ESM
|
|
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
return (await import(`file:///${modPath}`)).default;
|
|
}
|
|
throw error;
|
|
}
|
|
};
|