Registry /
web-framework / vite-plugin-source-identifier
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
muslnode 18–223 runs
build_error
glibcnode 18–223 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
sourceIdentifierPlugin
✓ import { sourceIdentifierPlugin } from 'vite-plugin-source-identifier'
✗ import sourceIdentifierPlugin from 'vite-plugin-source-identifier'
This is a named export, not default. Common mistake to use default import.
SourceIdentifierOptions
✓ import type { SourceIdentifierOptions } from 'vite-plugin-source-identifier'
✗ import { SourceIdentifierOptions } from 'vite-plugin-source-identifier'
TypeScript type-only import to avoid emitting runtime code.
Plugin usage in vite.config.ts
✓ import { sourceIdentifierPlugin } from 'vite-plugin-source-identifier';
export default defineConfig({ plugins: [sourceIdentifierPlugin()] })
✗ import sourceIdentifierPlugin from 'vite-plugin-source-identifier';
export default defineConfig({ plugins: [sourceIdentifierPlugin()] })
As above, named export must be used. Also do not forget to call the function.
Basic setup with React. Add the plugin before or after framework plugin, then inspect DOM elements in dev tools.
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { sourceIdentifierPlugin } from 'vite-plugin-source-identifier'
export default defineConfig({
plugins: [
sourceIdentifierPlugin(),
react(),
],
})
// Then in any React component:
function Button({ text }: { text: string }) {
return <button>{text}</button>
}
// After dev, DOM will have:
// <button data-lov-id="src/Button.tsx:3:10" data-lov-name="button" ...>Hello</button>
Errors
Common errors & fixes
Error: "Unsupported file extension: .js"
Plugin does not process .js files by default (only .jsx, .tsx, .vue).
fixAdd '.js' to the `include` option: `include: ['.jsx', '.tsx', '.vue', '.js']`
TypeError: sourceIdentifierPlugin is not a function
Default import used instead of named import.
fixUse `import { sourceIdentifierPlugin } from 'vite-plugin-source-identifier';` then call `sourceIdentifierPlugin()`. Attribute "data-lov-id" not appearing on elements
Plugin not added to Vite config, or Vite is running in production mode.
fixAdd `sourceIdentifierPlugin()` to plugins array and ensure development mode.
Audit
Dependencies
viterequiredpeer dependency: plugin requires Vite >=5.0.0