Registry / devops / esbuild-plugin-cache

esbuild-plugin-cache

JSON →
library0.2.10jsnpmunverified

An esbuild plugin to cache HTTP/HTTPS imports, enabling bundling of URLs from CDNs like Skypack without npm install or node_modules. Current stable version 0.2.10, released irregularly. Supports import-maps and Deno-style caching (DENO_DIR). Differentiates from Snowpack's Streaming NPM Imports by integrating directly with esbuild, and works in both Node.js and Deno.

npm install esbuild-plugin-cache
INSTALL
IMPORT
SIG · ESBUILD-PLUGIN-CAC
E
esbuild-plugin-cache
devopsjavascriptv0.2.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

cache
import { cache } from 'esbuild-plugin-cache'
const cache = require('esbuild-plugin-cache')
Package is ESM-only; named export, no default export.
cache
import { cache } from 'esbuild-plugin-cache'
import cache from 'esbuild-plugin-cache'
Not a default export; must use named import.
type CacheConfig
import type { CacheConfig } from 'esbuild-plugin-cache'
TypeScript type exported; use import type for type-only usage.

Bundles a JavaScript module that imports from a Skypack URL, using an import-map and custom cache directory.

import esbuild from 'esbuild'; import { cache } from 'esbuild-plugin-cache'; const importmap = { imports: { react: 'https://cdn.skypack.dev/react@17.0.1', }, }; await esbuild.build({ entryPoints: ['index.js'], bundle: true, outfile: 'bundle.js', plugins: [cache({ importmap, directory: './cache' })], }); console.log('Bundled successfully');
Debug
Known issues
gotchaThe plugin caches HTTP responses in a directory. Ensure the cache directory is writable and has enough space.
fix
Set directory option or ensure DENO_DIR environment variable points to a writable path.
affects: >=0.1.0
breakingPackage is ESM-only; does not support CommonJS require().
fix
Use import syntax or ensure project is configured for ESM.
affects: >=0.2.0
deprecatedVersion 0.2.1 introduced importmap config; earlier versions had different API.
fix
Upgrade to >=0.2.1 and use the importmap option as shown in README.
affects: <0.2.1
gotchaThe directory option is relative to the current working directory, not the esbuild config.
fix
Use absolute paths if needed.
affects: >=0.1.0
gotchaHTTPS imports are cached indefinitely; no TTL or cache invalidation built-in.
fix
Manually clear the cache directory to force re-fetch.
affects: >=0.1.0
Errors
Common errors & fixes
Error: Cannot find module 'esbuild-plugin-cache'
Package not installed or not found.
fix
Run 'npm install esbuild-plugin-cache' or 'deno add esbuild-plugin-cache'.
TypeError: cache is not a function
Incorrect import style (default import instead of named).
fix
Use 'import { cache } from "esbuild-plugin-cache"'.
Error: The plugin 'cache' must be passed an object with optional props
Calling cache() without arguments or with non-object argument in some versions.
fix
Call cache() with or without options: cache() or cache({}) or cache({importmap, directory}).
Upgrade
Version history
0.2.10latest on npm
Audit
Dependencies
esbuildrequiredpeer dependency; plugin operates as an esbuild plugin
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
esbuild-plugin-cache — npm install esbuild-plugin-cache · libregistry