mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
15 lines
383 B
JavaScript
15 lines
383 B
JavaScript
// Import the dynamic import helper
|
|
import importESM from './import-esm.js'
|
|
|
|
export default async (modPath) => {
|
|
try {
|
|
return await import(modPath)
|
|
} catch (error) {
|
|
// Fallback to import() if the runtime supports native ESM and throws specific error
|
|
if (error.code === 'ERR_REQUIRE_ESM') {
|
|
return (await importESM(modPath)).default
|
|
}
|
|
throw error
|
|
}
|
|
}
|