0.12.1 • Published 1 year ago

babel-plugin-jsx-owner v0.12.1

Weekly downloads
25
License
MIT
Repository
github
Last release
1 year ago

Adds __source to every JSX element with next data:

{
    name: string,
    parentProps: any
}

It allows you to handle children's parent component with name* and props

  • name - not actually component's name (function or class), this is a file name with path. For example: product/grid-list/ProductGridList
  • works only if component placed at src/components path. to override this, use paths to specify component directories

Feel free to fork and change this settings.

There is probability of some issues due to __source is reserved react property. But you can override it by plugin option (Make sure to prevent it to be passed to a real DOM):

// .babelrc
{
  "presets": [
      ...
  ],
  "plugins": [
    [
      "babel-plugin-jsx-owner",
      {
        "traceId": "__source",
        /* paths where your components placed */
        "paths": ["src/components"],
        /* paths to ignore */
        "ignorePaths": ["renderSubscriber"],
        /* add prefix to all component names */
        "prefix": "sd-common-products",
      }
    ]
  ]
}
npm install -D babel-plugin-jsx-owner
yarn add -D babel-plugin-jsx-owner
0.12.1

1 year ago

0.11.1

3 years ago

0.10.1

3 years ago

0.9.3

3 years ago

0.9.2

4 years ago

0.9.1

4 years ago

0.9.0

4 years ago