{"id":25320,"library":"esbuild-plugin-cache","title":"esbuild-plugin-cache","description":"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.","status":"active","version":"0.2.10","language":"javascript","source_language":"en","source_url":"https://github.com/dalcib/esbuild-plugin-deno-cache","tags":["javascript","esbuild","deno","cache","typescript"],"install":[{"cmd":"npm install esbuild-plugin-cache","lang":"bash","label":"npm"},{"cmd":"yarn add esbuild-plugin-cache","lang":"bash","label":"yarn"},{"cmd":"pnpm add esbuild-plugin-cache","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin operates as an esbuild plugin","package":"esbuild","optional":false}],"imports":[{"note":"Package is ESM-only; named export, no default export.","wrong":"const cache = require('esbuild-plugin-cache')","symbol":"cache","correct":"import { cache } from 'esbuild-plugin-cache'"},{"note":"Not a default export; must use named import.","wrong":"import cache from 'esbuild-plugin-cache'","symbol":"cache","correct":"import { cache } from 'esbuild-plugin-cache'"},{"note":"TypeScript type exported; use import type for type-only usage.","wrong":"","symbol":"type CacheConfig","correct":"import type { CacheConfig } from 'esbuild-plugin-cache'"}],"quickstart":{"code":"import esbuild from 'esbuild';\nimport { cache } from 'esbuild-plugin-cache';\n\nconst importmap = {\n  imports: {\n    react: 'https://cdn.skypack.dev/react@17.0.1',\n  },\n};\n\nawait esbuild.build({\n  entryPoints: ['index.js'],\n  bundle: true,\n  outfile: 'bundle.js',\n  plugins: [cache({ importmap, directory: './cache' })],\n});\n\nconsole.log('Bundled successfully');","lang":"typescript","description":"Bundles a JavaScript module that imports from a Skypack URL, using an import-map and custom cache directory."},"warnings":[{"fix":"Set directory option or ensure DENO_DIR environment variable points to a writable path.","message":"The plugin caches HTTP responses in a directory. Ensure the cache directory is writable and has enough space.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use import syntax or ensure project is configured for ESM.","message":"Package is ESM-only; does not support CommonJS require().","severity":"breaking","affected_versions":">=0.2.0"},{"fix":"Upgrade to >=0.2.1 and use the importmap option as shown in README.","message":"Version 0.2.1 introduced importmap config; earlier versions had different API.","severity":"deprecated","affected_versions":"<0.2.1"},{"fix":"Use absolute paths if needed.","message":"The directory option is relative to the current working directory, not the esbuild config.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Manually clear the cache directory to force re-fetch.","message":"HTTPS imports are cached indefinitely; no TTL or cache invalidation built-in.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'npm install esbuild-plugin-cache' or 'deno add esbuild-plugin-cache'.","cause":"Package not installed or not found.","error":"Error: Cannot find module 'esbuild-plugin-cache'"},{"fix":"Use 'import { cache } from \"esbuild-plugin-cache\"'.","cause":"Incorrect import style (default import instead of named).","error":"TypeError: cache is not a function"},{"fix":"Call cache() with or without options: cache() or cache({}) or cache({importmap, directory}).","cause":"Calling cache() without arguments or with non-object argument in some versions.","error":"Error: The plugin 'cache' must be passed an object with optional props"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}