Skip to content

Commit ef5f9d8

Browse files
heygradytimche
authored andcommitted
replace lodash with just, replace webpack with rollup, transpile dependencies (#332)
* replace lodash with just, replace webpack with rollup, bundle dependencies, fixes #331 * removing some packages, bumping some packages * bump reduce-reducers * revert just-camel-case; use to-camel-case; upgrade xo * use babel for commonjs and esm builds
1 parent 51de389 commit ef5f9d8

18 files changed

+2075
-3434
lines changed

.babelrc

Lines changed: 0 additions & 20 deletions
This file was deleted.

.babelrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const { BABEL_ENV, NODE_ENV } = process.env;
2+
3+
module.exports = {
4+
presets: [
5+
[
6+
'@babel/env',
7+
{
8+
targets: {
9+
browsers: ['ie >= 11']
10+
},
11+
exclude: ['transform-async-to-generator', 'transform-regenerator'],
12+
modules: BABEL_ENV === 'commonjs' ? 'cjs' : false,
13+
loose: true
14+
}
15+
]
16+
],
17+
plugins: [
18+
// don't use `loose` mode here - need to copy symbols when spreading
19+
'@babel/proposal-object-rest-spread',
20+
NODE_ENV === 'test' && '@babel/transform-modules-commonjs'
21+
].filter(Boolean)
22+
};

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
1010
### Table of Contents
1111

12-
* [Getting Started](#getting-started)
13-
* [Installation](#installation)
14-
* [Usage](#usage)
15-
* [Documentation](#documentation)
12+
- [Getting Started](#getting-started)
13+
- [Installation](#installation)
14+
- [Usage](#usage)
15+
- [Documentation](#documentation)
1616

1717
# Getting Started
1818

@@ -63,8 +63,8 @@ export default reducer;
6363

6464
## Documentation
6565

66-
* [Introduction](https://redux-actions.js.org/docs/introduction/index.html)
67-
* [API](https://redux-actions.js.org/docs/api/index.html)
68-
* [External Resources](https://redux-actions.js.org/docs/ExternalResources.html)
69-
* [Changelog](https://redux-actions.js.org/docs/Changelog.html)
70-
* [Contributors](https://redux-actions.js.org/docs/Contributors.html)
66+
- [Introduction](https://redux-actions.js.org/docs/introduction/index.html)
67+
- [API](https://redux-actions.js.org/docs/api/index.html)
68+
- [External Resources](https://redux-actions.js.org/docs/ExternalResources.html)
69+
- [Changelog](https://redux-actions.js.org/docs/Changelog.html)
70+
- [Contributors](https://redux-actions.js.org/docs/Contributors.html)

docs/ExternalResources.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

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

5-
* [redux-promise](https://github.com/redux-utilities/redux-promise) - Promise middleware
6-
* [redux-rx](https://github.com/acdlite/redux-rx) - Includes observable middleware.
5+
- [redux-promise](https://github.com/redux-utilities/redux-promise) - Promise middleware
6+
- [redux-rx](https://github.com/acdlite/redux-rx) - Includes observable middleware.

docs/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Table of Contents
22

3-
* [Read Me](../README.md)
4-
* [Introduction](introduction/README.md)
5-
* [Motivation](introduction/Motivation.md)
6-
* [Tutorial](introduction/Tutorial.md)
7-
* [API Reference](api/README.md)
8-
* [createAction(s)](api/createAction.md)
9-
* [handleAction(s)](api/handleAction.md)
10-
* [combineActions](api/combineActions.md)
11-
* [External Resources](ExternalResources.md)
12-
* [Changelog](Changelog.md)
13-
* [Contributors](https://github.com/redux-utilities/redux-actions/graphs/contributors)
3+
- [Read Me](../README.md)
4+
- [Introduction](introduction/README.md)
5+
- [Motivation](introduction/Motivation.md)
6+
- [Tutorial](introduction/Tutorial.md)
7+
- [API Reference](api/README.md)
8+
- [createAction(s)](api/createAction.md)
9+
- [handleAction(s)](api/handleAction.md)
10+
- [combineActions](api/combineActions.md)
11+
- [External Resources](ExternalResources.md)
12+
- [Changelog](Changelog.md)
13+
- [Contributors](https://github.com/redux-utilities/redux-actions/graphs/contributors)

docs/api/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# API Reference
22

3-
* Methods
4-
* [createAction(s)](/docs/api/createAction.md)
5-
* [handleAction(s)](/docs/api/handleAction.md)
6-
* [combineActions](/docs/api/combineActions.md)
3+
- Methods
4+
- [createAction(s)](/docs/api/createAction.md)
5+
- [handleAction(s)](/docs/api/handleAction.md)
6+
- [combineActions](/docs/api/combineActions.md)

docs/api/combineActions.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# API Reference for combineActions
22

3-
* [Methods](#methods)
4-
* [combineActions](#combineactions)
5-
* [`combineActions(...types)`](#combineactionstypes)
3+
- [Methods](#methods)
4+
- [combineActions](#combineactions)
5+
- [`combineActions(...types)`](#combineactionstypes)
66

77
## Methods
88

docs/api/createAction.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# API Reference for createAction(s)
22

3-
* [Methods](#methods)
4-
* [createAction](#createaction)
5-
* [`createAction(type)`](#createactiontype)
6-
* [`createAction(type, payloadCreator)`](#createactiontype-payloadcreator)
7-
* [`createAction(type, payloadCreator, metaCreator)`](#createactiontype-payloadcreator-metacreator)
8-
* [createActions](#createactions)
9-
* [`createActions(actionMap)`](#createactionsactionmap)
10-
* [`createActions(actionMap, ...identityActions)`](#createactionsactionmap-identityactions)
3+
- [Methods](#methods)
4+
- [createAction](#createaction)
5+
- [`createAction(type)`](#createactiontype)
6+
- [`createAction(type, payloadCreator)`](#createactiontype-payloadcreator)
7+
- [`createAction(type, payloadCreator, metaCreator)`](#createactiontype-payloadcreator-metacreator)
8+
- [createActions](#createactions)
9+
- [`createActions(actionMap)`](#createactionsactionmap)
10+
- [`createActions(actionMap, ...identityActions)`](#createactionsactionmap-identityactions)
1111

1212
## Methods
1313

@@ -150,10 +150,10 @@ import { createActions } from 'redux-actions';
150150
151151
`actionMap` is an object which can optionally have a recursive data structure, with action types as keys, and whose values **must** be either
152152
153-
* a function, which is the payload creator for that action
154-
* an array with `payload` and `meta` functions in that order, as in [`createAction`](#createaction)
155-
* `meta` is **required** in this case \(otherwise use the function form above\)
156-
* an `actionMap`
153+
- a function, which is the payload creator for that action
154+
- an array with `payload` and `meta` functions in that order, as in [`createAction`](#createaction)
155+
- `meta` is **required** in this case \(otherwise use the function form above\)
156+
- an `actionMap`
157157
158158
###### EXAMPLE
159159

docs/api/handleAction.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# API Reference for handleAction(s)
22

3-
* [Methods](#methods)
4-
* [handleAction](#handleaction)
5-
* [`handleAction(type, reducer, defaultState)`](#handleactiontype-reducer-defaultstate)
6-
* [`handleAction(type, reducerMap, defaultState)`](#handleactiontype-reducermap-defaultstate)
7-
* [handleActions](#handleactions)
8-
* [`handleActions(reducerMap, defaultState)`](#handleactionsreducermap-defaultstate)
3+
- [Methods](#methods)
4+
- [handleAction](#handleaction)
5+
- [`handleAction(type, reducer, defaultState)`](#handleactiontype-reducer-defaultstate)
6+
- [`handleAction(type, reducerMap, defaultState)`](#handleactiontype-reducermap-defaultstate)
7+
- [handleActions](#handleactions)
8+
- [`handleActions(reducerMap, defaultState)`](#handleactionsreducermap-defaultstate)
99

1010
## Methods
1111

docs/introduction/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Introduction
22

3-
* [Motivation](/docs/introduction/Motivation.md)
4-
* [Tutorial](/docs/introduction/Tutorial.md)
3+
- [Motivation](/docs/introduction/Motivation.md)
4+
- [Tutorial](/docs/introduction/Tutorial.md)

package.json

Lines changed: 48 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
"version": "2.6.1",
44
"description": "Flux Standard Action utlities for Redux",
55
"main": "lib/index.js",
6+
"unpkg": "dist/redux-actions.js",
67
"module": "es/index.js",
7-
"jsnext:main": "es/index.js",
88
"sideEffects": false,
99
"scripts": {
10-
"precommit": "lint-staged",
1110
"format": "prettier --write \"**/*.{js,md}\"",
1211
"format:check": "prettier --list-different \"**/*.{js,md}\"",
13-
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
12+
"build:esm": "cross-env BABEL_ENV=esm babel src --out-dir es",
1413
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
15-
"build:umd": "cross-env NODE_ENV=development webpack",
16-
"build:umd:min": "cross-env NODE_ENV=production webpack && es-check es5 dist/redux-actions.min.js",
14+
"build:umd": "rollup -c && es-check es5 dist/redux-actions.min.js",
1715
"build": "run-s clean && run-p build:**",
1816
"clean": "rimraf coverage dist es lib",
1917
"lint": "xo",
@@ -23,7 +21,8 @@
2321
"files": [
2422
"es",
2523
"lib",
26-
"dist"
24+
"dist",
25+
"src"
2726
],
2827
"keywords": [
2928
"flux",
@@ -42,40 +41,59 @@
4241
},
4342
"license": "MIT",
4443
"devDependencies": {
45-
"babel-cli": "^6.7.7",
46-
"babel-core": "^6.7.7",
47-
"babel-jest": "^22.4.3",
48-
"babel-loader": "^7.1.4",
49-
"babel-plugin-transform-object-rest-spread": "^6.26.0",
50-
"babel-preset-env": "^1.6.1",
51-
"cross-env": "^2.0.0",
52-
"es-check": "^2.0.4",
53-
"eslint-config-jest-files": "^0.1.1",
44+
"@babel/cli": "^7.1.2",
45+
"@babel/core": "^7.1.2",
46+
"@babel/node": "^7.0.0",
47+
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
48+
"@babel/preset-env": "^7.1.0",
49+
"babel-core": "^7.0.0-bridge.0",
50+
"babel-jest": "^23.6.0",
51+
"es-check": "^4.0.0",
52+
"eslint": "^5.7.0",
53+
"eslint-config-jest-files": "^0.1.3",
5454
"eslint-config-unicorn-camelcase": "^0.1.1",
55-
"eslint-plugin-prettier": "^2.6.0",
56-
"flux-standard-action": "^1.0.0",
57-
"husky": "^0.14.3",
58-
"jest": "^22.4.3",
59-
"lint-staged": "^7.0.4",
60-
"npm-run-all": "^4.1.2",
61-
"prettier": "^1.12.1",
62-
"rimraf": "^2.5.3",
63-
"webpack": "^4.1.1",
64-
"webpack-cli": "^2.0.11",
65-
"xo": "^0.20.3"
55+
"eslint-plugin-prettier": "^3.0.0",
56+
"flux-standard-action": "^2.0.3",
57+
"husky": "^1.1.2",
58+
"jest": "^23.6.0",
59+
"lint-staged": "^7.3.0",
60+
"npm-run-all": "^4.1.3",
61+
"prettier": "^1.14.3",
62+
"rimraf": "^2.6.2",
63+
"rollup": "^0.66.6",
64+
"rollup-plugin-babel": "^4.0.3",
65+
"rollup-plugin-commonjs": "^9.2.0",
66+
"rollup-plugin-node-resolve": "^3.4.0",
67+
"rollup-plugin-replace": "^2.1.0",
68+
"rollup-plugin-terser": "^3.0.0",
69+
"xo": "^0.23.0"
6670
},
6771
"dependencies": {
68-
"invariant": "^2.2.1",
69-
"lodash.camelcase": "^4.3.0",
70-
"lodash.curry": "^4.1.1",
71-
"reduce-reducers": "^0.1.0"
72+
"invariant": "^2.2.4",
73+
"just-curry-it": "^3.1.0",
74+
"loose-envify": "^1.4.0",
75+
"reduce-reducers": "^0.4.3",
76+
"to-camel-case": "^1.0.0"
77+
},
78+
"husky": {
79+
"hooks": {
80+
"pre-commit": "lint-staged"
81+
}
82+
},
83+
"browserify": {
84+
"transform": [
85+
"loose-envify"
86+
]
7287
},
7388
"xo": {
7489
"prettier": true,
7590
"space": true,
7691
"extends": [
7792
"unicorn-camelcase",
7893
"jest-files"
94+
],
95+
"ignores": [
96+
"rollup.config.js"
7997
]
8098
},
8199
"prettier": {

rollup.config.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import commonjs from 'rollup-plugin-commonjs';
2+
import nodeResolve from 'rollup-plugin-node-resolve';
3+
import babel from 'rollup-plugin-babel';
4+
import replace from 'rollup-plugin-replace';
5+
import { terser } from 'rollup-plugin-terser';
6+
7+
import pkg from './package.json';
8+
9+
export default [
10+
// UMD Development
11+
{
12+
input: 'src/index.js',
13+
output: {
14+
file: 'dist/redux-actions.js',
15+
format: 'umd',
16+
name: 'ReduxActions',
17+
indent: false
18+
},
19+
plugins: [
20+
nodeResolve(),
21+
commonjs(),
22+
babel(),
23+
replace({ 'process.env.NODE_ENV': JSON.stringify('development') })
24+
]
25+
},
26+
27+
// UMD Production
28+
{
29+
input: 'src/index.js',
30+
output: {
31+
file: 'dist/redux-actions.min.js',
32+
format: 'umd',
33+
name: 'ReduxActions',
34+
indent: false
35+
},
36+
plugins: [
37+
nodeResolve(),
38+
commonjs(),
39+
babel(),
40+
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),
41+
terser({
42+
compress: {
43+
pure_getters: true,
44+
unsafe: true,
45+
unsafe_comps: true,
46+
warnings: false
47+
}
48+
})
49+
]
50+
}
51+
];

src/createCurriedAction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import curry from 'lodash.curry';
1+
import curry from 'just-curry-it';
22
import createAction from './createAction';
33

44
export default (type, payloadCreator) =>

src/handleActions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@ export default function handleActions(handlers, defaultState, options = {}) {
1919
const reducers = ownKeys(flattenedReducerMap).map(type =>
2020
handleAction(type, get(type, flattenedReducerMap), defaultState)
2121
);
22-
const reducer = reduceReducers(...reducers);
22+
const reducer = reduceReducers(...reducers, defaultState);
2323
return (state = defaultState, action) => reducer(state, action);
2424
}

src/utils/camelCase.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import camelCase from 'lodash.camelcase';
1+
import camelCase from 'to-camel-case';
22

33
const namespacer = '/';
44

src/utils/ownKeys.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ import isMap from './isMap';
22

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

0 commit comments

Comments
 (0)