# esbuild-plugin-cache

> Esbuid plugin to use cache for http/https

Latest version **0.2.10** (published 2022-11-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install esbuild-plugin-cache
pnpm add esbuild-plugin-cache
yarn add esbuild-plugin-cache
bun add esbuild-plugin-cache
```

## Health

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

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

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.10 |
| Published | 2022-11-23 |
| First published | 2021-01-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 442.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 46 |
| Author | Dalci de Jesus Bagolin |
| Maintainers | dalcib |
| Keywords | esbuild, deno, cache |

## Links

- npm: https://www.npmjs.com/package/esbuild-plugin-cache
- Repository: https://github.com/dalcib/esbuild-plugin-deno-cache
- Homepage: https://github.com/dalcib/esbuild-plugin-cache#readme
- Issues: https://github.com/dalcib/esbuild-plugin-cache/issues
- npm.io page: https://npm.io/package/esbuild-plugin-cache

## Dependencies (2)

- [deno-cache](https://npm.io/package/deno-cache.md) ^0.2.12
- [deno-importmap](https://npm.io/package/deno-importmap.md) ^0.1.6

## 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

- 0.2.10 (latest) — 2022-11-23
- 0.2.9 — 2021-06-10
- 0.2.8 — 2021-05-21
- 0.2.7 — 2021-05-21
- 0.2.6 — 2021-05-02
- 0.2.5 — 2021-04-13
- 0.2.4 — 2021-04-13
- 0.2.3 — 2021-04-13
- 0.2.2 — 2021-04-13
- 0.2.1 — 2021-01-15
- 0.2.0 — 2021-01-08

## README

# esbuild-plugin-cache

### Esbuid plugin to cache http/https imports.

The plugin allows to use http/https imports without installing npm packages on node_modules.

It also allows to use [import-maps](https://github.com/WICG/import-maps) .

It can provide a feature similar to Snowpack 3.0, the new [Streaming NPM Imports](https://www.snowpack.dev/posts/2020-12-03-snowpack-3-release-candidate), which allows to skip the NPM install and node_modules.

```javascript
//index.js
import React from 'https://cdn.skypack.dev/react@17.0.1'
console.log(React.version)
```

#### Build script:

```javascript
//build.js
import esbuild from 'esbuild'
import { cache } from 'esbuild-plugin-cache'

esbuild
  .build({
    entryPoints: ['index.js'],
    bundle: true,
    outfile: 'bundle.js',
    plugins: [cache()],
  })
  .catch(() => process.exit(1))
```

#### Config:

`config: {importmap: {imports:{[key: string]: string}}, directory: string}`

- `importmap`: Import-map object. Default: `{}`

- `directory`: Path or name for the directory of the cache. Default to Deno cache directory. Optionally the cache directory can be defined with DENO_DIR env variable: `process.env.DENO_DIR = 'cache'`.

#### Using with `importmap`

```javascript
//index.js
import React from 'react'
console.log(React.version)
```

```javascript
//build.js
import esbuild from 'esbuild'
import { cache } from 'esbuild-plugin-cache'

const importmap = {
  imports: {
    react: 'https://cdn.skypack.dev/react@17.0.1',
  },
}

esbuild
  .build({
    entryPoints: ['index.js'],
    bundle: true,
    outfile: 'bundle.js',
    plugins: [cache({ importmap, directory: './cache' })],
  })
  .catch(() => process.exit(1))
```

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