From d17091ddebf317173eb30e3ab4a8e28e124c8f50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Thu, 24 Mar 2016 11:00:38 -0700 Subject: [PATCH] Make Browserify-specific modules to remove DOM dependencies from npm package --- grunt/config/browserify.js | 8 +++--- packages/react/lib/React.native.js | 5 ---- src/addons/ReactWithAddons.js | 7 ----- .../{ReactIsomorphic.js => React.js} | 2 +- src/{React.js => umd/ReactUMDEntry.js} | 16 +++++------- src/umd/ReactWithAddonsUMDEntry.js | 26 +++++++++++++++++++ 6 files changed, 38 insertions(+), 26 deletions(-) delete mode 100644 packages/react/lib/React.native.js rename src/isomorphic/{ReactIsomorphic.js => React.js} (98%) rename src/{React.js => umd/ReactUMDEntry.js} (63%) create mode 100644 src/umd/ReactWithAddonsUMDEntry.js diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index f6d43baf34..bfcb01ddda 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -50,7 +50,7 @@ function simpleBannerify(src) { // Our basic config which we'll add to to make our other builds var basic = { entries: [ - './build/modules/React.js', + './build/modules/ReactUMDEntry.js', ], outfile: './build/react.js', debug: false, @@ -63,7 +63,7 @@ var basic = { var min = { entries: [ - './build/modules/React.js', + './build/modules/ReactUMDEntry.js', ], outfile: './build/react.min.js', debug: false, @@ -81,7 +81,7 @@ var min = { var addons = { entries: [ - './build/modules/ReactWithAddons.js', + './build/modules/ReactWithAddonsUMDEntry.js', ], outfile: './build/react-with-addons.js', debug: false, @@ -94,7 +94,7 @@ var addons = { var addonsMin = { entries: [ - './build/modules/ReactWithAddons.js', + './build/modules/ReactWithAddonsUMDEntry.js', ], outfile: './build/react-with-addons.min.js', debug: false, diff --git a/packages/react/lib/React.native.js b/packages/react/lib/React.native.js deleted file mode 100644 index 36bf5a4655..0000000000 --- a/packages/react/lib/React.native.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -// TODO: Once we remove the DOM bits from React, this shim can go away. - -module.exports = require('./ReactIsomorphic'); diff --git a/src/addons/ReactWithAddons.js b/src/addons/ReactWithAddons.js index 755a1dc8c2..bd13ea495f 100644 --- a/src/addons/ReactWithAddons.js +++ b/src/addons/ReactWithAddons.js @@ -9,13 +9,6 @@ * @providesModule ReactWithAddons */ -/** - * This module exists purely in the open source project, and is meant as a way - * to create a separate standalone build of React. This build has "addons", or - * functionality we've built and think might be useful but doesn't have a good - * place to live inside React core. - */ - 'use strict'; var LinkedStateMixin = require('LinkedStateMixin'); diff --git a/src/isomorphic/ReactIsomorphic.js b/src/isomorphic/React.js similarity index 98% rename from src/isomorphic/ReactIsomorphic.js rename to src/isomorphic/React.js index 8eca054b79..5037feb7a4 100644 --- a/src/isomorphic/ReactIsomorphic.js +++ b/src/isomorphic/React.js @@ -6,7 +6,7 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule ReactIsomorphic + * @providesModule React */ 'use strict'; diff --git a/src/React.js b/src/umd/ReactUMDEntry.js similarity index 63% rename from src/React.js rename to src/umd/ReactUMDEntry.js index 5aa15e8c8b..ee02afd38a 100644 --- a/src/React.js +++ b/src/umd/ReactUMDEntry.js @@ -6,23 +6,21 @@ * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. * - * @providesModule React + * @providesModule ReactUMDEntry */ 'use strict'; var ReactDOM = require('ReactDOM'); var ReactDOMServer = require('ReactDOMServer'); -var ReactIsomorphic = require('ReactIsomorphic'); +var React = require('React'); var assign = require('Object.assign'); // `version` will be added here by ReactIsomorphic. -var React = {}; +var ReactUMDEntry = assign({ + __SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOM, + __SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOMServer, +}, React); -assign(React, ReactIsomorphic); - -React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM; -React.__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOMServer; - -module.exports = React; +module.exports = ReactUMDEntry; diff --git a/src/umd/ReactWithAddonsUMDEntry.js b/src/umd/ReactWithAddonsUMDEntry.js new file mode 100644 index 0000000000..e1934f2a59 --- /dev/null +++ b/src/umd/ReactWithAddonsUMDEntry.js @@ -0,0 +1,26 @@ +/** + * Copyright 2013-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule ReactWithAddonsUMDEntry + */ + +'use strict'; + +var ReactDOM = require('ReactDOM'); +var ReactDOMServer = require('ReactDOMServer'); +var ReactWithAddons = require('ReactWithAddons'); + +var assign = require('Object.assign'); + +// `version` will be added here by ReactIsomorphic. +var ReactWithAddonsUMDEntry = assign({ + __SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOM, + __SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactDOMServer, +}, ReactWithAddons); + +module.exports = ReactWithAddonsUMDEntry;