Skip to content

replace lodash with just, replace webpack with rollup, transpile dependencies #332

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .babelrc

This file was deleted.

22 changes: 22 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const { BABEL_ENV, NODE_ENV } = process.env;

module.exports = {
presets: [
[
'@babel/env',
{
targets: {
browsers: ['ie >= 11']
},
exclude: ['transform-async-to-generator', 'transform-regenerator'],
modules: BABEL_ENV === 'commonjs' ? 'cjs' : false,
loose: true
}
]
],
plugins: [
// don't use `loose` mode here - need to copy symbols when spreading
'@babel/proposal-object-rest-spread',
NODE_ENV === 'test' && '@babel/transform-modules-commonjs'
].filter(Boolean)
};
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

### Table of Contents

* [Getting Started](#getting-started)
* [Installation](#installation)
* [Usage](#usage)
* [Documentation](#documentation)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)
- [Documentation](#documentation)

# Getting Started

Expand Down Expand Up @@ -63,8 +63,8 @@ export default reducer;

## Documentation

* [Introduction](https://redux-actions.js.org/docs/introduction/index.html)
* [API](https://redux-actions.js.org/docs/api/index.html)
* [External Resources](https://redux-actions.js.org/docs/ExternalResources.html)
* [Changelog](https://redux-actions.js.org/docs/Changelog.html)
* [Contributors](https://redux-actions.js.org/docs/Contributors.html)
- [Introduction](https://redux-actions.js.org/docs/introduction/index.html)
- [API](https://redux-actions.js.org/docs/api/index.html)
- [External Resources](https://redux-actions.js.org/docs/ExternalResources.html)
- [Changelog](https://redux-actions.js.org/docs/Changelog.html)
- [Contributors](https://redux-actions.js.org/docs/Contributors.html)
4 changes: 2 additions & 2 deletions docs/ExternalResources.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

Use redux-actions in combination with [FSA](https://github.com/redux-utilities/flux-standard-action)-compliant libraries.

* [redux-promise](https://github.com/redux-utilities/redux-promise) - Promise middleware
* [redux-rx](https://github.com/acdlite/redux-rx) - Includes observable middleware.
- [redux-promise](https://github.com/redux-utilities/redux-promise) - Promise middleware
- [redux-rx](https://github.com/acdlite/redux-rx) - Includes observable middleware.
22 changes: 11 additions & 11 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Table of Contents

* [Read Me](../README.md)
* [Introduction](introduction/README.md)
* [Motivation](introduction/Motivation.md)
* [Tutorial](introduction/Tutorial.md)
* [API Reference](api/README.md)
* [createAction(s)](api/createAction.md)
* [handleAction(s)](api/handleAction.md)
* [combineActions](api/combineActions.md)
* [External Resources](ExternalResources.md)
* [Changelog](Changelog.md)
* [Contributors](https://github.com/redux-utilities/redux-actions/graphs/contributors)
- [Read Me](../README.md)
- [Introduction](introduction/README.md)
- [Motivation](introduction/Motivation.md)
- [Tutorial](introduction/Tutorial.md)
- [API Reference](api/README.md)
- [createAction(s)](api/createAction.md)
- [handleAction(s)](api/handleAction.md)
- [combineActions](api/combineActions.md)
- [External Resources](ExternalResources.md)
- [Changelog](Changelog.md)
- [Contributors](https://github.com/redux-utilities/redux-actions/graphs/contributors)
8 changes: 4 additions & 4 deletions docs/api/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# API Reference

* Methods
* [createAction(s)](/docs/api/createAction.md)
* [handleAction(s)](/docs/api/handleAction.md)
* [combineActions](/docs/api/combineActions.md)
- Methods
- [createAction(s)](/docs/api/createAction.md)
- [handleAction(s)](/docs/api/handleAction.md)
- [combineActions](/docs/api/combineActions.md)
6 changes: 3 additions & 3 deletions docs/api/combineActions.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# API Reference for combineActions

* [Methods](#methods)
* [combineActions](#combineactions)
* [`combineActions(...types)`](#combineactionstypes)
- [Methods](#methods)
- [combineActions](#combineactions)
- [`combineActions(...types)`](#combineactionstypes)

## Methods

Expand Down
24 changes: 12 additions & 12 deletions docs/api/createAction.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# API Reference for createAction(s)

* [Methods](#methods)
* [createAction](#createaction)
* [`createAction(type)`](#createactiontype)
* [`createAction(type, payloadCreator)`](#createactiontype-payloadcreator)
* [`createAction(type, payloadCreator, metaCreator)`](#createactiontype-payloadcreator-metacreator)
* [createActions](#createactions)
* [`createActions(actionMap)`](#createactionsactionmap)
* [`createActions(actionMap, ...identityActions)`](#createactionsactionmap-identityactions)
- [Methods](#methods)
- [createAction](#createaction)
- [`createAction(type)`](#createactiontype)
- [`createAction(type, payloadCreator)`](#createactiontype-payloadcreator)
- [`createAction(type, payloadCreator, metaCreator)`](#createactiontype-payloadcreator-metacreator)
- [createActions](#createactions)
- [`createActions(actionMap)`](#createactionsactionmap)
- [`createActions(actionMap, ...identityActions)`](#createactionsactionmap-identityactions)

## Methods

Expand Down Expand Up @@ -150,10 +150,10 @@ import { createActions } from 'redux-actions';

`actionMap` is an object which can optionally have a recursive data structure, with action types as keys, and whose values **must** be either

* a function, which is the payload creator for that action
* an array with `payload` and `meta` functions in that order, as in [`createAction`](#createaction)
* `meta` is **required** in this case \(otherwise use the function form above\)
* an `actionMap`
- a function, which is the payload creator for that action
- an array with `payload` and `meta` functions in that order, as in [`createAction`](#createaction)
- `meta` is **required** in this case \(otherwise use the function form above\)
- an `actionMap`

###### EXAMPLE

Expand Down
12 changes: 6 additions & 6 deletions docs/api/handleAction.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# API Reference for handleAction(s)

* [Methods](#methods)
* [handleAction](#handleaction)
* [`handleAction(type, reducer, defaultState)`](#handleactiontype-reducer-defaultstate)
* [`handleAction(type, reducerMap, defaultState)`](#handleactiontype-reducermap-defaultstate)
* [handleActions](#handleactions)
* [`handleActions(reducerMap, defaultState)`](#handleactionsreducermap-defaultstate)
- [Methods](#methods)
- [handleAction](#handleaction)
- [`handleAction(type, reducer, defaultState)`](#handleactiontype-reducer-defaultstate)
- [`handleAction(type, reducerMap, defaultState)`](#handleactiontype-reducermap-defaultstate)
- [handleActions](#handleactions)
- [`handleActions(reducerMap, defaultState)`](#handleactionsreducermap-defaultstate)

## Methods

Expand Down
4 changes: 2 additions & 2 deletions docs/introduction/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Introduction

* [Motivation](/docs/introduction/Motivation.md)
* [Tutorial](/docs/introduction/Tutorial.md)
- [Motivation](/docs/introduction/Motivation.md)
- [Tutorial](/docs/introduction/Tutorial.md)
78 changes: 48 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
"version": "2.6.1",
"description": "Flux Standard Action utlities for Redux",
"main": "lib/index.js",
"unpkg": "dist/redux-actions.js",
"module": "es/index.js",
"jsnext:main": "es/index.js",
"sideEffects": false,
"scripts": {
"precommit": "lint-staged",
"format": "prettier --write \"**/*.{js,md}\"",
"format:check": "prettier --list-different \"**/*.{js,md}\"",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"build:esm": "cross-env BABEL_ENV=esm babel src --out-dir es",
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"build:umd": "cross-env NODE_ENV=development webpack",
"build:umd:min": "cross-env NODE_ENV=production webpack && es-check es5 dist/redux-actions.min.js",
"build:umd": "rollup -c && es-check es5 dist/redux-actions.min.js",
"build": "run-s clean && run-p build:**",
"clean": "rimraf coverage dist es lib",
"lint": "xo",
Expand All @@ -23,7 +21,8 @@
"files": [
"es",
"lib",
"dist"
"dist",
"src"
],
"keywords": [
"flux",
Expand All @@ -42,40 +41,59 @@
},
"license": "MIT",
"devDependencies": {
"babel-cli": "^6.7.7",
"babel-core": "^6.7.7",
"babel-jest": "^22.4.3",
"babel-loader": "^7.1.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"cross-env": "^2.0.0",
"es-check": "^2.0.4",
"eslint-config-jest-files": "^0.1.1",
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"es-check": "^4.0.0",
"eslint": "^5.7.0",
"eslint-config-jest-files": "^0.1.3",
"eslint-config-unicorn-camelcase": "^0.1.1",
"eslint-plugin-prettier": "^2.6.0",
"flux-standard-action": "^1.0.0",
"husky": "^0.14.3",
"jest": "^22.4.3",
"lint-staged": "^7.0.4",
"npm-run-all": "^4.1.2",
"prettier": "^1.12.1",
"rimraf": "^2.5.3",
"webpack": "^4.1.1",
"webpack-cli": "^2.0.11",
"xo": "^0.20.3"
"eslint-plugin-prettier": "^3.0.0",
"flux-standard-action": "^2.0.3",
"husky": "^1.1.2",
"jest": "^23.6.0",
"lint-staged": "^7.3.0",
"npm-run-all": "^4.1.3",
"prettier": "^1.14.3",
"rimraf": "^2.6.2",
"rollup": "^0.66.6",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"rollup-plugin-terser": "^3.0.0",
"xo": "^0.23.0"
},
"dependencies": {
"invariant": "^2.2.1",
"lodash.camelcase": "^4.3.0",
"lodash.curry": "^4.1.1",
"reduce-reducers": "^0.1.0"
"invariant": "^2.2.4",
"just-curry-it": "^3.1.0",
"loose-envify": "^1.4.0",
"reduce-reducers": "^0.4.3",
"to-camel-case": "^1.0.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"browserify": {
"transform": [
"loose-envify"
]
},
"xo": {
"prettier": true,
"space": true,
"extends": [
"unicorn-camelcase",
"jest-files"
],
"ignores": [
"rollup.config.js"
]
},
"prettier": {
Expand Down
51 changes: 51 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import commonjs from 'rollup-plugin-commonjs';
import nodeResolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import { terser } from 'rollup-plugin-terser';

import pkg from './package.json';

export default [
// UMD Development
{
input: 'src/index.js',
output: {
file: 'dist/redux-actions.js',
format: 'umd',
name: 'ReduxActions',
indent: false
},
plugins: [
nodeResolve(),
commonjs(),
babel(),
replace({ 'process.env.NODE_ENV': JSON.stringify('development') })
]
},

// UMD Production
{
input: 'src/index.js',
output: {
file: 'dist/redux-actions.min.js',
format: 'umd',
name: 'ReduxActions',
indent: false
},
plugins: [
nodeResolve(),
commonjs(),
babel(),
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
terser({
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false
}
})
]
}
];
2 changes: 1 addition & 1 deletion src/createCurriedAction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import curry from 'lodash.curry';
import curry from 'just-curry-it';
import createAction from './createAction';

export default (type, payloadCreator) =>
Expand Down
2 changes: 1 addition & 1 deletion src/handleActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export default function handleActions(handlers, defaultState, options = {}) {
const reducers = ownKeys(flattenedReducerMap).map(type =>
handleAction(type, get(type, flattenedReducerMap), defaultState)
);
const reducer = reduceReducers(...reducers);
const reducer = reduceReducers(...reducers, defaultState);
return (state = defaultState, action) => reducer(state, action);
}
2 changes: 1 addition & 1 deletion src/utils/camelCase.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import camelCase from 'lodash.camelcase';
import camelCase from 'to-camel-case';

const namespacer = '/';

Expand Down
7 changes: 7 additions & 0 deletions src/utils/ownKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import isMap from './isMap';

export default function ownKeys(object) {
if (isMap(object)) {
// We are using loose transforms in babel. Here we are trying to convert an
// interable to an array. Loose mode expects everything to already be an
// array. The problem is that our eslint rules encourage us to prefer
// spread over Array.from.
//
// Instead of disabling loose mode we simply disable the warning.
// eslint-disable-next-line unicorn/prefer-spread
return Array.from(object.keys());
}

Expand Down
Loading