Add
data-source-code-location
to all JSX Elements.
English | 简体中文
In
<sometag />
Out
<sometag data-__source-code-location={`${__jsxFileName}:${lineNumber}:${columnNumber}`} />
Using npm:
npm install --save-dev babel-plugin-transform-react-jsx-data-source-code-location
or using yarn:
yarn add babel-plugin-transform-react-jsx-data-source-code-location --dev
{
"plugins": ["babel-plugin-transform-react-jsx-data-source-code-location"]
}
babel --plugins babel-plugin-transform-react-jsx-data-source-code-location script.js
require("@babel/core").transformSync("code", {
plugins: ["babel-plugin-transform-react-jsx-data-source-code-location"],
});