Actually build react-dom file with the build
Paul O’Shannessy committed
Sep 8, 2015 at 10:13 UTC
b2ca3349c27b57b1e9462944cbe4aaaf76783d2b
5 files changed
+63
.eslintignore
+1
@@ -16,3 +16,4 @@ packages/react-codemod/test/
16
packages/react-codemod/scripts/
17
packages/react-codemod/build/
18
packages/react-codemod/node_modules/
19
+vendor/react-dom.js
Gruntfile.js
+2
@@ -107,6 +107,7 @@ module.exports = function(grunt) {
107
'build-modules',
108
'npm-react:release',
109
]);
110
+ grunt.registerTask('build:react-dom', require('./grunt/tasks/react-dom'));
111
112
grunt.registerTask('test', ['jest']);
113
grunt.registerTask('npm:test', ['build', 'npm:pack']);
@@ -124,6 +125,7 @@ module.exports = function(grunt) {
125
'browserify:addons',
126
'browserify:min',
127
'browserify:addonsMin',
128
+ 'build:react-dom',
129
'npm-react:release',
130
'npm-react:pack',
131
'npm-react-dom:pack',
grunt/tasks/react-dom.js
new
+27
@@ -0,0 +1,27 @@
1
+'use strict';
2
+
3
+var grunt = require('grunt');
4
+var UglifyJS = require('uglify-js');
5
+
6
+var LICENSE_TEMPLATE =
7
+ grunt.file.read('./grunt/data/header-template-extended.txt');
8
+
9
+module.exports = function() {
10
+ var templateData = {
11
+ package: 'ReactDOM',
12
+ version: grunt.config.data.pkg.version,
13
+ };
14
+ var header = grunt.template.process(
15
+ LICENSE_TEMPLATE,
16
+ {data: templateData}
17
+ );
18
+ var src = grunt.file.read('vendor/react-dom.js');
19
+ grunt.file.write(
20
+ 'build/react-dom.js',
21
+ header + src
22
+ );
23
+ grunt.file.write(
24
+ 'build/react-dom.min.js',
25
+ header + UglifyJS.minify(src, {fromString: true}).code
26
+ );
27
+};
src/React.js
+2
@@ -64,4 +64,6 @@ assign(React, {
64
),
65
});
66
67
+React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM;
68
+
69
module.exports = React;
vendor/react-dom.js
new
+31
@@ -0,0 +1,31 @@
1
+// Based off https://github.com/ForbesLindesay/umd/blob/master/template.js
2
+;(function(f) {
3
+ // CommonJS
4
+ if (typeof exports === "object" && typeof module !== "undefined") {
5
+ module.exports = f(require('react'));
6
+
7
+ // RequireJS
8
+ } else if (typeof define === "function" && define.amd) {
9
+ define(['react'], f);
10
+
11
+ // <script>
12
+ } else {
13
+ var g
14
+ if (typeof window !== "undefined") {
15
+ g = window;
16
+ } else if (typeof global !== "undefined") {
17
+ g = global;
18
+ } else if (typeof self !== "undefined") {
19
+ g = self;
20
+ } else {
21
+ // works providing we're not in "use strict";
22
+ // needed for Java 8 Nashorn
23
+ // see https://github.com/facebook/react/issues/3037
24
+ g = this;
25
+ }
26
+ g.ReactDOM = f(g.React);
27
+ }
28
+
29
+})(function(React) {
30
+ return React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
31
+});