mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
15 lines
366 B
JavaScript
15 lines
366 B
JavaScript
'use strict';
|
|
|
|
module.exports = async (modPath) => {
|
|
try {
|
|
const mod = require(modPath);
|
|
return mod && mod.default ? mod.default : mod;
|
|
} catch (error) {
|
|
// Fallback to import() if the runtime supports native ESM
|
|
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
return (await require('./import-esm')(modPath)).default;
|
|
}
|
|
throw error;
|
|
}
|
|
};
|