dyim

1.0.0 • Public • Published

dyim

according to ECMAScript, the contents of dynamic imports are cached by default.

Any subsequent call to [import()] given the arguments referencingScriptOrModule and specifier, must return [...] a module which has already been evaluated

which means if you are using a dynamic import as part of your build process (eg. using chokidar to execute a function when a file is changed/added/deleted), then await import("/path/to/resource.js") will not fetch the updated version, rather the (cached) version that was fetched the first time that call was made.

dyim solves this by adding a cache busting timestamp param to the request, forcing node to fetch the fresh contents.

import dyim from "dyim";

const someResource = await dyim("/path/to/resource.js", {
    cache: false
})

or, to make dyim behave just like a normal dynamic import

import dyim from "dyim";

const someResource = await dyim("/path/to/resource.js");

Readme

Keywords

Package Sidebar

Install

npm i dyim

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

1.68 kB

Total Files

3

Last publish

Collaborators

  • paul-browne