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.
npm install vite-import-mapsVerified import paths — ran on the pinned version, not inferred.
Sets up vite-import-maps to expose 'react' and 'react-dom' via browser import maps with SRI integrity and logging enabled.
Update package name to 'vite-import-maps' and import { viteImportMaps } instead of { vitePluginNativeImportMaps }.Upgrade Vite to version 6.0.0 or later. For Vite 5 projects, stay on an older version or use a different plugin.
Monitor changelog for updates; alternative: use 'injectImportMapsToHtml: false' and import the virtual module.
Ensure CJS modules have stable named exports. For problematic modules, use a custom entry with explicit export mapping.
Add <script type="importmap">{{importMapContent}}</script> to your HTML template.Run 'npm install vite-import-maps --save-dev' and update imports to use 'vite-import-maps'.
Change import to '{ viteImportMaps }' from 'vite-import-maps'.Ensure entries in the 'imports' array are valid strings or objects with 'name' and 'entry' properties.