babel-plugin-kea

3.0.0 • Public • Published

NPM Version Backers on Open Collective Sponsors on Open Collective

babel-plugin-kea

This plugin helps auto-generate paths for kea logic.

// IN FILE: scenes/homepage/homepageLogic.js

// input:
kea({
  // ... anything but `path`
})

// output:
kea({
  path: () => ['scenes', 'homepage', 'homepageLogic']
  // ... anything but `path`
})


// IN FILE: scenes/dashboard/dashboardLogic.js

// input:
kea({
  key: props => props.id, 
  // ... anything but `path`
})

// output:
kea({
  key: props => props.id,
  path: (key) => ['scenes', 'homepage', 'homepageLogic', key]
  // ... anything but `path`
})


// IN FILE: lib/customPage.js

// input:
kea({
  path: () => ['special', 'customStuff'],
  // other keys 
})

// output:
kea({
  path: () => ['special', 'customStuff'], // path was not modified 
  // other keys 
})

Installation

First install the package

# with yarn
yarn add babel-plugin-kea --dev

# with npm
npm install babel-plugin-kea --save-dev

Then add it to the list of plugins in your .babelrc:

// .babelrc
{
  "plugins": [
    "babel-plugin-kea"
  ]
}

Configuration

Logic paths are scoped from the current path. If you wish to skip a few parts of the path, for example if your frontend lives under frontend/src and you don't want every kea path to start with frontend.src, specify it in the config as follows:

// .babelrc
{
  "plugins": [
    ["babel-plugin-kea", { "path": "./frontend/src" }]
  ]
}

Readme

Keywords

none

Package Sidebar

Install

npm i babel-plugin-kea

Weekly Downloads

4

Version

3.0.0

License

MIT

Unpacked Size

17.9 kB

Total Files

7

Last publish

Collaborators

  • mariusandra