Skip to content

Babel transform to add a static property modulePath containing path to the currently processed React component

License

Notifications You must be signed in to change notification settings

KijijiCA/babel-plugin-inline-react-es6-modulepath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-inline-react-es6-modulepath Build Status

Add modulePath to React components instantiated in ES6 style inheriting from React.Component (ex: class ComponentName extends React.Component or class ComponentName extends React.Component).

modulePath represents the modules location on the filesystem. Good as an alternative to React displayName, when name collisions are likely.

Installation

$ npm install babel-plugin-transform-react-es6-displayname

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["transform-react-es6-displayname"]
}

or with options:

{
  "plugins": [
        ["transform-react-es6-displayname", {stripCwd: true, stripExtension: true}]
    ]
}

Via CLI

$ babel --plugins transform-react-es6-displayname script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-react-es6-displayname"]
});

Options

  • stripCwd [boolean] - Whether to strip current working folder from modulePath (cwd is from process.cwd())
  • stripExtension [boolean] - Whether to strip extensions from modulePath

Development

Read babel plugin handbook -> https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md

Tests

To run tests, run npm test or npm test watch

About

Babel transform to add a static property modulePath containing path to the currently processed React component

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published