1.0.0 • Published 7 years ago
babel-plugin-transform-name-export-default v1.0.0
babel-plugin-transform-name-export-default
Name default exported functions when they don't have a name with the file name
What it does
myFile.js
export default () => {};
Transforms to:
export default (function myFile() {});
Usefull for naming stateless react components or anything that displays the function's name !
Options
compose
-true
orfalse
enables the naming inside the first argument, like a redux connect
or compose
function:
export default compose()(() => {});
TransformsTo:
export default compose()(function composeArrowFunction() {});
Install
npm install --save-dev babel-plugin-transform-name-export-default
yarn add --dev babel-plugin-transform-name-export-default
Usage
Via .babelrc
.babelrc
{
"presets": ["transform-name-export-default"]
}
{
"presets": [["transform-name-export-default", { "compose": true }]]
}
Via CLI
babel script.js --presets transform-name-export-default
Via Node API
require("babel-core").transform("code", {
presets: [require('transform-name-export-default')]
});
require("babel-core").transform("code", {
presets: [[require('transform-name-export-default'), { compose: true }]]
});
Thanks
1.0.0
7 years ago