Skip to content

jsenv/dynamic-import-worker

Repository files navigation

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

About

Bypass node cache on dynamic import thanks to worker

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published