Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 1.16 KB

README.md

File metadata and controls

32 lines (22 loc) · 1.16 KB

Dynamic import worker npm package github main codecov coverage

Bypass node cache on dynamic import thanks to worker

Example

docs/demo/random_number.mjs

export const randomNumber = Math.random()

docs/demo/demo.mjs

import { importOneExportFromFile } from "@jsenv/dynamic-import-worker"

const randomNumberFileUrl = new URL("./random_number.mjs", import.meta.url)
const randomNumberExportUrl = `${randomNumberFileUrl}#randomNumber`

const randomNumberA = await importOneExportFromFile(randomNumberExportUrl)
const randomNumberB = await importOneExportFromFile(randomNumberExportUrl)

console.log(randomNumberA)
console.log(randomNumberB)
> node ./docs/demo/demo.mjs
0.5362418125287491
0.35129949391010595