diff --git a/Gruntfile.js b/Gruntfile.js index 6d9ce5bb3b..d5c201ad38 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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', @@ -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' ]); diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index 71207c0ea1..953251d4c7 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -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; } @@ -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 }; diff --git a/grunt/config/jsx/jsx.js b/grunt/config/jsx/jsx.js index 02c220b5da..a23ce02732 100644 --- a/grunt/config/jsx/jsx.js +++ b/grunt/config/jsx/jsx.js @@ -4,7 +4,7 @@ var grunt = require('grunt'); var rootIDs = [ "React", - "ReactTransitionGroup" + "ReactWithAddons" ]; var getDebugConfig = function() { diff --git a/src/ReactWithAddons.js b/src/ReactWithAddons.js new file mode 100644 index 0000000000..3b92d59f81 --- /dev/null +++ b/src/ReactWithAddons.js @@ -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; +