Security News
The Push to Ban Ransom Payments Is Gaining Momentum
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
@babel/plugin-transform-react-jsx-source
Advanced tools
Package description
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.
Readme
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/transform-react-jsx-source"]
}
babel --plugins @babel/transform-react-jsx-source script.js
require("@babel/core").transform("code", {
plugins: ["@babel/transform-react-jsx-source"]
});
FAQs
Add a __source prop to all JSX Elements
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
Ransomware costs victims an estimated $30 billion per year and has gotten so out of control that global support for banning payments is gaining momentum.
Application Security
New SEC disclosure rules aim to enforce timely cyber incident reporting, but fear of job loss and inadequate resources lead to significant underreporting.
Security News
The Python Software Foundation has secured a 5-year sponsorship from Fastly that supports PSF's activities and events, most notably the security and reliability of the Python Package Index (PyPI).