Registry / devops / vite-plugin-importmap

vite-plugin-importmap

JSON →
library0.1.1jsnpmunverified

Vite plugin (v0.1.1) that enables import map-like path resolution by environment variable (mark). Allows conditional module replacement per build target using string suffix conventions, arrays, or JSON config files. Unlike standard Vite resolve aliases, it switches between file variants based on a single mark. Minimal API surface, ESM-only, ships TypeScript definitions. Release cadence is low; single maintainer. Suitable for multi-tenant or configurable builds.

npm install vite-plugin-importmap
INSTALL
IMPORT
SIG · VITE-PLUGIN-IMPORT
V
vite-plugin-importmap
devopsjavascriptv0.1.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

importmap
import importmap from 'vite-plugin-importmap'
const importmap = require('vite-plugin-importmap')
Default export; ESM-only. CJS require() will fail.

Configures vite-plugin-importmap with an environment-based 'mark' to switch resolved file variants.

// vite.config.js import { defineConfig } from 'vite'; import importmap from 'vite-plugin-importmap'; const mark = process.env.VITE_OPEN_TYPE ?? 'v1'; export default defineConfig({ plugins: [importmap(mark)] });
Debug
Known issues
gotchamark must be set at build time; missing env variable reverts to original import path without transformation.
fix
Set VITE_OPEN_TYPE environment variable or pass a string directly to importmap().
affects: >=0.0.0
gotchaPlugin does not support dynamic imports or import() expressions; only static import/require statements are transformed.
fix
Use static imports; avoid dynamic import() for variant switching.
affects: >=0.0.0
gotchaFile resolution relies on exact suffixes; mismatched naming conventions (e.g., case sensitivity) will not be resolved.
fix
Ensure file variants match the pattern: baseName.<variant>.ext for string mode, or baseName[v1,v2].ext for array mode.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: importmap is not a function
Using CommonJS require() instead of ESM import.
fix
Change to `import importmap from 'vite-plugin-importmap'` and ensure vite.config.js uses ESM or type: module in package.json.
[vite] The plugin 'vite-plugin-importmap' didn't output a plugin object.
Calling importmap() without parentheses or passing invalid argument.
fix
Call `importmap(mark)` with a string argument; e.g., `importmap('v1')`.
Module not found: Can't resolve 'test.v1.js'
mark is set but no matching file variant exists (e.g., test.v1.js not found).
fix
Ensure the variant file exists with the correct naming pattern (e.g., test.v1.js) or adjust the mark value.
Upgrade
Version history
0.1.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
OpenAI (training)
1
Resources
vite-plugin-importmap — npm install vite-plugin-importmap · libregistry