Socket
Socket
Sign inDemoInstall

@babel/plugin-transform-react-jsx-source

Package Overview
Dependencies
78
Maintainers
4
Versions
70
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @babel/plugin-transform-react-jsx-source

Add a __source prop to all JSX Elements


Version published
Maintainers
4
Created

Package description

What is @babel/plugin-transform-react-jsx-source?

The @babel/plugin-transform-react-jsx-source plugin is used with Babel to transform JSX code. It adds source file and line number information to JSX elements, which can be very helpful for debugging purposes. When a React component throws an error, this plugin makes it easier to trace back to the source code where the problematic component was defined.

What are @babel/plugin-transform-react-jsx-source's main functionalities?

Adding source and line number to JSX elements

This code snippet demonstrates a simple React component. When using @babel/plugin-transform-react-jsx-source, Babel will transform this JSX to include source file and line number information. This doesn't change the behavior of the component but enhances the debugging experience by indicating where each element was defined in the source code.

const MyComponent = () => (
  <div>
    <h1>Hello, world!</h1>
  </div>
);

Other packages similar to @babel/plugin-transform-react-jsx-source

Readme

Source

@babel/plugin-transform-react-jsx-source

Adds source file and line number to JSX elements.

Example

In

<sometag />

Out

<sometag __source={ { fileName: 'this/file.js', lineNumber: 10 } } />

Installation

npm install --save-dev @babel/plugin-transform-react-jsx-source

Usage

.babelrc

{
  "plugins": ["@babel/transform-react-jsx-source"]
}

Via CLI

babel --plugins @babel/transform-react-jsx-source script.js

Via Node API

require("@babel/core").transform("code", {
  plugins: ["@babel/transform-react-jsx-source"]
});

Keywords

FAQs

Last updated on 03 Nov 2017

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc