Dynamic import module from url.
npm install import-dynamic
import importDynamic from 'import-dynamic'
const fn = await importDynamic('https://url-of-module', {
fetchOptions: { // fetch options
method: 'GET',
},
globals: { // global values
globalValue: 1,
},
})
fn()
- fetchOptions: An object containing any custom settings that you want to apply to the request. MDN Link
- globals: An object containing global values.