diff --git a/npm-react-core/ReactJSErrors.js b/npm-react-core/ReactJSErrors.js new file mode 100644 index 0000000000..e2ef349bb0 --- /dev/null +++ b/npm-react-core/ReactJSErrors.js @@ -0,0 +1,38 @@ +var copyProperties = require('./lib/copyProperties'); + +var WARNING_MESSAGE = ( + 'It looks like you\'re trying to use jeffbski\'s React.js project.\n' + + 'The `react` npm package now points to the React JavaScript library for ' + + 'building user interfaces, not the React.js project for managing asynchronous ' + + 'control flow. If you\'re looking for that library, please npm install reactjs.' +); + +function error() { + throw new Error(WARNING_MESSAGE); +} + +// Model the React.js project's public interface exactly. + +function ReactJSShim() { + error(); +}; + +ReactJSShim.logEvents = error; +ReactJSShim.resolvePromises = error; +ReactJSShim.trackTasks = error; +ReactJSShim.createEventCollector = error; + +// These could throw using defineProperty() but supporting older browsers will +// be painful. Additionally any error messages around this will contain the string +// so I think this is sufficient. +ReactJSShim.options = WARNING_MESSAGE; +ReactJSShim.events = WARNING_MESSAGE; + +var ReactJSErrors = { + wrap: function(module) { + copyProperties(ReactJSShim, module); + return ReactJSShim; + } +}; + +module.exports = ReactJSErrors; \ No newline at end of file diff --git a/npm-react-core/addons.js b/npm-react-core/addons.js index 21c5f83950..e74522f76d 100644 --- a/npm-react-core/addons.js +++ b/npm-react-core/addons.js @@ -1 +1,4 @@ module.exports = require('./lib/ReactWithAddons'); +if ('production' !== process.env.NODE_ENV) { + module.exports = require('./ReactJSErrors').wrap(module.exports); +} diff --git a/npm-react-core/package.json b/npm-react-core/package.json index 29bca75384..a43e9b0fad 100644 --- a/npm-react-core/package.json +++ b/npm-react-core/package.json @@ -1,5 +1,5 @@ { - "name": "react-core", + "name": "react", "version": "0.6.0-alpha", "keywords": [ "react" diff --git a/npm-react-core/react.js b/npm-react-core/react.js index 08da025716..b682b0397f 100644 --- a/npm-react-core/react.js +++ b/npm-react-core/react.js @@ -1 +1,4 @@ module.exports = require('./lib/React'); +if ('production' !== process.env.NODE_ENV) { + module.exports = require('./ReactJSErrors').wrap(module.exports); +}