
Security News
Django Joins curl in Pushing Back on AI Slop Security Reports
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
@babel/plugin-transform-react-jsx-source
Advanced tools
Add a __source prop to all JSX Elements
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.
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>
);
Similar to @babel/plugin-transform-react-jsx-source, this plugin transforms JSX into createElement calls but does not add source and line number information. It's more focused on the transformation itself rather than enhancing the debugging experience.
While not a direct alternative, react-hot-loader provides hot reloading for React components during development. It enhances the development experience by allowing live updates without losing state. It complements the functionality of @babel/plugin-transform-react-jsx-source by improving the overall development workflow rather than focusing solely on debugging.
Adds source file and line number to JSX elements.
In
<sometag />
Out
<sometag __source={ { fileName: 'this/file.js', lineNumber: 10 } } />
npm install --save-dev @babel/plugin-transform-react-jsx-source
.babelrc
(Recommended).babelrc
{
"plugins": ["@babel/plugin-transform-react-jsx-source"]
}
babel --plugins @babel/plugin-transform-react-jsx-source script.js
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-transform-react-jsx-source"]
});
FAQs
Add a __source prop to all JSX Elements
The npm package @babel/plugin-transform-react-jsx-source receives a total of 11,614,311 weekly downloads. As such, @babel/plugin-transform-react-jsx-source popularity was classified as popular.
We found that @babel/plugin-transform-react-jsx-source demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
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.
Security News
Django has updated its security policies to reject AI-generated vulnerability reports that include fabricated or unverifiable content.
Security News
ECMAScript 2025 introduces Iterator Helpers, Set methods, JSON modules, and more in its latest spec update approved by Ecma in June 2025.
Security News
A new Node.js homepage button linking to paid support for EOL versions has sparked a heated discussion among contributors and the wider community.