{"id":22564,"library":"vite-import-maps","title":"vite-import-maps","description":"Vite plugin that generates and manages browser import maps for shared dependencies in Vite applications, targeting micro-frontends, plugin systems, and runtime ESM loading. Current stable version is 0.2.6, with monthly patch releases. Key differentiators: supports CommonJS modules via static analysis, injects import map directly into HTML or emits as a standalone file, provides Subresource Integrity (SRI) hashes, and handles both npm packages and local entry modules. Requires Vite >=6.0.0, rollup >=4.0.0, or rolldown >=1.0.0-rc.0. Renamed from 'vite-plugin-native-import-maps' in v0.2.0.","status":"active","version":"0.2.6","language":"javascript","source_language":"en","source_url":"https://github.com/riccardoperra/vite-import-maps","tags":["javascript","vite","vite-plugin","import-maps","mfe","import maps","microfrontend","plugin","typescript"],"install":[{"cmd":"npm install vite-import-maps","lang":"bash","label":"npm"},{"cmd":"yarn add vite-import-maps","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-import-maps","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core peer dependency; plugin relies on Vite's plugin API and hooks.","package":"vite","optional":false},{"reason":"Required for build-time module resolution (rollup is Vite's bundler for production builds).","package":"rollup","optional":true},{"reason":"Alternative bundler peer dependency for build-time module resolution (used by Vite 7+).","package":"rolldown","optional":true}],"imports":[{"note":"Named export, not default. Named export was renamed from 'vitePluginNativeImportMaps' in v0.2.0.","wrong":"import viteImportMaps from 'vite-import-maps'","symbol":"viteImportMaps","correct":"import { viteImportMaps } from 'vite-import-maps'"},{"note":"Since v0.2.0, a default export is also available; both work. However, the named export is recommended for explicit usage.","wrong":"import { viteImportMaps } from 'vite-import-maps'","symbol":"viteImportMaps (default)","correct":"import viteImportMaps from 'vite-import-maps'"},{"note":"Type-only import to avoid runtime inclusion.","wrong":"import { PluginOptions } from 'vite-import-maps'","symbol":"Types (PluginOptions)","correct":"import type { PluginOptions } from 'vite-import-maps'"},{"note":"CJS requires destructuring because the package exports both named and default. This works if your project uses CJS.","wrong":"const viteImportMaps = require('vite-import-maps')","symbol":"CommonJS require","correct":"const { viteImportMaps } = require('vite-import-maps')"},{"note":"The plugin was renamed in v0.2.0. Old import path 'vite-plugin-native-import-maps' no longer exists; use 'vite-import-maps'.","wrong":"import { vitePluginNativeImportMaps } from 'vite-plugin-native-import-maps'","symbol":"Old named export (deprecated)","correct":"import { vitePluginNativeImportMaps } from 'vite-import-maps'"},{"note":"The virtual module is provided by the plugin; no file path needed. Use when injectImportMapsToHtml is false.","wrong":"import importMap from 'vite-import-maps/virtual:importmap'","symbol":"Virtual module","correct":"import importMap from 'virtual:importmap'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { viteImportMaps } from 'vite-import-maps';\n\nexport default defineConfig({\n  plugins: [\n    viteImportMaps({\n      imports: ['react', 'react-dom'],\n      integrity: 'sha384',\n      log: true,\n    }),\n  ],\n});","lang":"typescript","description":"Sets up vite-import-maps to expose 'react' and 'react-dom' via browser import maps with SRI integrity and logging enabled."},"warnings":[{"fix":"Update package name to 'vite-import-maps' and import { viteImportMaps } instead of { vitePluginNativeImportMaps }.","message":"In v0.2.0, the plugin was renamed from 'vite-plugin-native-import-maps' to 'vite-import-maps' and the main export was renamed from 'vitePluginNativeImportMaps' to 'viteImportMaps'.","severity":"breaking","affected_versions":"<0.2.0"},{"fix":"Upgrade Vite to version 6.0.0 or later. For Vite 5 projects, stay on an older version or use a different plugin.","message":"Requires Vite >=6.0.0 (or Vite 7/8) as a peer dependency. Older Vite versions are not supported.","severity":"breaking","affected_versions":">=0.2.6"},{"fix":"Monitor changelog for updates; alternative: use 'injectImportMapsToHtml: false' and import the virtual module.","message":"The 'outputAsFile' option may change in future versions. It is currently stable but not guaranteed to remain.","severity":"deprecated","affected_versions":">=0.2.0"},{"fix":"Ensure CJS modules have stable named exports. For problematic modules, use a custom entry with explicit export mapping.","message":"CommonJS module resolution uses static analysis via node/cjs-module-lexer; some CJS modules may not be detected correctly if they have side effects or dynamic exports.","severity":"gotcha","affected_versions":">=0.2.4"},{"fix":"Add <script type=\"importmap\">{{importMapContent}}</script> to your HTML template.","message":"When 'injectImportMapsToHtml' is false, you must manually import the virtual module 'virtual:importmap' and inject the script tag yourself.","severity":"gotcha","affected_versions":">=0.2.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run 'npm install vite-import-maps --save-dev' and update imports to use 'vite-import-maps'.","cause":"Package was renamed to 'vite-import-maps' in v0.2.0.","error":"Error: Cannot find module 'vite-plugin-native-import-maps'"},{"fix":"Change import to '{ viteImportMaps }' from 'vite-import-maps'.","cause":"Export renamed to 'viteImportMaps' in v0.2.0.","error":"TypeError: vitePluginNativeImportMaps is not a function"},{"fix":"Ensure entries in the 'imports' array are valid strings or objects with 'name' and 'entry' properties.","cause":"Improperly formatted import map entries; likely a custom entry with invalid JSON.","error":"Error: Unexpected token on import map JSON (e.g., missing quotes)"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}