@builder.io/vite-plugin-jsx-loc
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

vite-plugin-jsx-loc

A Vite plugin that adds location data attributes to JSX elements for debugging and development purposes.

Installation

npm install @builder.io/vite-plugin-jsx-loc
# or
yarn add @builder.io/vite-plugin-jsx-loc
# or
pnpm add @builder.io/vite-plugin-jsx-loc

Usage

Add the plugin to your vite.config.ts:

import { defineConfig } from 'vite';
import { jsxLocPlugin } from '@builder.io/vite-plugin-jsx-loc';

export default defineConfig({
  plugins: [jsxLocPlugin()],
});

This will add a data-loc attribute to all JSX elements in your code, containing the relative file path and line number where the element is defined. For example:

// Input: src/components/Button.tsx
export function Button() {
  return <button>Click me</button>;
}

// Output (during development):
export function Button() {
  return <button data-loc="src/components/Button.tsx:2">Click me</button>;
}

Features

  • Adds source location information to JSX elements
  • Works with both .jsx and .tsx files
  • Skips processing of node_modules
  • Preserves source maps
  • Minimal performance impact
  • No configuration required

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.1.150latest

Version History

VersionDownloads (Last 7 Days)Published
0.1.150
0.1.09,417

Package Sidebar

Install

npm i @builder.io/vite-plugin-jsx-loc

Weekly Downloads

9,467

Version

0.1.1

License

none

Unpacked Size

3.73 kB

Total Files

6

Last publish

Collaborators

  • steve8708
  • samijaber
  • teleaziz123
  • mrkoreye
  • strd6
  • mhevery
  • adamdbradley
  • gustavohgs
  • manucorporat
  • shyam-builder
  • sanyamkamat
  • harmeet.builder
  • midhunadarvin
  • kylefowler
  • builderio-bot
  • armela
  • anaghavarhade
  • sidmohanty11
  • yash-wadhia-builder
  • paprikaf
  • clyde-builderio