Skip to content

Instantly share code, notes, and snippets.

@dbauszus-glx
Created August 22, 2022 07:43
Show Gist options
  • Save dbauszus-glx/e7397406aba43876079a13878729bf0e to your computer and use it in GitHub Desktop.
Save dbauszus-glx/e7397406aba43876079a13878729bf0e to your computer and use it in GitHub Desktop.
export default plugins => {
if (!Array.isArray(plugins)) return;
return new Promise(resolveAll=>{
const promises = plugins.map(
plugin =>
new Promise((resolve, reject) =>
import(plugin)
.then(mod=> {
resolve(mod)
})
.catch(reject)))
Promise
.all(promises)
.then(mods=>{
resolveAll(mods)
})
.catch(resolveAll)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment