{"id":46762,"library":"vite-plugin-long-term-cache-import-map","title":"vite-plugin-long-term-cache-import-map","description":"A Vite plugin enabling long-term caching of static assets (JS, CSS) using import maps. Version 0.2.6, actively maintained with weekly releases. Key differentiators: it generates and patches import maps to decouple file hashes from URLs, allowing aggressive caching without cache invalidation. Unlike standard Vite hashing, this plugin splits import map management into generator and patcher plugins, giving fine-grained control over entry points and chunk names. Useful for projects needing maximal cache hit rates, especially with large vendor chunks like monaco-editor.","status":"active","version":"0.2.6","language":"javascript","source_language":"en","source_url":"https://github.com/rawbin-/vite-plugin-long-term-cache-import-map","tags":["javascript","vite","rollup","plugin","template","typescript"],"install":[{"cmd":"npm install vite-plugin-long-term-cache-import-map","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-long-term-cache-import-map","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-long-term-cache-import-map","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; named export, not default.","wrong":"const importMapGeneratorPlugin = require('vite-plugin-long-term-cache-import-map')","symbol":"importMapGeneratorPlugin","correct":"import { importMapGeneratorPlugin } from 'vite-plugin-long-term-cache-import-map'"},{"note":"Named export, not default. Do not treat as default import.","wrong":"import importMapPatcherPlugin from 'vite-plugin-long-term-cache-import-map'","symbol":"importMapPatcherPlugin","correct":"import { importMapPatcherPlugin } from 'vite-plugin-long-term-cache-import-map'"},{"note":"TypeScript type export for generator options; use type import.","wrong":"const ImportMapGeneratorOptions = require('vite-plugin-long-term-cache-import-map').ImportMapGeneratorOptions","symbol":"ImportMapGeneratorOptions","correct":"import type { ImportMapGeneratorOptions } from 'vite-plugin-long-term-cache-import-map'"}],"quickstart":{"code":"import { defineConfig } from 'vite';\nimport Vue from '@vitejs/plugin-vue';\nimport { importMapGeneratorPlugin, importMapPatcherPlugin } from 'vite-plugin-long-term-cache-import-map';\n\nexport default defineConfig({\n  plugins: [\n    Vue(),\n    importMapGeneratorPlugin(),\n    importMapPatcherPlugin({ entryPath: '/assets/js/index.js' }),\n  ],\n  build: {\n    rollupOptions: {\n      output: {\n        entryFileNames: 'assets/js/[name].js',\n        chunkFileNames: 'assets/js/[name].js',\n        assetFileNames: (info) => {\n          if (info.name.endsWith('.css')) return 'assets/css/[name]-[hash].[ext]';\n          return 'assets/[ext]/[name].[ext]';\n        },\n        manualChunks: (id) => {\n          if (id.includes('node_modules')) {\n            if (id.includes('monaco-editor')) return 'vendor-monaco-editor';\n            if (id.includes('@codemirror')) return 'vendor-codemirror';\n            return 'vendor-common';\n          }\n          return 'main-all';\n        },\n      },\n    },\n  },\n});","lang":"typescript","description":"Configures Vite with import map caching plugins, generating and patching import maps for long-term cache."},"warnings":[{"fix":"Set output.entryFileNames and output.chunkFileNames without [hash] (e.g., 'assets/js/[name].js').","message":"Chunk filenames must NOT include hashes when using import map patcher; hashes are managed by the plugin.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Test all pages after adding manualChunks; ensure all entry points are covered by importMapPatcherPlugin options.","message":"Manual chunk splitting can cause white screen or JS errors if not thoroughly tested; the plugin's import map may not cover all chunks correctly.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Monitor GitHub for API updates; consider pinning version if stability is critical.","message":"Import map patcher configuration may change in future versions; current API uses entryPath string but might shift to more flexible options.","severity":"deprecated","affected_versions":"0.2.x"},{"fix":"Use assetFileNames function to add [hash] only for .css files (and other non-JS assets if needed).","message":"CSS assets must be named with hashes (e.g., [hash]) because import maps do not cover CSS; the example in README handles this conditionally.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.2.6':26 'activ':27 'aggress':47 'allow':46 'asset':19 'cach':6,16,48,50,83 'chunk':76,90 'control':71 'css':21 'decoupl':41 'differenti':33 'editor':94 'enabl':12 'entri':73 'especi':86 'file':42 'fine':69 'fine-grain':68 'generat':35,63 'give':67 'grain':70 'hash':43,55 'hit':84 'import':7,23,38,59 'invalid':51 'javascript':95 'js':20 'key':32 'larg':88 'like':91 'long':4,14 'long-term':13 'maintain':28 'manag':61 'map':8,24,39,60 'maxim':82 'monaco':93 'monaco-editor':92 'name':77 'need':81 'patch':37 'patcher':65 'plugin':3,11,57,66,98 'point':74 'project':80 'rate':85 'releas':31 'rollup':97 'split':58 'standard':53 'static':18 'templat':99 'term':5,15 'typescript':100 'unlik':52 'url':45 'use':22,78 'vendor':89 'version':25 'vite':2,10,54,96 'vite-plugin-long-term-cache-import-map':1 'week':30 'without':49","created_at":"2026-06-07T13:01:30.004179+00:00","updated_at":"2026-06-07T13:01:30.004179+00:00","problems":[{"fix":"Run `npm install vite-plugin-long-term-cache-import-map --save-dev` or equivalent for your package manager.","cause":"Missing or incorrect installation (npm vs pnpm vs yarn).","error":"Cannot find module 'vite-plugin-long-term-cache-import-map'"},{"fix":"Use `import { importMapGeneratorPlugin, importMapPatcherPlugin } from 'vite-plugin-long-term-cache-import-map'`.","cause":"Using default import instead of named imports.","error":"The requested module 'vite-plugin-long-term-cache-import-map' does not provide an export named 'default'"},{"fix":"Ensure correct named import: `import { importMapPatcherPlugin } from 'vite-plugin-long-term-cache-import-map'`.","cause":"Probably imported incorrectly (e.g., as default or misspelled).","error":"TypeError: importMapPatcherPlugin is not a function"},{"fix":"Pass object with `entryPath` property: `importMapPatcherPlugin({ entryPath: '/assets/js/index.js' })`.","cause":"importMapPatcherPlugin options missing or invalid entryPath.","error":"Error: entryPath must be a string"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/rawbin-/vite-plugin-long-term-cache-import-map#readme","github":"https://github.com/rawbin-/vite-plugin-long-term-cache-import-map","docs":null,"changelog":null,"pypi":null,"npm":"vite-plugin-long-term-cache-import-map","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}