1// something.js
2
3export const hi = (name) => console.log(`Hi, ${name}!`)
4export const bye = (name) => console.log(`Bye, ${name}!`)
5export default () => console.log('Hello World!')
6
7We can use import() syntax to easily and cleanly load it conditionally:
8// other-file.js
9
10if (somethingIsTrue) {
11 import('./something.js').then((module) => {
12 // Use the module the way you want, as:
13 module.hi('Erick') // Named export
14 module.bye('Erick') // Named export
15 module.default() // Default export
16 })
17}