Skip to content

Commit f9d655c

Browse files
Improve ES build comaptibility (#386)
* chore: upgrade build tooling * chore: move tests to vitest * chore: improve code linting * chore: add pnpm to travis config * chore: remove system file * chore: only support ESM targets * chore: fix package version * fix: merge conflicts
1 parent 3f43258 commit f9d655c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+4140
-7127
lines changed

.babelrc.js

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

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ dist
66
.idea
77
*.log
88
package-lock.json
9+
10+
# System Files
11+
.DS_Store
12+
Thumbs.db

.travis.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
language: node_js
2-
node_js: 11
2+
node_js: 18
3+
cache:
4+
npm: false
5+
directories:
6+
- "~/.pnpm-store"
7+
before_install:
8+
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7
9+
- pnpm config set store-dir ~/.pnpm-store
10+
install:
11+
- pnpm install
312
script:
4-
- yarn format:check
5-
- yarn lint
6-
- yarn test
13+
- pnpm format:check
14+
- pnpm lint
15+
- pnpm test
716
after_success:
817
- npx codecov
9-
cache:
10-
directories:
11-
- "$HOME/.npm"

docs/api/combineActions.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ Below is how you would use `combineActions` and `handleActions` together
4545
4646
```js
4747
const { increment, decrement } = createActions({
48-
INCREMENT: amount => ({ amount }),
49-
DECREMENT: amount => ({ amount: -amount })
48+
INCREMENT: (amount) => ({ amount }),
49+
DECREMENT: (amount) => ({ amount: -amount })
5050
});
5151

5252
const reducer = handleActions(

docs/api/createAction.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ createAction('ADD_TODO')('Use Redux');
100100
###### EXAMPLE
101101
102102
```js
103-
let noop = createAction('NOOP', amount => amount);
103+
let noop = createAction('NOOP', (amount) => amount);
104104
// same as
105105
noop = createAction('NOOP');
106106

@@ -119,7 +119,7 @@ expect(noop(42)).to.deep.equal({
119119
```js
120120
const updateAdminUser = createAction(
121121
'UPDATE_ADMIN_USER',
122-
updates => updates,
122+
(updates) => updates,
123123
() => ({ admin: true })
124124
);
125125

@@ -160,9 +160,9 @@ import { createActions } from 'redux-actions';
160160
161161
```js
162162
createActions({
163-
ADD_TODO: todo => ({ todo }), // payload creator
163+
ADD_TODO: (todo) => ({ todo }), // payload creator
164164
REMOVE_TODO: [
165-
todo => ({ todo }), // payload creator
165+
(todo) => ({ todo }), // payload creator
166166
(todo, warn) => ({ todo, warn }) // meta
167167
]
168168
});
@@ -176,8 +176,11 @@ If `actionMap` has a recursive structure, its leaves are used as payload and met
176176
const actionCreators = createActions({
177177
APP: {
178178
COUNTER: {
179-
INCREMENT: [amount => ({ amount }), amount => ({ key: 'value', amount })],
180-
DECREMENT: amount => ({ amount: -amount }),
179+
INCREMENT: [
180+
(amount) => ({ amount }),
181+
(amount) => ({ key: 'value', amount })
182+
],
183+
DECREMENT: (amount) => ({ amount: -amount }),
181184
SET: undefined // given undefined, the identity function will be used
182185
},
183186
NOTIFY: [
@@ -221,7 +224,7 @@ const { actionOne, actionTwo, actionThree } = createActions(
221224

222225
// array form
223226
ACTION_TWO: [
224-
first => [first], // payload
227+
(first) => [first], // payload
225228
(first, second) => ({ second }) // meta
226229
]
227230

docs/introduction/Tutorial.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ We are going to be building a simple counter, I recommend using something like [
2525
To begin we are going to need some scaffolding so here is some HTML to get started with. You may need to create a new file called main.js depending on where you are trying to set this tutorial up.
2626

2727
```html
28-
<!doctype html>
28+
<!DOCTYPE html>
2929
<html>
3030
<head>
31-
<meta charset="utf-8"/>
31+
<meta charset="utf-8" />
3232
<script src="https://unpkg.com/redux@latest/dist/redux.js"></script>
3333
<script src="https://unpkg.com/redux-actions@latest/dist/redux-actions.js"></script>
3434
</head>
@@ -131,8 +131,8 @@ const { createAction, handleActions } = window.ReduxActions;
131131

132132
const reducer = handleActions(
133133
{
134-
[increment]: state => ({ ...state, counter: state.counter + 1 }),
135-
[decrement]: state => ({ ...state, counter: state.counter - 1 })
134+
[increment]: (state) => ({ ...state, counter: state.counter + 1 }),
135+
[decrement]: (state) => ({ ...state, counter: state.counter - 1 })
136136
},
137137
defaultState
138138
);

package.json

Lines changed: 45 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
{
22
"name": "redux-actions",
3-
"version": "2.6.5",
3+
"version": "2.7.0",
44
"description": "Flux Standard Action utlities for Redux",
5-
"main": "lib/index.js",
6-
"unpkg": "dist/redux-actions.js",
7-
"module": "es/index.js",
8-
"sideEffects": false,
5+
"type": "module",
96
"scripts": {
107
"format": "prettier --write \"**/*.{js,md}\"",
118
"format:check": "prettier --list-different \"**/*.{js,md}\"",
12-
"build:esm": "cross-env BABEL_ENV=esm babel src --out-dir es",
13-
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
14-
"build:umd": "rollup -c && es-check es5 dist/redux-actions.min.js",
15-
"build": "run-s clean && run-p build:**",
9+
"build": "vite build",
1610
"clean": "rimraf coverage dist es lib",
17-
"lint": "xo",
1811
"prepublishOnly": "run-s build",
19-
"test": "jest"
12+
"test": "vitest run --coverage",
13+
"lint": "xo"
2014
},
2115
"files": [
22-
"es",
23-
"lib",
24-
"dist",
25-
"src"
16+
"dist"
2617
],
18+
"module": "./dist/redux-actions.js",
19+
"exports": {
20+
".": {
21+
"import": "./dist/redux-actions.js"
22+
}
23+
},
2724
"keywords": [
2825
"flux",
2926
"redux",
@@ -41,74 +38,59 @@
4138
},
4239
"license": "MIT",
4340
"devDependencies": {
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-
"cross-env": "^5.2.0",
52-
"es-check": "^4.0.0",
53-
"eslint": "^5.7.0",
54-
"eslint-config-jest-files": "^0.1.3",
55-
"eslint-config-unicorn-camelcase": "^0.1.1",
56-
"eslint-plugin-prettier": "^3.0.0",
57-
"flux-standard-action": "^2.0.3",
58-
"husky": "^1.1.2",
59-
"jest": "^23.6.0",
60-
"lint-staged": "^7.3.0",
61-
"npm-run-all": "^4.1.3",
62-
"prettier": "^1.14.3",
63-
"rimraf": "^2.6.2",
64-
"rollup": "^0.66.6",
65-
"rollup-plugin-babel": "^4.0.3",
66-
"rollup-plugin-commonjs": "^9.2.0",
67-
"rollup-plugin-node-resolve": "^3.4.0",
68-
"rollup-plugin-replace": "^2.1.0",
69-
"rollup-plugin-terser": "^3.0.0",
70-
"xo": "^0.23.0"
41+
"@vitest/coverage-c8": "0.26.2",
42+
"eslint-config-unicorn-camelcase": "0.1.1",
43+
"flux-standard-action": "2.1.2",
44+
"husky": "8.0.2",
45+
"lint-staged": "13.1.0",
46+
"npm-run-all": "4.1.5",
47+
"prettier": "2.8.1",
48+
"vite": "4.0.3",
49+
"vitest": "0.26.2",
50+
"xo": "0.53.1"
7151
},
7252
"dependencies": {
73-
"invariant": "^2.2.4",
74-
"just-curry-it": "^3.1.0",
75-
"loose-envify": "^1.4.0",
76-
"reduce-reducers": "^0.4.3",
77-
"to-camel-case": "^1.0.0"
53+
"just-curry-it": "5.3.0",
54+
"reduce-reducers": "1.0.4"
7855
},
7956
"husky": {
8057
"hooks": {
8158
"pre-commit": "lint-staged"
8259
}
8360
},
84-
"browserify": {
85-
"transform": [
86-
"loose-envify"
61+
"lint-staged": {
62+
"*.{js,md}": [
63+
"prettier --write",
64+
"git add"
8765
]
8866
},
8967
"xo": {
9068
"prettier": true,
9169
"space": true,
9270
"extends": [
93-
"unicorn-camelcase",
94-
"jest-files"
71+
"unicorn-camelcase"
9572
],
9673
"ignores": [
97-
"rollup.config.js"
98-
]
74+
"vite.config.js"
75+
],
76+
"rules": {
77+
"import/no-anonymous-default-export": "off",
78+
"unicorn/no-array-reduce": "off",
79+
"n/file-extension-in-import": "off",
80+
"import/extensions": "off",
81+
"unicorn/prevent-abbreviations": "off",
82+
"unicorn/no-array-for-each": "off",
83+
"unicorn/no-for-loop": "off",
84+
"padding-line-between-statements": "off",
85+
"unicorn/no-array-callback-reference": "off",
86+
"n/prefer-global/process": "off",
87+
"unicorn/prefer-export-from": "off",
88+
"unicorn/prefer-array-flat": "off"
89+
}
9990
},
10091
"prettier": {
10192
"singleQuote": true,
10293
"bracketSpacing": true,
10394
"trailingComma": "none"
104-
},
105-
"jest": {
106-
"collectCoverage": true
107-
},
108-
"lint-staged": {
109-
"*.{js,md}": [
110-
"prettier --write",
111-
"git add"
112-
]
11395
}
11496
}

0 commit comments

Comments
 (0)