From f7c5a42d2270e6902337da93eeb09be505e35889 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 28 Dec 2015 21:58:49 +0000 Subject: [PATCH 1/2] Bump packages --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a2fc81008..48d6448ec 100644 --- a/package.json +++ b/package.json @@ -43,12 +43,12 @@ }, "homepage": "https://github.com/gaearon/react-redux", "devDependencies": { - "babel-cli": "^6.3.15", - "babel-core": "^6.1.20", + "babel-cli": "^6.3.17", + "babel-core": "^6.3.26", "babel-eslint": "^5.0.0-beta4", "babel-loader": "^6.2.0", "babel-plugin-transform-decorators-legacy": "^1.2.0", - "babel-preset-es2015-loose": "^6.1.3", + "babel-preset-es2015-loose": "^6.1.4", "babel-preset-react": "^6.3.13", "babel-preset-stage-0": "^6.3.13", "eslint": "^1.7.1", From caae2e1d53775b89716683f7d6a5d8302cad5a87 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 28 Dec 2015 22:09:30 +0000 Subject: [PATCH 2/2] Go back to using CommonJS modules Our current presets didn't include ES3 transforms by default, so IE8 support is broken. Normally we would have fixed it by adding a few plugins: * babel-plugin-transform-es3-member-expression-literals * babel-plugin-transform-es3-property-literals Unfortunately there is a [bug in Babel](https://phabricator.babeljs.io/T2817) that prevents them from working correctly in certain cases with `export default` declarations. Until this is resolved, we will go back to using CommonJS modules internally. --- src/components/Provider.js | 8 +++++--- src/components/connect.js | 18 ++++++++++-------- src/index.js | 6 +++--- src/utils/isPlainObject.js | 4 +++- src/utils/shallowEqual.js | 4 +++- src/utils/storeShape.js | 6 ++++-- src/utils/wrapActionCreators.js | 4 +++- 7 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/components/Provider.js b/src/components/Provider.js index d0e5ed7f0..b62c0e6b1 100644 --- a/src/components/Provider.js +++ b/src/components/Provider.js @@ -1,5 +1,5 @@ -import { Component, PropTypes, Children } from 'react' -import storeShape from '../utils/storeShape' +const { Component, PropTypes, Children } = require('react') +const storeShape = require('../utils/storeShape') let didWarnAboutReceivingStore = false function warnAboutReceivingStore() { @@ -17,7 +17,7 @@ function warnAboutReceivingStore() { ) } -export default class Provider extends Component { +class Provider extends Component { getChildContext() { return { store: this.store } } @@ -49,3 +49,5 @@ Provider.propTypes = { Provider.childContextTypes = { store: storeShape.isRequired } + +module.exports = Provider diff --git a/src/components/connect.js b/src/components/connect.js index a028b2f97..e9fbc06e5 100644 --- a/src/components/connect.js +++ b/src/components/connect.js @@ -1,10 +1,10 @@ -import { Component, createElement } from 'react' -import storeShape from '../utils/storeShape' -import shallowEqual from '../utils/shallowEqual' -import isPlainObject from '../utils/isPlainObject' -import wrapActionCreators from '../utils/wrapActionCreators' -import hoistStatics from 'hoist-non-react-statics' -import invariant from 'invariant' +const { Component, createElement } = require('react') +const storeShape = require('../utils/storeShape') +const shallowEqual = require('../utils/shallowEqual') +const isPlainObject = require('../utils/isPlainObject') +const wrapActionCreators = require('../utils/wrapActionCreators') +const hoistStatics = require('hoist-non-react-statics') +const invariant = require('invariant') const defaultMapStateToProps = state => ({}) // eslint-disable-line no-unused-vars const defaultMapDispatchToProps = dispatch => ({ dispatch }) @@ -21,7 +21,7 @@ function getDisplayName(WrappedComponent) { // Helps track hot reloading. let nextVersion = 0 -export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) { +function connect(mapStateToProps, mapDispatchToProps, mergeProps, options = {}) { const shouldSubscribe = Boolean(mapStateToProps) const finalMapStateToProps = mapStateToProps || defaultMapStateToProps const finalMapDispatchToProps = isPlainObject(mapDispatchToProps) ? @@ -273,3 +273,5 @@ export default function connect(mapStateToProps, mapDispatchToProps, mergeProps, return hoistStatics(Connect, WrappedComponent) } } + +module.exports = connect diff --git a/src/index.js b/src/index.js index ad89eec2d..65a2e6c4a 100644 --- a/src/index.js +++ b/src/index.js @@ -1,4 +1,4 @@ -import Provider from './components/Provider' -import connect from './components/connect' +const Provider = require('./components/Provider') +const connect = require('./components/connect') -export { Provider, connect } +module.exports = { Provider, connect } diff --git a/src/utils/isPlainObject.js b/src/utils/isPlainObject.js index cb8e86144..5fc5ccc1c 100644 --- a/src/utils/isPlainObject.js +++ b/src/utils/isPlainObject.js @@ -4,7 +4,7 @@ const fnToString = (fn) => Function.prototype.toString.call(fn) * @param {any} obj The object to inspect. * @returns {boolean} True if the argument appears to be a plain object. */ -export default function isPlainObject(obj) { +function isPlainObject(obj) { if (!obj || typeof obj !== 'object') { return false } @@ -23,3 +23,5 @@ export default function isPlainObject(obj) { && constructor instanceof constructor && fnToString(constructor) === fnToString(Object) } + +module.exports = isPlainObject diff --git a/src/utils/shallowEqual.js b/src/utils/shallowEqual.js index 76df37841..e10c4ae52 100644 --- a/src/utils/shallowEqual.js +++ b/src/utils/shallowEqual.js @@ -1,4 +1,4 @@ -export default function shallowEqual(objA, objB) { +function shallowEqual(objA, objB) { if (objA === objB) { return true } @@ -21,3 +21,5 @@ export default function shallowEqual(objA, objB) { return true } + +module.exports = shallowEqual diff --git a/src/utils/storeShape.js b/src/utils/storeShape.js index 16b1b141a..c28b20d9e 100644 --- a/src/utils/storeShape.js +++ b/src/utils/storeShape.js @@ -1,7 +1,9 @@ -import { PropTypes } from 'react' +const { PropTypes } = require('react') -export default PropTypes.shape({ +const storeShape = PropTypes.shape({ subscribe: PropTypes.func.isRequired, dispatch: PropTypes.func.isRequired, getState: PropTypes.func.isRequired }) + +module.exports = storeShape diff --git a/src/utils/wrapActionCreators.js b/src/utils/wrapActionCreators.js index 349e03d0f..ad4f48947 100644 --- a/src/utils/wrapActionCreators.js +++ b/src/utils/wrapActionCreators.js @@ -1,5 +1,7 @@ import { bindActionCreators } from 'redux' -export default function wrapActionCreators(actionCreators) { +function wrapActionCreators(actionCreators) { return dispatch => bindActionCreators(actionCreators, dispatch) } + +module.exports = wrapActionCreators