Skip to content

Commit

Permalink
Merge pull request #340 from reduxjs/feature/v3.0-esm-build
Browse files Browse the repository at this point in the history
  • Loading branch information
markerikson committed Jan 21, 2023
2 parents 7317347 + a1e9c32 commit e3d4529
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { NODE_ENV, BABEL_ENV } = process.env
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'

module.exports = {
export default {
presets: [
[
'@babel/preset-env',
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: 14.x
node-version: 16.x
cache: 'npm'

- name: Install deps
Expand All @@ -41,7 +41,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ts: ['3.9', '4.0', '4.1', '4.2', '4.3', '4.4', '4.5', 'next']
ts: ['4.2', '4.3', '4.4', '4.5', '4.6', '4.7', '4.8', '4.9']

steps:
- name: Checkout code
Expand Down
10 changes: 5 additions & 5 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */

module.exports = {
export default {
preset: 'ts-jest',
testEnvironment: 'node',
coverageDirectory: './coverage/',
collectCoverage: true,
testRegex: 'test/test.ts',
globals: {
'ts-jest': {
tsconfig: './test/tsconfig.json',
},
},
};
tsconfig: './test/tsconfig.json'
}
}
}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 13 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "redux-thunk",
"version": "2.4.2",
"version": "3.0.0-alpha.1",
"license": "MIT",
"description": "Thunk middleware for Redux.",
"repository": "github:reduxjs/redux-thunk",
Expand All @@ -14,9 +14,18 @@
"flux"
],
"author": "Dan Abramov <dan.abramov@me.com>",
"type": "module",
"main": "lib/index.js",
"module": "es/index.js",
"types": "es/index.d.ts",
"exports": {
"./package.json": "./package.json",
".": {
"types": "./es/index.d.ts",
"import": "./es/index.js",
"default": "./lib/index.js"
}
},
"sideEffects": false,
"files": [
"lib",
Expand All @@ -28,9 +37,9 @@
"scripts": {
"clean": "rimraf lib dist es",
"prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build",
"format": "prettier --write {src,test,typescript_test}/**/*.{js,ts}",
"format:check": "prettier --check {src,test,typescript_test}/**/*.{js,ts}",
"lint": "eslint '{src,test,typescript_test}/**/*.{js,ts}'",
"format": "prettier --write \"{src,test,typescript_test}/**/*.{js,ts}\"",
"format:check": "prettier --check \"{src,test,typescript_test}/**/*.{js,ts}\"",
"lint": "eslint \"{src,test,typescript_test}/**/*.{js,ts}\"",
"test": "jest",
"test:cov": "jest --coverage",
"test:typescript": "npm run test:typescript:main && npm run test:typescript:extended",
Expand Down
8 changes: 3 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function createThunkMiddleware<
return middleware
}

const thunk = createThunkMiddleware() as ThunkMiddleware & {
export const thunk = createThunkMiddleware() as ThunkMiddleware & {
withExtraArgument<
ExtraThunkArg,
State = any,
Expand All @@ -46,8 +46,6 @@ const thunk = createThunkMiddleware() as ThunkMiddleware & {
): ThunkMiddleware<State, BasicAction, ExtraThunkArg>
}

// Attach the factory function so users can create a customized version
// Export the factory function so users can create a customized version
// with whatever "extra arg" they want to inject into their thunks
thunk.withExtraArgument = createThunkMiddleware

export default thunk
export const withExtraArgument = createThunkMiddleware
4 changes: 2 additions & 2 deletions test/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import thunkMiddleware from '../src/index'
import { thunk as thunkMiddleware, withExtraArgument } from '../src/index'

describe('thunk middleware', () => {
const doDispatch = () => {}
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('thunk middleware', () => {
it('must pass the third argument', done => {
const extraArg = { lol: true }
// @ts-ignore
thunkMiddleware.withExtraArgument(extraArg)({
withExtraArgument(extraArg)({
dispatch: doDispatch,
getState: doGetState
})()((dispatch: any, getState: any, arg: any) => {
Expand Down
2 changes: 1 addition & 1 deletion typescript_test/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { applyMiddleware, bindActionCreators, createStore } from 'redux'
import type { Action, AnyAction } from 'redux'

import thunk from '../src/index'
import { thunk } from '../src/index'
import type {
ThunkAction,
ThunkActionDispatch,
Expand Down
2 changes: 1 addition & 1 deletion typescript_test/typescript_extended/extended-redux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Dispatch
} from 'redux'

import thunk from '../../src/index'
import { thunk } from '../../src/index'
import type {
ThunkAction,
ThunkActionDispatch,
Expand Down

0 comments on commit e3d4529

Please sign in to comment.