Skip to content
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

Improve ES build comaptibility #386

Merged
merged 9 commits into from
Jan 22, 2023
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
22 changes: 0 additions & 22 deletions .babelrc.js

This file was deleted.

4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ dist
.idea
*.log
package-lock.json

# System Files
.DS_Store
Thumbs.db
20 changes: 13 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
language: node_js
node_js: 11
node_js: 18
cache:
npm: false
directories:
- "~/.pnpm-store"
before_install:
- curl -f https://get.pnpm.io/v6.16.js | node - add --global pnpm@7
- pnpm config set store-dir ~/.pnpm-store
install:
- pnpm install
alexander-heimbuch marked this conversation as resolved.
Show resolved Hide resolved
script:
- yarn format:check
- yarn lint
- yarn test
- pnpm format:check
- pnpm lint
- pnpm test
after_success:
- npx codecov
cache:
directories:
- "$HOME/.npm"
4 changes: 2 additions & 2 deletions docs/api/combineActions.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Below is how you would use `combineActions` and `handleActions` together

```js
const { increment, decrement } = createActions({
INCREMENT: amount => ({ amount }),
DECREMENT: amount => ({ amount: -amount })
INCREMENT: (amount) => ({ amount }),
DECREMENT: (amount) => ({ amount: -amount })
});

const reducer = handleActions(
Expand Down
17 changes: 10 additions & 7 deletions docs/api/createAction.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ createAction('ADD_TODO')('Use Redux');
###### EXAMPLE

```js
let noop = createAction('NOOP', amount => amount);
let noop = createAction('NOOP', (amount) => amount);
// same as
noop = createAction('NOOP');

Expand All @@ -119,7 +119,7 @@ expect(noop(42)).to.deep.equal({
```js
const updateAdminUser = createAction(
'UPDATE_ADMIN_USER',
updates => updates,
(updates) => updates,
() => ({ admin: true })
);

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

```js
createActions({
ADD_TODO: todo => ({ todo }), // payload creator
ADD_TODO: (todo) => ({ todo }), // payload creator
REMOVE_TODO: [
todo => ({ todo }), // payload creator
(todo) => ({ todo }), // payload creator
(todo, warn) => ({ todo, warn }) // meta
]
});
Expand All @@ -176,8 +176,11 @@ If `actionMap` has a recursive structure, its leaves are used as payload and met
const actionCreators = createActions({
APP: {
COUNTER: {
INCREMENT: [amount => ({ amount }), amount => ({ key: 'value', amount })],
DECREMENT: amount => ({ amount: -amount }),
INCREMENT: [
(amount) => ({ amount }),
(amount) => ({ key: 'value', amount })
],
DECREMENT: (amount) => ({ amount: -amount }),
SET: undefined // given undefined, the identity function will be used
},
NOTIFY: [
Expand Down Expand Up @@ -221,7 +224,7 @@ const { actionOne, actionTwo, actionThree } = createActions(

// array form
ACTION_TWO: [
first => [first], // payload
(first) => [first], // payload
(first, second) => ({ second }) // meta
]

Expand Down
8 changes: 4 additions & 4 deletions docs/introduction/Tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ We are going to be building a simple counter, I recommend using something like [
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.

```html
<!doctype html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta charset="utf-8" />
<script src="https://unpkg.com/redux@latest/dist/redux.js"></script>
<script src="https://unpkg.com/redux-actions@latest/dist/redux-actions.js"></script>
</head>
Expand Down Expand Up @@ -131,8 +131,8 @@ const { createAction, handleActions } = window.ReduxActions;

const reducer = handleActions(
{
[increment]: state => ({ ...state, counter: state.counter + 1 }),
[decrement]: state => ({ ...state, counter: state.counter - 1 })
[increment]: (state) => ({ ...state, counter: state.counter + 1 }),
[decrement]: (state) => ({ ...state, counter: state.counter - 1 })
},
defaultState
);
Expand Down
108 changes: 45 additions & 63 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
{
"name": "redux-actions",
"version": "2.6.5",
"version": "2.7.0",
"description": "Flux Standard Action utlities for Redux",
"main": "lib/index.js",
"unpkg": "dist/redux-actions.js",
"module": "es/index.js",
"sideEffects": false,
"type": "module",
"scripts": {
"format": "prettier --write \"**/*.{js,md}\"",
"format:check": "prettier --list-different \"**/*.{js,md}\"",
"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": "rollup -c && es-check es5 dist/redux-actions.min.js",
"build": "run-s clean && run-p build:**",
"build": "vite build",
"clean": "rimraf coverage dist es lib",
"lint": "xo",
"prepublishOnly": "run-s build",
"test": "jest"
"test": "vitest run --coverage",
"lint": "xo"
},
"files": [
"es",
"lib",
"dist",
"src"
"dist"
],
"module": "./dist/redux-actions.js",
"exports": {
".": {
"import": "./dist/redux-actions.js"
}
},
"keywords": [
"flux",
"redux",
Expand All @@ -41,74 +38,59 @@
},
"license": "MIT",
"devDependencies": {
"@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",
"cross-env": "^5.2.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": "^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"
"@vitest/coverage-c8": "0.26.2",
"eslint-config-unicorn-camelcase": "0.1.1",
"flux-standard-action": "2.1.2",
"husky": "8.0.2",
"lint-staged": "13.1.0",
"npm-run-all": "4.1.5",
"prettier": "2.8.1",
"vite": "4.0.3",
"vitest": "0.26.2",
"xo": "0.53.1"
},
"dependencies": {
"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"
"just-curry-it": "5.3.0",
"reduce-reducers": "1.0.4"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"browserify": {
"transform": [
"loose-envify"
"lint-staged": {
"*.{js,md}": [
"prettier --write",
"git add"
]
},
"xo": {
"prettier": true,
"space": true,
"extends": [
"unicorn-camelcase",
"jest-files"
"unicorn-camelcase"
],
"ignores": [
"rollup.config.js"
]
"vite.config.js"
],
"rules": {
"import/no-anonymous-default-export": "off",
"unicorn/no-array-reduce": "off",
"n/file-extension-in-import": "off",
"import/extensions": "off",
"unicorn/prevent-abbreviations": "off",
"unicorn/no-array-for-each": "off",
"unicorn/no-for-loop": "off",
"padding-line-between-statements": "off",
"unicorn/no-array-callback-reference": "off",
"n/prefer-global/process": "off",
"unicorn/prefer-export-from": "off",
"unicorn/prefer-array-flat": "off"
alexander-heimbuch marked this conversation as resolved.
Show resolved Hide resolved
}
},
"prettier": {
"singleQuote": true,
"bracketSpacing": true,
"trailingComma": "none"
},
"jest": {
"collectCoverage": true
},
"lint-staged": {
"*.{js,md}": [
"prettier --write",
"git add"
]
}
}
Loading