Last active
August 8, 2021 19:56
-
-
Save WebReflection/2da6e7386fcd37f6d8dc1de3b321779c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ES2017 Asynchronous Export | |
// module.js | |
export default new Promise(async $export => { | |
const module = await Promise.resolve( | |
{my: 'module'} | |
); | |
$export(module); | |
}); | |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
// ES2015 consumer | |
import module from './module.js'; | |
module.then(exports => { | |
// will log "module" | |
console.log(exports.my); | |
}); | |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
// ES2017 consumer | |
(async () => { | |
const module = await ( | |
await import('./module.js') | |
).default; | |
})(); | |
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - | |
// ES2017 consumer and exporter | |
export default new Promise(async $export => { | |
const module = await ( | |
await import('./module.js') | |
).default; | |
$export({module, method(){}}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment