Skip to content

Commit

Permalink
Merge pull request facebook#5381 from kevinrobinson/react-dom-server-…
Browse files Browse the repository at this point in the history
…package

Add additional secret property to build artifact for react-dom-server
  • Loading branch information
zpao committed Nov 18, 2015
2 parents e03df26 + 45c612e commit c07b304
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
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 @@ -110,6 +110,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 @@ -127,6 +128,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;

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;
});

0 comments on commit c07b304

Please sign in to comment.