Cweili / import-dynamic

Dynamic import module from url

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Import Dynamic

Dynamic import module from url.

Installation

npm install import-dynamic

Usage

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.

About

Dynamic import module from url


Languages

Language:JavaScript 100.0%