Example of JavaScript Module
Import specific export
import { FruitType, Fruit, tell } from './TestModule.js'
Import everythong
import * from './TestModule.js'
Rename import
import { tell as show } from './TestModule.js'
Import As Module
import * as TestModule from './TestModule.js'TestModule.tell('Apple')
or
import TestModule from './TestModule.js'
Dynamic Loading
import('./TestModule.js') .then((module) => { module.tell('Apple') })
or
let TestModule = await import('./TestModule.js')
Import defaults
import { FruitType, Fruit, tell } from './TestModule.js'
or
import myDefault, * as myModule from '/modules/my-module.js'
or
import myDefault, {foo, bar} from '/modules/my-module.js'
or
// dynamic importconst { default: myDefault, foo, bar } = await import('/modules/my-module.js')
References: