1.0.0 • Published 7 years ago

babel-plugin-transform-name-export-default v1.0.0

Weekly downloads
46
License
-
Repository
github
Last release
7 years ago

babel-plugin-transform-name-export-default NPM version

Name default exported functions when they don't have a name with the file name

Build Status Travis Status Dependency Status Dependency ci Status

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 or false

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