What is the problem this feature will solve?
/** @type {Plugin[]} */
let plugins
try {
plugins = dependencies.map(pkgName => {
/** @type {Plugin} */
const pkg = require(pkgName)
return pkg.default || pkg
})
} catch {
plugins = await Promise.all(
dependencies.map(async pkgName => {
/** @type {Plugin} */
const pkg = await import(pkgName)
return pkg.default || pkg
}),
)
}
What is the feature you are proposing to solve the problem?
I'd like to use require(ESM) when possible but fallback to top await when it fails.
What alternatives have you considered?
N/A