Created
August 22, 2022 07:43
-
-
Save dbauszus-glx/e7397406aba43876079a13878729bf0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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