Skip to content

Instantly share code, notes, and snippets.

@Maxondria
Forked from WebReflection/export-await.js
Created February 20, 2022 10:31
Show Gist options
  • Save Maxondria/1921c400d4000b78f8460b2114e503d8 to your computer and use it in GitHub Desktop.
Save Maxondria/1921c400d4000b78f8460b2114e503d8 to your computer and use it in GitHub Desktop.
// keeping the same pattern
export default await new Promise(async $export => {
// export the module
$export({my: 'module'});
});
// dropping the Promise all together
export default await (async () => {
// await async dependencies
// export the module
return {my: 'module'};
})();
// both static and dynamic importers will work
import module from './module.js';
// or
import('./module.js').then(m => {
const module = m.default;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment