# dynamic-import-no-cache

> dynamic import with no caching

Latest version **1.0.3** (published 2022-07-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install dynamic-import-no-cache
pnpm add dynamic-import-no-cache
yarn add dynamic-import-no-cache
bun add dynamic-import-no-cache
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2022-07-04 |
| First published | 2022-06-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 1.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Paul Browne |
| Maintainers | paul-browne |
| Keywords | dynamic, import, cache |

## Links

- npm: https://www.npmjs.com/package/dynamic-import-no-cache
- npm.io page: https://npm.io/package/dynamic-import-no-cache

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2022-07-04
- 1.0.2 — 2022-06-30
- 1.0.1 — 2022-06-30
- 1.0.0 — 2022-06-30

## README

# dynamic-import-no-cache

according to [ECMAScript](https://tc39.es/ecma262/#sec-hostimportmoduledynamically), 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.

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

```js
import dinc from "dynamic-import-no-cache";

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

alternatively, if you don't want to install yet another node package, you can just do:

```js
const someResource = await import(`/path/to/resource.js?${Date.now()}`);
```

---
_Source: https://npm.io/package/dynamic-import-no-cache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
