Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ examples/
build/
scripts/bench/bench-*.js
vendor/react-dom.js
vendor/react-dom-server.js
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ script:
-F "react-with-addons.min=@build/react-with-addons.min.js" \
-F "react-dom=@build/react-dom.js" \
-F "react-dom.min=@build/react-dom.min.js" \
-F "react-dom-server=@build/react-dom-server.js"
-F "react-dom-server.min=@build/react-dom-server.min.js"
-F "npm-react=@build/packages/react.tgz" \
-F "npm-react-dom=@build/packages/react-dom.tgz" \
-F "commit=$TRAVIS_COMMIT" \
Expand Down
2 changes: 2 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ module.exports = function(grunt) {
'npm-react:release',
]);
grunt.registerTask('build:react-dom', require('./grunt/tasks/react-dom'));
grunt.registerTask('build:react-dom-server', require('./grunt/tasks/react-dom-server'));

grunt.registerTask('test', ['jest']);
grunt.registerTask('npm:test', ['build', 'npm:pack']);
Expand All @@ -129,6 +130,7 @@ module.exports = function(grunt) {
'browserify:min',
'browserify:addonsMin',
'build:react-dom',
'build:react-dom-server',
'npm-react:release',
'npm-react:pack',
'npm-react-dom:release',
Expand Down
27 changes: 27 additions & 0 deletions grunt/tasks/react-dom-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

var grunt = require('grunt');
var UglifyJS = require('uglify-js');

var LICENSE_TEMPLATE =
grunt.file.read('./grunt/data/header-template-extended.txt');

module.exports = function() {
var templateData = {
package: 'ReactDOMServer',
version: grunt.config.data.pkg.version,
};
var header = grunt.template.process(
LICENSE_TEMPLATE,
{data: templateData}
);
var src = grunt.file.read('vendor/react-dom-server.js');
grunt.file.write(
'build/react-dom-server.js',
header + src
);
grunt.file.write(
'build/react-dom-server.min.js',
header + UglifyJS.minify(src, {fromString: true}).code
);
};
1 change: 1 addition & 0 deletions src/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,6 @@ assign(React, {
});

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SECRET_DO_NOT_USE_OR_YOU_WILL_BE_FIRED made sense when we were migrating and you really would break stuff. But if we're adding this as an explicit hook to allow various environments, it shouldn't be a severe variable name (IMHO) - Or if this is just for the 0.14.3 update, perhaps it makes sense. cc @zpao @spicyj for thoughts.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point is that the react-dom-server.js package we provide uses this secret key, but you're meant to never type it in your own code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, this is fine as is. We are not planning on making these properties condoned in any public use. They are subject to breaking (and I might just change them in the next release to ensure this does break)


module.exports = React;
31 changes: 31 additions & 0 deletions vendor/react-dom-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Based off https://github.com/ForbesLindesay/umd/blob/master/template.js
;(function(f) {
// CommonJS
if (typeof exports === "object" && typeof module !== "undefined") {
module.exports = f(require('react'));

// RequireJS
} else if (typeof define === "function" && define.amd) {
define(['react'], f);

// <script>
} else {
var g
if (typeof window !== "undefined") {
g = window;
} else if (typeof global !== "undefined") {
g = global;
} else if (typeof self !== "undefined") {
g = self;
} else {
// works providing we're not in "use strict";
// needed for Java 8 Nashorn
// see https://github.com/facebook/react/issues/3037
g = this;
}
g.ReactDOM = f(g.React);
}

})(function(React) {
return React.__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
});