Skip to content

Commit

Permalink
react-with-addons build
Browse files Browse the repository at this point in the history
This creates a new standalone build which should have everything the
default build has, plus a little extra. This is not a sustainable long
term solution (we shouldn't make people choose like this) but it fixes
the problem we have in the short term.

This also removes the terrible react-transitions build. This is better
anway.

Fixes facebook#369
  • Loading branch information
zpao committed Oct 8, 2013
1 parent f658c32 commit 2e6092b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 10 deletions.
6 changes: 4 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ module.exports = function(grunt) {
});

grunt.registerTask('build:basic', ['jsx:debug', 'version-check', 'browserify:basic']);
grunt.registerTask('build:addons', ['jsx:debug', 'browserify:addons']);
grunt.registerTask('build:transformer', ['jsx:debug', 'browserify:transformer']);
grunt.registerTask('build:transitions', ['jsx:debug', 'browserify:transitions']);
grunt.registerTask('build:min', ['jsx:release', 'version-check', 'browserify:min']);
grunt.registerTask('build:addons-min', ['jsx:debug', 'browserify:addonsMin']);
grunt.registerTask('build:test', [
'jsx:jasmine',
'jsx:test',
Expand All @@ -89,9 +90,10 @@ module.exports = function(grunt) {
'version-check',
'browserify:basic',
'browserify:transformer',
'browserify:transitions',
'browserify:addons',
'jsx:release',
'browserify:min',
'browserify:addonsMin',
'copy:react_docs',
'compare_size'
]);
Expand Down
24 changes: 17 additions & 7 deletions grunt/config/browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ function minify(src) {
// TODO: move this out to another build step maybe.
function bannerify(src) {
var version = grunt.config.data.pkg.version;
return LICENSE_TEMPLATE.replace('@PACKAGE@', this.data.standalone)
var packageName = this.data.packageName || this.data.standalone;
return LICENSE_TEMPLATE.replace('@PACKAGE@', packageName)
.replace('@VERSION@', version) +
'\n' + src;
}

function simpleBannerify(src) {
var version = grunt.config.data.pkg.version;
return SIMPLE_TEMPLATE.replace('@PACKAGE@', this.data.standalone)
var packageName = this.data.packageName || this.data.standalone;
return SIMPLE_TEMPLATE.replace('@PACKAGE@', packageName)
.replace('@VERSION@', version) +
'\n' + src;
}
Expand Down Expand Up @@ -76,19 +78,27 @@ var transformer = {
after: [simpleBannerify]
};

var transitions = {
var addons = {
entries: [
'./build/modules/ReactTransitionGroup.js'
'./build/modules/ReactWithAddons.js'
],
outfile: './build/react-transitiongroup.js',
outfile: './build/react-with-addons.js',
debug: false,
standalone: 'ReactTransitionGroup',
standalone: 'React',
packageName: 'React (with addons)',
after: [simpleBannerify]
};

var addonsMin = grunt.util._.merge({}, addons, {
outfile: './build/react-with-addons.min.js',
debug: false,
after: [minify, bannerify]
});

module.exports = {
basic: basic,
min: min,
transformer: transformer,
transitions: transitions
addons: addons,
addonsMin: addonsMin
};
2 changes: 1 addition & 1 deletion grunt/config/jsx/jsx.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var grunt = require('grunt');

var rootIDs = [
"React",
"ReactTransitionGroup"
"ReactWithAddons"
];

var getDebugConfig = function() {
Expand Down
41 changes: 41 additions & 0 deletions src/ReactWithAddons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright 2013 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @providesModule ReactWithAddons
*/

/**
* This module exists purely in the open source project, and is meant as a way
* to create a separate standalone build of React. This build has "addons", or
* functionality we've built and think might be useful but doesn't have a good
* place to live inside React core.
*/

"use strict";

var LinkedStateMixin = require('LinkedStateMixin');
var React = require('React');
var ReactTransitionGroup = require('ReactTransitionGroup');

var cx = require('cx');

React.addons = {
classSet: cx,
LinkedStateMixin: LinkedStateMixin,
TransitionGroup: ReactTransitionGroup
};

module.exports = React;

0 comments on commit 2e6092b

Please sign in to comment.