vite-plugin-jsx-source-attrs

JSON →
library 0.2.1 ·javascript
verified Jun 4, 2026

A Vite/Babel plugin for injecting source location attributes into JSX elements during React development. Current stable version: 0.2.1. This package extracts and centralizes the pattern originally scattered across multiple Analytics MFE projects using @wix/babel-plugin-jsx-source-attrs. It adds data-source-location (intrinsic elements) and data-component-source-location (custom components) attributes, with support for disabling in production, deduplication of existing attributes, path normalization (query/hash removal, virtual module prefixes, OS path separators), and TypeScript types. Unlike ad-hoc Babel plugin configurations, this offers a unified Vite plugin interface with simple options (enabled, attributeName, componentAttributeName). Requires @babel/core >=7.20.0 as a peer dependency. Dev-only dependency for build time; production builds must include devDependencies during CI.