# babel-plugin-s2s-redux-actions-reducers-root

> generate redux actions reducers root

Latest version **0.0.5** (published 2019-10-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-s2s-redux-actions-reducers-root
pnpm add babel-plugin-s2s-redux-actions-reducers-root
yarn add babel-plugin-s2s-redux-actions-reducers-root
bun add babel-plugin-s2s-redux-actions-reducers-root
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2019-10-23 |
| First published | 2017-11-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 4 |
| Unpacked size | 5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | progted |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-s2s-redux-actions-reducers-root
- npm.io page: https://npm.io/package/babel-plugin-s2s-redux-actions-reducers-root

## Dependencies (4)

- [globby](https://npm.io/package/globby.md) ^6.1.0
- [s2s-utils](https://npm.io/package/s2s-utils.md) ^0.5.0
- [babel-types](https://npm.io/package/babel-types.md) ^6.26.0
- [babel-preset-es2015](https://npm.io/package/babel-preset-es2015.md) ^6.24.1

## Recent versions

- 0.0.5 (latest) — 2019-10-23
- 0.0.4 — 2019-10-23
- 0.0.3 — 2017-11-17
- 0.0.2 — 2017-11-14
- 0.0.1 — 2017-11-14

## README

# babel-plugin-s2s-redux-actions-reducers-root

> generate redux actions reducers root

Here is the sample repository using this s2s plugin.
[https://github.com/cndlhvn/s2s-redux-actions-sample](https://github.com/cndlhvn/s2s-redux-actions-sample)

## Install

```
$ yarn add --dev babel-plugin-s2s-redux-actions-reducers-root
```

## Install babel handler
You need a handler compatible with syntax object rest spread.

```
$ yarn add --dev s2s-handler-babel-object-rest-spread
```
This handler can transform a code containing object rest spread like this.

```js
[action_name]: () => ({
  ...state
})
```

## s2s.config.js

s2s-redux-actions-reducers-root plugin watch the `src/reducers/(?!.*index).*\.js` files

```js
const handlerBabelSpread = require('s2s-handler-babel-object-rest-spread').default

module.exports = {
  watch: './**/*.js',
  plugins: [
    {
      test: /src\/reducers\/(?!.*index).*\.js/,
      output: "index.js",
      handler: handlerBabelSpread,
      plugin: ['s2s-redux-actions-reducers-root',
      { input: 'src/reducers/*.js', output: "src/reducers/index.js" }]
    }
  ]
}
```

### For React Router Redux
If you use react-router-redux, pleaser pass a router option.
```js
plugin: ['s2s-redux-actions-reducers-root',
{ input: 'src/reducers/*.js', output: "src/reducers/index.js", router: true }]
```

## Start s2s

Start the s2s with yarn command

`yarn run s2s`

## Usage

#### When create reducers file

When you create a `src/reducers/*.js`, this plugin inserts reducers into index.js automatically.

For example you create a `src/reducers/user.js`. It is inserted into index.js

#### Out:

```js
import { combineReducers } from "redux";
import user from "./user";
export default combineReducers({
  user
});
```
#### Case router option:
```js
import { combineReducers } from "redux";
import { routerReducer } from "react-router-redux";
import user from "./user";
export default combineReducers({
  user,
  routing: routerReducer
});
```

# Test

This plugin has two type of test files. \
First is babel plugin main test file named `test.js` on root direcotry. \
Next is `test/*.js` that is test target files.

Run this command.

` npm run test`

Test will run and you can see what happen.

---
_Source: https://npm.io/package/babel-plugin-s2s-redux-actions-reducers-root · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
