Skip to content

Commit f1e947c

Browse files
committed
Build renderers into their individual npm packages
This copies modules into three separate packages instead of putting it all in React. The overlap in shared and between renderers gets duplicated. This allows the isomorphic package to stay minimal. It can also be used as a direct dependency without much risk. This also allow us to ship versions to each renderer independently and we can ship renderers without updating the main react package dependency.
1 parent 119739e commit f1e947c

File tree

10 files changed

+181
-34
lines changed

10 files changed

+181
-34
lines changed

grunt/config/browserify.js

+18-15
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@ var SECRET_INTERNALS_NAME = 'React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_
1717
var SECRET_DOM_INTERNALS_NAME = 'ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED';
1818

1919
var shimSharedModules = globalShim.configure({
20-
'./ReactCurrentOwner': SECRET_INTERNALS_NAME + '.ReactCurrentOwner',
21-
'./ReactComponentTreeDevtool': SECRET_INTERNALS_NAME + '.ReactComponentTreeDevtool',
20+
// Shared state
21+
'react/lib/ReactCurrentOwner': SECRET_INTERNALS_NAME + '.ReactCurrentOwner',
22+
'react/lib/ReactComponentTreeDevtool': SECRET_INTERNALS_NAME + '.ReactComponentTreeDevtool',
2223
// All these methods are shared are exposed.
23-
'./ReactElement': 'React',
24-
'./ReactPropTypes': 'React.PropTypes',
25-
'./ReactChildren': 'React.Children',
24+
// TODO: Update the source to just use the React module.
25+
'react/lib/React': 'React',
26+
'react/lib/ReactElement': 'React',
27+
'react/lib/ReactPropTypes': 'React.PropTypes',
28+
'react/lib/ReactChildren': 'React.Children',
2629
});
2730

2831
// Shim references to ReactDOM internals from addons.
2932
var shimDOM = globalShim.configure({
30-
'./ReactDOM': 'ReactDOM',
31-
'./ReactInstanceMap': SECRET_DOM_INTERNALS_NAME + '.ReactInstanceMap',
33+
'react-dom/lib/ReactDOM': 'ReactDOM',
34+
'react-dom/lib/ReactInstanceMap': SECRET_DOM_INTERNALS_NAME + '.ReactInstanceMap',
3235

3336
// TestUtils pulls in a bunch of internals.
3437
'./EventConstants': SECRET_DOM_INTERNALS_NAME + '.EventConstants',
@@ -84,7 +87,7 @@ function simpleBannerify(src) {
8487
// Our basic config which we'll add to to make our other builds
8588
var basic = {
8689
entries: [
87-
'./build/modules/ReactUMDEntry.js',
90+
'./build/node_modules/react/lib/ReactUMDEntry.js',
8891
],
8992
outfile: './build/react.js',
9093
debug: false,
@@ -97,7 +100,7 @@ var basic = {
97100

98101
var min = {
99102
entries: [
100-
'./build/modules/ReactUMDEntry.js',
103+
'./build/node_modules/react/lib/ReactUMDEntry.js',
101104
],
102105
outfile: './build/react.min.js',
103106
debug: false,
@@ -115,7 +118,7 @@ var min = {
115118

116119
var addons = {
117120
entries: [
118-
'./build/modules/ReactWithAddonsUMDEntry.js',
121+
'./build/node_modules/react/lib/ReactWithAddonsUMDEntry.js',
119122
],
120123
outfile: './build/react-with-addons.js',
121124
debug: false,
@@ -129,7 +132,7 @@ var addons = {
129132

130133
var addonsMin = {
131134
entries: [
132-
'./build/modules/ReactWithAddonsUMDEntry.js',
135+
'./build/node_modules/react/lib/ReactWithAddonsUMDEntry.js',
133136
],
134137
outfile: './build/react-with-addons.min.js',
135138
debug: false,
@@ -147,7 +150,7 @@ var addonsMin = {
147150
// The DOM Builds
148151
var dom = {
149152
entries: [
150-
'./build/modules/ReactDOMUMDEntry.js',
153+
'./build/node_modules/react-dom/lib/ReactDOMUMDEntry.js',
151154
],
152155
outfile: './build/react-dom.js',
153156
debug: false,
@@ -161,7 +164,7 @@ var dom = {
161164

162165
var domMin = {
163166
entries: [
164-
'./build/modules/ReactDOMUMDEntry.js',
167+
'./build/node_modules/react-dom/lib/ReactDOMUMDEntry.js',
165168
],
166169
outfile: './build/react-dom.min.js',
167170
debug: false,
@@ -179,7 +182,7 @@ var domMin = {
179182

180183
var domServer = {
181184
entries: [
182-
'./build/modules/ReactDOMServerUMDEntry.js',
185+
'./build/node_modules/react-dom/lib/ReactDOMServerUMDEntry.js',
183186
],
184187
outfile: './build/react-dom-server.js',
185188
debug: false,
@@ -193,7 +196,7 @@ var domServer = {
193196

194197
var domServerMin = {
195198
entries: [
196-
'./build/modules/ReactDOMServerUMDEntry.js',
199+
'./build/node_modules/react-dom/lib/ReactDOMServerUMDEntry.js',
197200
],
198201
outfile: './build/react-dom-server.min.js',
199202
debug: false,

grunt/tasks/npm-react-addons.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,55 @@ var path = require('path');
66

77
var addons = {
88
CSSTransitionGroup: {
9+
package: 'react',
910
module: 'ReactCSSTransitionGroup',
1011
name: 'css-transition-group',
1112
docs: 'animation',
1213
},
1314
LinkedStateMixin: {
15+
package: 'react',
1416
module: 'LinkedStateMixin',
1517
name: 'linked-state-mixin',
1618
docs: 'two-way-binding-helpers',
1719
},
1820
Perf: {
21+
package: 'react-dom',
1922
module: 'ReactPerf',
2023
name: 'perf',
2124
docs: 'perf',
2225
},
2326
PureRenderMixin: {
27+
package: 'react',
2428
module: 'ReactComponentWithPureRenderMixin',
2529
name: 'pure-render-mixin',
2630
docs: 'pure-render-mixin',
2731
},
2832
TestUtils: {
33+
package: 'react-dom',
2934
module: 'ReactTestUtils',
3035
name: 'test-utils',
3136
docs: 'test-utils',
3237
},
3338
TransitionGroup: {
39+
package: 'react',
3440
module: 'ReactTransitionGroup',
3541
name: 'transition-group',
3642
docs: 'animation',
3743
},
3844
createFragment: {
45+
package: 'react',
3946
module: 'ReactFragment',
4047
method: 'create',
4148
name: 'create-fragment',
4249
docs: 'create-fragment',
4350
},
4451
shallowCompare: {
52+
package: 'react',
4553
module: 'shallowCompare',
4654
name: 'shallow-compare',
4755
},
4856
updates: {
57+
package: 'react',
4958
module: 'update',
5059
name: 'update',
5160
docs: 'update',
@@ -54,9 +63,11 @@ var addons = {
5463

5564
function generateSource(info) {
5665
var pieces = [
57-
"module.exports = require('react/lib/",
66+
'module.exports = require(\'',
67+
info.package,
68+
'/lib/',
5869
info.module,
59-
"')",
70+
'\')',
6071
];
6172
if (info.method) {
6273
pieces.push('.', info.method);

grunt/tasks/npm-react-dom.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var grunt = require('grunt');
55

66
var src = 'packages/react-dom/';
77
var dest = 'build/packages/react-dom/';
8+
var modSrc = 'build/node_modules/react-dom/lib';
9+
var lib = dest + 'lib/';
810
var dist = dest + 'dist/';
911
var distFiles = [
1012
'react-dom.js',
@@ -21,6 +23,7 @@ function buildRelease() {
2123
// Copy to build/packages/react-dom
2224
var mappings = [].concat(
2325
grunt.file.expandMapping('**/*', dest, {cwd: src}),
26+
grunt.file.expandMapping('**/*', lib, {cwd: modSrc}),
2427
grunt.file.expandMapping('{LICENSE,PATENTS}', dest)
2528
);
2629
mappings.forEach(function(mapping) {

grunt/tasks/npm-react-native.js

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ var grunt = require('grunt');
55

66
var src = 'packages/react-native-renderer/';
77
var dest = 'build/packages/react-native-renderer/';
8+
var modSrc = 'build/node_modules/react-native/lib';
9+
var lib = dest + 'lib/';
810

911
function buildRelease() {
1012
if (grunt.file.exists(dest)) {
@@ -14,6 +16,7 @@ function buildRelease() {
1416
// Copy to build/packages/react-native-renderer
1517
var mappings = [].concat(
1618
grunt.file.expandMapping('**/*', dest, {cwd: src}),
19+
grunt.file.expandMapping('**/*', lib, {cwd: modSrc}),
1720
grunt.file.expandMapping('{LICENSE,PATENTS}', dest)
1821
);
1922
mappings.forEach(function(mapping) {

grunt/tasks/npm-react.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var grunt = require('grunt');
55

66
var src = 'packages/react/';
77
var dest = 'build/packages/react/';
8-
var modSrc = 'build/modules/';
8+
var modSrc = 'build/node_modules/react/lib';
99
var lib = dest + 'lib/';
1010
var dist = dest + 'dist/';
1111
var distFiles = [

0 commit comments

Comments
 (0)