Skip to content

Commit e3d4529

Browse files
authored
Merge pull request #340 from reduxjs/feature/v3.0-esm-build
2 parents 7317347 + a1e9c32 commit e3d4529

File tree

9 files changed

+30
-23
lines changed

9 files changed

+30
-23
lines changed

.babelrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const { NODE_ENV, BABEL_ENV } = process.env
22
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
33

4-
module.exports = {
4+
export default {
55
presets: [
66
[
77
'@babel/preset-env',

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Set up Node
1919
uses: actions/setup-node@v2
2020
with:
21-
node-version: 14.x
21+
node-version: 16.x
2222
cache: 'npm'
2323

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

4646
steps:
4747
- name: Checkout code

jest.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/** @type {import('@ts-jest/dist/types').InitialOptionsTsJest} */
22

3-
module.exports = {
3+
export default {
44
preset: 'ts-jest',
55
testEnvironment: 'node',
66
coverageDirectory: './coverage/',
77
collectCoverage: true,
88
testRegex: 'test/test.ts',
99
globals: {
1010
'ts-jest': {
11-
tsconfig: './test/tsconfig.json',
12-
},
13-
},
14-
};
11+
tsconfig: './test/tsconfig.json'
12+
}
13+
}
14+
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "redux-thunk",
3-
"version": "2.4.2",
3+
"version": "3.0.0-alpha.1",
44
"license": "MIT",
55
"description": "Thunk middleware for Redux.",
66
"repository": "github:reduxjs/redux-thunk",
@@ -14,9 +14,18 @@
1414
"flux"
1515
],
1616
"author": "Dan Abramov <[email protected]>",
17+
"type": "module",
1718
"main": "lib/index.js",
1819
"module": "es/index.js",
1920
"types": "es/index.d.ts",
21+
"exports": {
22+
"./package.json": "./package.json",
23+
".": {
24+
"types": "./es/index.d.ts",
25+
"import": "./es/index.js",
26+
"default": "./lib/index.js"
27+
}
28+
},
2029
"sideEffects": false,
2130
"files": [
2231
"lib",
@@ -28,9 +37,9 @@
2837
"scripts": {
2938
"clean": "rimraf lib dist es",
3039
"prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build",
31-
"format": "prettier --write {src,test,typescript_test}/**/*.{js,ts}",
32-
"format:check": "prettier --check {src,test,typescript_test}/**/*.{js,ts}",
33-
"lint": "eslint '{src,test,typescript_test}/**/*.{js,ts}'",
40+
"format": "prettier --write \"{src,test,typescript_test}/**/*.{js,ts}\"",
41+
"format:check": "prettier --check \"{src,test,typescript_test}/**/*.{js,ts}\"",
42+
"lint": "eslint \"{src,test,typescript_test}/**/*.{js,ts}\"",
3443
"test": "jest",
3544
"test:cov": "jest --coverage",
3645
"test:typescript": "npm run test:typescript:main && npm run test:typescript:extended",

src/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function createThunkMiddleware<
3636
return middleware
3737
}
3838

39-
const thunk = createThunkMiddleware() as ThunkMiddleware & {
39+
export const thunk = createThunkMiddleware() as ThunkMiddleware & {
4040
withExtraArgument<
4141
ExtraThunkArg,
4242
State = any,
@@ -46,8 +46,6 @@ const thunk = createThunkMiddleware() as ThunkMiddleware & {
4646
): ThunkMiddleware<State, BasicAction, ExtraThunkArg>
4747
}
4848

49-
// Attach the factory function so users can create a customized version
49+
// Export the factory function so users can create a customized version
5050
// with whatever "extra arg" they want to inject into their thunks
51-
thunk.withExtraArgument = createThunkMiddleware
52-
53-
export default thunk
51+
export const withExtraArgument = createThunkMiddleware

test/test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import thunkMiddleware from '../src/index'
1+
import { thunk as thunkMiddleware, withExtraArgument } from '../src/index'
22

33
describe('thunk middleware', () => {
44
const doDispatch = () => {}
@@ -92,7 +92,7 @@ describe('thunk middleware', () => {
9292
it('must pass the third argument', done => {
9393
const extraArg = { lol: true }
9494
// @ts-ignore
95-
thunkMiddleware.withExtraArgument(extraArg)({
95+
withExtraArgument(extraArg)({
9696
dispatch: doDispatch,
9797
getState: doGetState
9898
})()((dispatch: any, getState: any, arg: any) => {

typescript_test/typescript.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { applyMiddleware, bindActionCreators, createStore } from 'redux'
33
import type { Action, AnyAction } from 'redux'
44

5-
import thunk from '../src/index'
5+
import { thunk } from '../src/index'
66
import type {
77
ThunkAction,
88
ThunkActionDispatch,

typescript_test/typescript_extended/extended-redux.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Dispatch
1010
} from 'redux'
1111

12-
import thunk from '../../src/index'
12+
import { thunk } from '../../src/index'
1313
import type {
1414
ThunkAction,
1515
ThunkActionDispatch,

0 commit comments

Comments
 (0)