Catalog npm
Back to packageRELEASE DETAILS

1.1.0

npm

@0xminds/component-tagger

Vite plugin for tagging React/JSX components with design mode metadata

0xmindscomponentdesign-modejsxpluginreacttaggervite
Published30 Nov 2025
Direct dependencies10
Transitive dependenciesNot calculated

README

Current package documentation

@0xminds/component-tagger

A Vite plugin that automatically adds metadata attributes to React/JSX components to enable Design Mode functionality in the 0xminds platform.

Features

✅ Automatic Component Tagging: Adds unique IDs to every JSX element ✅ File & Line Tracking: Tracks source file and line number for each component ✅ TypeScript Support: Full TypeScript support with type definitions ✅ Smart Filtering: Excludes node_modules, dist, and UI library components ✅ Development-Only: Automatically disabled in production builds ✅ Zero Runtime Overhead: Pure build-time transformation ✅ Source Maps: Preserves source maps for debugging

Installation

npm install @0xminds/component-tagger --save-dev

Usage

Basic Setup

Add the plugin to your vite.config.ts:

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { componentTagger } from '@0xminds/component-tagger';

export default defineConfig({
  plugins: [
    react(),
    componentTagger(), // Add this line
  ],
});

With Custom Options

import { componentTagger } from '@0xminds/component-tagger';

export default defineConfig({
  plugins: [
    react(),
    componentTagger({
      enabled: true,              // Force enable (default: auto-detect from mode)
      debug: true,                // Enable debug logging
      include: ['**/*.{jsx,tsx}'], // Files to process
      exclude: ['**/ui/**'],      // Files to exclude
      attributeName: 'data-0x-component-id', // Custom attribute name
    }),
  ],
});

How It Works

Before Transformation

function MyComponent() {
  return (
    <div className="container">
      <h1>Hello World</h1>
      <Button variant="primary">Click Me</Button>
    </div>
  );
}

After Transformation

function MyComponent() {
  return (
    <div
      data-0x-component-id="div_MyComponent_3_5"
      data-0x-file="src/components/MyComponent.tsx"
      data-0x-line="3"
      data-0x-column="5"
      data-0x-component="div"
      data-0x-content="children"
      className="container"
    >
      <h1
        data-0x-component-id="h1_MyComponent_4_7"
        data-0x-file="src/components/MyComponent.tsx"
        data-0x-line="4"
        data-0x-column="7"
        data-0x-component="h1"
        data-0x-content="static"
      >
        Hello World
      </h1>
      <Button
        data-0x-component-id="Button_MyComponent_5_7"
        data-0x-file="src/components/MyComponent.tsx"
        data-0x-line="5"
        data-0x-column="7"
        data-0x-component="Button"
        data-0x-content="static"
        variant="primary"
      >
        Click Me
      </Button>
    </div>
  );
}

Configuration Options

OptionTypeDefaultDescription
enabledbooleanautoEnable/disable the plugin (auto = dev only)
includestring[]['**/*.{jsx,tsx}']File patterns to include
excludestring[]['node_modules/**', 'dist/**', '**/ui/**']File patterns to exclude
attributeNamestring'data-0x-component-id'Main attribute name
includeFilePathbooleantrueAdd file path attribute
includeLineNumberbooleantrueAdd line number attribute
rootDirstringprocess.cwd()Root directory for relative paths
debugbooleanfalseEnable debug logging

Generated Attributes

Each tagged component receives the following attributes:

  • data-0x-component-id: Unique identifier (format: ComponentName_FileName_Line_Column)
  • data-0x-file: Relative file path from project root
  • data-0x-line: Line number in source file
  • data-0x-column: Column number in source file
  • data-0x-component: Component/element name
  • data-0x-content: Content type (static | dynamic | empty | children)

Content Types

TypeDescriptionExample
staticStatic text content<h1>Hello World</h1>
dynamicDynamic/variable content<h1>{title}</h1>
emptyNo text content<div /> or <img src="..." />
childrenContains child elements<div><span>...</span></div>

Use Cases

This plugin is designed for:

  • 🎨 Design Mode: Click-to-edit functionality in visual builders
  • 🔍 Component Inspector: Identify components in rendered output
  • 🐛 Debugging: Track component source locations
  • 📊 Analytics: Component usage tracking
  • 🧪 Testing: Element selection in E2E tests

Performance

  • Zero Runtime Impact: All transformations happen at build time
  • Smart Caching: Only processes changed files
  • Production Safe: Automatically disabled in production builds
  • Source Maps: Maintains accurate source maps for debugging

Compatibility

  • ✅ Vite 5.x and above
  • ✅ React 18+
  • ✅ TypeScript 5+
  • ✅ JSX/TSX files
  • ✅ All modern browsers

Troubleshooting

Plugin not working?

  1. Check that mode is set to 'development' in Vite config
  2. Verify file matches include patterns and not in exclude
  3. Enable debug: true to see transformation logs
  4. Check console for error messages

Attributes not appearing?

Make sure:

  • Plugin is listed before React plugin in Vite config
  • Files are not in excluded directories (node_modules, dist, ui)
  • Build cache is cleared: rm -rf node_modules/.vite

TypeScript errors?

Install type definitions:

npm install --save-dev @types/babel__core @types/babel__traverse

Examples

See the examples/ directory for complete working examples:

  • Basic React app
  • TypeScript project
  • shadcn/ui integration
  • Next.js (experimental)

Contributing

Contributions welcome! Please read CONTRIBUTING.md first.

License

MIT © 0xminds

Support


Made with ❤️ by the 0xminds team

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 10

Native requirements
10 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
@babel/parser
Environment
{
  "local_name": "@babel/parser",
  "alias": false,
  "peer_metadata": null
}
^7.25.9runtime
@babel/traverse
Environment
{
  "local_name": "@babel/traverse",
  "alias": false,
  "peer_metadata": null
}
^7.25.9runtime
@babel/types
Environment
{
  "local_name": "@babel/types",
  "alias": false,
  "peer_metadata": null
}
^7.25.8runtime
magic-string
Environment
{
  "local_name": "magic-string",
  "alias": false,
  "peer_metadata": null
}
^0.30.12runtime
@types/babel__core
Environment
{
  "local_name": "@types/babel__core",
  "alias": false,
  "peer_metadata": null
}
^7.20.5development
@types/babel__traverse
Environment
{
  "local_name": "@types/babel__traverse",
  "alias": false,
  "peer_metadata": null
}
^7.20.6development
@types/node
Environment
{
  "local_name": "@types/node",
  "alias": false,
  "peer_metadata": null
}
^22.5.5development
tsup
Environment
{
  "local_name": "tsup",
  "alias": false,
  "peer_metadata": null
}
^8.0.0development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.5.3development
vite
Environment
{
  "local_name": "vite",
  "alias": false,
  "peer_metadata": null
}
>=5.0.0peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "integrity": "sha512-4Osdi4GGkKhYl34llK+jvdCSTzfyt51tLJnHnO9hsP6+as+X3qGbGx7Dz40/2IzTGTxylwqkD/QEMdTQXjd1AQ==",
  "shasum": "698907f9ed5d86288f7f428beae58663e619343f",
  "tarball": "https://registry.npmjs.org/@0xminds/component-tagger/-/component-tagger-1.1.0.tgz",
  "fileCount": 6,
  "unpackedSize": 26238,
  "signatures": [
    {
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U",
      "sig": "MEQCIACKx1R6xzpniws1eqb/+o6xpUt/lhwcOfCihor6ffY9AiBwMiUzh0BWkcER51ar1T6gGtZeZaxRekA9Lg9cM5ckfA=="
    }
  ]
}

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 09:08 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:4f0ee0dfe6a51576fd4e378f7a4af9e39060f299b4173c3eeab36d97f6c79f01

Other collected versions

1.0.130 Nov1.0.019 NovView all collected versions →