Skip to content

Commit 86f3f91

Browse files
authored
Merge branch 'typescript-port' into ts-port-mdtp
2 parents b1e300f + b8a118a commit 86f3f91

18 files changed

+714
-535
lines changed

.babelrc.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,29 @@
11
const { NODE_ENV, BABEL_ENV } = process.env
22
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs'
3-
const loose = true
43

54
module.exports = {
65
presets: [
7-
['@babel/env', { loose, modules: false }],
6+
[
7+
'@babel/preset-env',
8+
{
9+
targets: {
10+
esmodules: true,
11+
},
12+
// Use the equivalent of `babel-preset-modules`
13+
bugfixes: true,
14+
modules: false,
15+
loose: true,
16+
},
17+
],
818
'@babel/preset-typescript',
919
],
1020
plugins: [
1121
['@babel/proposal-decorators', { legacy: true }],
12-
['@babel/proposal-object-rest-spread', { loose }],
1322
'@babel/transform-react-jsx',
14-
cjs && ['@babel/transform-modules-commonjs', { loose }],
23+
['@babel/plugin-proposal-class-properties', { loose: true }],
24+
['@babel/plugin-proposal-private-methods', { loose: true }],
25+
['@babel/plugin-proposal-private-property-in-object', { loose: true }],
26+
cjs && ['@babel/transform-modules-commonjs'],
1527
[
1628
'@babel/transform-runtime',
1729
{
@@ -22,4 +34,7 @@ module.exports = {
2234
},
2335
],
2436
].filter(Boolean),
37+
assumptions: {
38+
enumerableModuleMeta: true,
39+
},
2540
}

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
"es"
2424
],
2525
"scripts": {
26-
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --extensions \".js,.ts\" --out-dir lib",
27-
"build:es": "babel src --extensions \".js,.ts\" --out-dir es",
26+
"build:commonjs": "cross-env BABEL_ENV=commonjs babel src --extensions \".js,.ts,.tsx\" --out-dir lib",
27+
"build:es": "babel src --extensions \".js,.ts,.tsx\" --out-dir es",
2828
"build:umd": "cross-env NODE_ENV=development rollup -c -o dist/react-redux.js",
2929
"build:umd:min": "cross-env NODE_ENV=production rollup -c -o dist/react-redux.min.js",
3030
"build:types": "tsc",

rollup.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const config = {
3333
}),
3434
replace({
3535
'process.env.NODE_ENV': JSON.stringify(env),
36+
preventAssignment: true,
3637
}),
3738
commonjs(),
3839
],

src/components/Context.ts

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
22
import { Action, AnyAction, Store } from 'redux'
33
import type { FixTypeLater } from '../types'
4-
import type Subscription from '../utils/Subscription'
4+
import type { Subscription } from '../utils/Subscription'
55

66
export interface ReactReduxContextValue<
77
SS = FixTypeLater,
@@ -11,9 +11,10 @@ export interface ReactReduxContextValue<
1111
subscription: Subscription
1212
}
1313

14-
export const ReactReduxContext = /*#__PURE__*/ React.createContext<ReactReduxContextValue | null>(
15-
null
16-
)
14+
export const ReactReduxContext =
15+
/*#__PURE__*/ React.createContext<ReactReduxContextValue | null>(null)
16+
17+
export type ReactReduxContextInstance = typeof ReactReduxContext
1718

1819
if (process.env.NODE_ENV !== 'production') {
1920
ReactReduxContext.displayName = 'ReactRedux'

src/components/Provider.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Context, ReactNode, useMemo } from 'react'
22
import { ReactReduxContext, ReactReduxContextValue } from './Context'
3-
import Subscription from '../utils/Subscription'
3+
import { createSubscription } from '../utils/Subscription'
44
import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
55
import type { FixTypeLater } from '../types'
66
import { Action, AnyAction, Store } from 'redux'
@@ -21,7 +21,7 @@ interface ProviderProps<A extends Action = AnyAction> {
2121

2222
function Provider({ store, context, children }: ProviderProps) {
2323
const contextValue = useMemo(() => {
24-
const subscription = new Subscription(store)
24+
const subscription = createSubscription(store)
2525
subscription.onStateChange = subscription.notifyNestedSubs
2626
return {
2727
store,

0 commit comments

Comments
 (0)