New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

babel-plugin-source-mapper

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-source-mapper

Injects data-filepath and data-component into JSX elements for source mapping

latest
npmnpm
Version
0.1.12
Version published
Weekly downloads
17
466.67%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-source-mapper

A Babel plugin to inject data-filepath and data-component attributes into React JSX elements.

Why?

This is useful for:

  • Mapping DOM elements back to their source files
  • Building screen-to-source tools
  • Enabling AI agents to reason about code ownership
  • This is built by TestChimp primarily for mapping the source files related to screens of webapps during exploratory testing

Usage

Install

npm install –save-dev babel-plugin-source-mapper

With craco.config.js or Babel config:

const sourceMapper = require('babel-plugin-source-mapper');

module.exports = {
  babel: {
    plugins: [sourceMapper],
  },
  webpack: {
    configure: (config) => {
      config.optimization.minimize = false;
      return config;
    },
  },
};

Output

Each JSX element will get:

<Component data-filepath="src/components/MyComponent.jsx" data-component="Component" />

Notes • Only applies to custom React components (not HTML tags) • Skips node_modules • Works best with NODE_ENV=development and minification turned off

Keywords

babel-plugin

FAQs

Package last updated on 08 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts