{"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,"search_vec":"'0.2.6':34 '1.0.0':80 '4.0.0':77 '6.0.0':75 'analysi':46 'applic':19 'browser':11 'commonj':42 'current':30 'depend':16 'differenti':40 'direct':50 'emit':54 'entri':71 'esm':28 'file':58 'frontend':23 'generat':8 'handl':65 'hash':63 'html':52 'import':3,12,48,88,98,101 'import-map':97 'inject':47 'integr':61 'javascript':92 'key':39 'load':29 'local':70 'manag':10 'map':4,13,49,89,99,102 'mfe':100 'micro':22 'micro-frontend':21 'microfrontend':103 'modul':43,72 'month':36 'nativ':87 'npm':67 'packag':68 'patch':37 'plugin':6,24,86,96,104 'provid':59 'rc.0':81 'releas':38 'renam':82 'requir':73 'rolldown':79 'rollup':76 'runtim':27 'share':15 'sri':62 'stabl':31 'standalon':57 'static':45 'subresourc':60 'support':41 'system':25 'target':20 'typescript':105 'v0.2.0':91 'version':32 'via':44 'vite':2,5,18,74,85,93,95 'vite-import-map':1 'vite-plugin':94 'vite-plugin-native-import-map':84","created_at":"2026-04-27T17:05:50.490250+00:00","updated_at":"2026-04-27T17:05:50.490250+00:00","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,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":null,"github":"https://github.com/riccardoperra/vite-import-maps","docs":null,"changelog":null,"pypi":null,"npm":"https://www.npmjs.com/package/vite-import-maps","openapi_spec":null,"status_page":null,"smithery":null,"categories":["web-framework","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-18","next_check":"2026-07-26","install_tag":null}}