diff --git a/src/index.js b/src/index.js index 1b11c797147..1636ed3ef86 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,16 @@ import combineReducers from './utils/combineReducers' import bindActionCreators from './utils/bindActionCreators' import applyMiddleware from './utils/applyMiddleware' import compose from './utils/compose' +import isMinifiedOutsideOfProduction from './utils/isMinifiedOutsideOfProduction' + +if (isMinifiedOutsideOfProduction()) { + var warningMessage = 'You are utilzing minified code outside of NODE_ENV === \'production\'. ' + + 'This means that you are running a slower development only build of Redux. ' + + 'Consult tools such as loose-envify (https://github.com/zertosh/loose-envify) for browserify ' + + 'and DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) ' + + 'to build with proper NODE_ENV' + console.error(warningMessage) +} export { createStore, diff --git a/src/utils/isMinifiedOutsideOfProduction.js b/src/utils/isMinifiedOutsideOfProduction.js new file mode 100644 index 00000000000..da44ed64e3c --- /dev/null +++ b/src/utils/isMinifiedOutsideOfProduction.js @@ -0,0 +1,18 @@ + /** + * This is a function that exists for the function isMinifiedOutsideOfProduction to perform a check. + * If this function does not maintain its name and the NODE_ENV is not === 'production' + * then we know the user is using minified code outside of production and we should warn + */ +function isCrushed() { + return true +} +/** + * Function that checks name of isCrushed and NODE_ENV + * to determine if code is minified outside of production + * + * @returns {Boolean} A boolean value that is based on whether or not code + * has been minifed outside side of NODE_ENV === 'production' + */ +export default function isMinifiedOutsideOfProduction() { + return isCrushed.name !== 'isCrushed' && process.env.NODE_ENV !== 'production' +} \ No newline at end of file