babel-plugin-transform-react-fela-display-name
Introduction
This plugin transforms the display names of all react-fela
components created with createComponent
or createComponentWithProxy
to the name of the variable to which they are assigned.
For example, given:
; const MyComponent = ;
<MyComponent .../>
typically renders as:
With this plugin, it renders as:
Installation
npm install babel-plugin-transform-react-fela-display-name --save-dev
yarn add -D babel-plugin-transfrom-react-fela-display-name
How It Works
This plugin works by injecting an extra line of code that sets the displayName
after the component declaration.
For instance:
; const MyComponent = ;
becomes:
; const MyComponent = ;MyComponentdisplayName = 'MyComponent';
Usage
.babelrc
(Recommended)
Via
Via CLI
babel --plugins transform-react-fela-display-name script.js
Via Node API
;
Options
globalSource
If you happen to be providing the react-fela
package globally, you can specify the variable name under which is made so.
For instance, the following allows for this plugin to latch onto usage of ReactFela.createComponent
or ReactFela.createComponentWithProxy
:
functionNameRegEx
You can provide a custom regular expression to check against for function usage instead of the original one which will only match createComponent
and
createComponentWithProxy
.
For instance, the following allows for this plugin to latch onto usage of customFunction
.
reactFelaPackageRegEx
You can provide a custom regular expression to check against instead of the original one for package name which will only match react-fela
.
For instance, the following allows for this plugin to latch onto usage of createComponent
imported from custom-package
.
Changelog
Changes to this package are recorded in the CHANGELOG.md.
Contributing
All pull requests must pass the CI status checks.