Skip to content

Commit 7dc3625

Browse files
committed
Merge pull request #233 from rackt/commonjs-again
Use CommonJS modules until ES3 transforms are fixed
2 parents 25694df + caae2e1 commit 7dc3625

File tree

8 files changed

+34
-22
lines changed

8 files changed

+34
-22
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
},
4444
"homepage": "https://github.com/gaearon/react-redux",
4545
"devDependencies": {
46-
"babel-cli": "^6.3.15",
47-
"babel-core": "^6.1.20",
46+
"babel-cli": "^6.3.17",
47+
"babel-core": "^6.3.26",
4848
"babel-eslint": "^5.0.0-beta4",
4949
"babel-loader": "^6.2.0",
5050
"babel-plugin-transform-decorators-legacy": "^1.2.0",
51-
"babel-preset-es2015-loose": "^6.1.3",
51+
"babel-preset-es2015-loose": "^6.1.4",
5252
"babel-preset-react": "^6.3.13",
5353
"babel-preset-stage-0": "^6.3.13",
5454
"eslint": "^1.7.1",

src/components/Provider.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Component, PropTypes, Children } from 'react'
2-
import storeShape from '../utils/storeShape'
1+
const { Component, PropTypes, Children } = require('react')
2+
const storeShape = require('../utils/storeShape')
33

44
let didWarnAboutReceivingStore = false
55
function warnAboutReceivingStore() {
@@ -17,7 +17,7 @@ function warnAboutReceivingStore() {
1717
)
1818
}
1919

20-
export default class Provider extends Component {
20+
class Provider extends Component {
2121
getChildContext() {
2222
return { store: this.store }
2323
}
@@ -49,3 +49,5 @@ Provider.propTypes = {
4949
Provider.childContextTypes = {
5050
store: storeShape.isRequired
5151
}
52+
53+
module.exports = Provider

src/components/connect.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Component, createElement } from 'react'
2-
import storeShape from '../utils/storeShape'
3-
import shallowEqual from '../utils/shallowEqual'
4-
import isPlainObject from '../utils/isPlainObject'
5-
import wrapActionCreators from '../utils/wrapActionCreators'
6-
import hoistStatics from 'hoist-non-react-statics'
7-
import invariant from 'invariant'
1+
const { Component, createElement } = require('react')
2+
const storeShape = require('../utils/storeShape')
3+
const shallowEqual = require('../utils/shallowEqual')
4+
const isPlainObject = require('../utils/isPlainObject')
5+
const wrapActionCreators = require('../utils/wrapActionCreators')
6+
const hoistStatics = require('hoist-non-react-statics')
7+
const invariant = require('invariant')
88

99
const defaultMapStateToProps = state => ({}) // eslint-disable-line no-unused-vars
1010
const defaultMapDispatchToProps = dispatch => ({ dispatch })
@@ -21,7 +21,7 @@ function getDisplayName(WrappedComponent) {
2121
// Helps track hot reloading.
2222
let nextVersion = 0
2323

24-
export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) {
24+
function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) {
2525
const shouldSubscribe = Boolean(mapStateToProps)
2626
const finalMapStateToProps = mapStateToProps || defaultMapStateToProps
2727
const finalMapDispatchToProps = isPlainObject(mapDispatchToProps) ?
@@ -273,3 +273,5 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps,
273273
return hoistStatics(Connect, WrappedComponent)
274274
}
275275
}
276+
277+
module.exports = connect

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Provider from './components/Provider'
2-
import connect from './components/connect'
1+
const Provider = require('./components/Provider')
2+
const connect = require('./components/connect')
33

4-
export { Provider, connect }
4+
module.exports = { Provider, connect }

src/utils/isPlainObject.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const fnToString = (fn) => Function.prototype.toString.call(fn)
44
* @param {any} obj The object to inspect.
55
* @returns {boolean} True if the argument appears to be a plain object.
66
*/
7-
export default function isPlainObject(obj) {
7+
function isPlainObject(obj) {
88
if (!obj || typeof obj !== 'object') {
99
return false
1010
}
@@ -23,3 +23,5 @@ export default function isPlainObject(obj) {
2323
&& constructor instanceof constructor
2424
&& fnToString(constructor) === fnToString(Object)
2525
}
26+
27+
module.exports = isPlainObject

src/utils/shallowEqual.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function shallowEqual(objA, objB) {
1+
function shallowEqual(objA, objB) {
22
if (objA === objB) {
33
return true
44
}
@@ -21,3 +21,5 @@ export default function shallowEqual(objA, objB) {
2121

2222
return true
2323
}
24+
25+
module.exports = shallowEqual

src/utils/storeShape.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
import { PropTypes } from 'react'
1+
const { PropTypes } = require('react')
22

3-
export default PropTypes.shape({
3+
const storeShape = PropTypes.shape({
44
subscribe: PropTypes.func.isRequired,
55
dispatch: PropTypes.func.isRequired,
66
getState: PropTypes.func.isRequired
77
})
8+
9+
module.exports = storeShape

src/utils/wrapActionCreators.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { bindActionCreators } from 'redux'
22

3-
export default function wrapActionCreators(actionCreators) {
3+
function wrapActionCreators(actionCreators) {
44
return dispatch => bindActionCreators(actionCreators, dispatch)
55
}
6+
7+
module.exports = wrapActionCreators

0 commit comments

Comments
 (0)