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 @@ -16,3 +16,4 @@ packages/react-codemod/test/
packages/react-codemod/scripts/
packages/react-codemod/build/
packages/react-codemod/node_modules/
vendor/react-dom.js
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ script:
-F "transformer=@build/JSXTransformer.js" \
-F "react-with-addons=@build/react-with-addons.js" \
-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 "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 @@ -107,6 +107,7 @@ module.exports = function(grunt) {
'build-modules',
'npm-react:release',
]);
grunt.registerTask('build:react-dom', require('./grunt/tasks/react-dom'));

grunt.registerTask('test', ['jest']);
grunt.registerTask('npm:test', ['build', 'npm:pack']);
Expand All @@ -124,6 +125,7 @@ module.exports = function(grunt) {
'browserify:addons',
'browserify:min',
'browserify:addonsMin',
'build:react-dom',
'npm-react:release',
'npm-react:pack',
'npm-react-dom:pack',
Expand Down
36 changes: 16 additions & 20 deletions grunt/config/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,10 @@ var envifyDev = envify({NODE_ENV: process.env.NODE_ENV || 'development'});
var envifyProd = envify({NODE_ENV: process.env.NODE_ENV || 'production'});

var SIMPLE_TEMPLATE =
'/**\n\
* @PACKAGE@ v@VERSION@\n\
*/';
grunt.file.read('./grunt/data/header-template-short.txt');

var LICENSE_TEMPLATE =
'/**\n\
* @PACKAGE@ v@VERSION@\n\
*\n\
* Copyright 2013-2015, Facebook, Inc.\n\
* All rights reserved.\n\
*\n\
* This source code is licensed under the BSD-style license found in the\n\
* LICENSE file in the root directory of this source tree. An additional grant\n\
* of patent rights can be found in the PATENTS file in the same directory.\n\
*\n\
*/';
grunt.file.read('./grunt/data/header-template-extended.txt');

function minify(src) {
return UglifyJS.minify(src, {fromString: true}).code;
Expand All @@ -38,17 +26,25 @@ function minify(src) {
function bannerify(src) {
var version = grunt.config.data.pkg.version;
var packageName = this.data.packageName || this.data.standalone;
return LICENSE_TEMPLATE.replace('@PACKAGE@', packageName)
.replace('@VERSION@', version) +
'\n' + src;
return (
grunt.template.process(
LICENSE_TEMPLATE,
{data: {package: packageName, version: version}}
) +
src
);
}

function simpleBannerify(src) {
var version = grunt.config.data.pkg.version;
var packageName = this.data.packageName || this.data.standalone;
return SIMPLE_TEMPLATE.replace('@PACKAGE@', packageName)
.replace('@VERSION@', version) +
'\n' + src;
return (
grunt.template.process(
SIMPLE_TEMPLATE,
{data: {package: packageName, version: version}}
) +
src
);
}

// Our basic config which we'll add to to make our other builds
Expand Down
11 changes: 11 additions & 0 deletions grunt/data/header-template-extended.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* <%= package %> v<%= version %>
*
* Copyright 2013-2015, 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.
*
*/
3 changes: 3 additions & 0 deletions grunt/data/header-template-short.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/**
* <%= package %> v<%= version %>
*/
27 changes: 27 additions & 0 deletions grunt/tasks/react-dom.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: 'ReactDOM',
version: grunt.config.data.pkg.version,
};
var header = grunt.template.process(
LICENSE_TEMPLATE,
{data: templateData}
);
var src = grunt.file.read('vendor/react-dom.js');
grunt.file.write(
'build/react-dom.js',
header + src
);
grunt.file.write(
'build/react-dom.min.js',
header + UglifyJS.minify(src, {fromString: true}).code
);
};
1 change: 1 addition & 0 deletions grunt/tasks/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var BOWER_GLOB = [BOWER_PATH + '*.{js}'];
var BOWER_FILES = [
'react.js', 'react.min.js', 'JSXTransformer.js',
'react-with-addons.js', 'react-with-addons.min.js',
'react-dom.js', 'react-dom.min.js',
];
var GH_PAGES_PATH = '../react-gh-pages/';
var GH_PAGES_GLOB = [GH_PAGES_PATH + '*'];
Expand Down
2 changes: 2 additions & 0 deletions src/React.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,6 @@ assign(React, {
),
});

React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM;

module.exports = React;
31 changes: 31 additions & 0 deletions vendor/react-dom.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_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
});