diff --git a/package.json b/package.json index 67ac99e5f8472..15d5209ab8e4b 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,11 @@ "loose-envify": "^1.1.0", "object-assign": "^4.1.0", "platform": "^1.1.0", + "rollup": "^0.33.0", + "rollup-plugin-babel": "^2.6.1", + "rollup-plugin-node-resolve": "^1.7.1", + "rollup-plugin-replace": "^1.1.1", + "rollup-plugin-uglify": "^1.0.1", "run-sequence": "^1.1.4", "through2": "^2.0.0", "tmp": "~0.0.28", @@ -79,7 +84,9 @@ "lint": "grunt lint", "postinstall": "node node_modules/fbjs-scripts/node/check-dev-engines.js package.json", "test": "jest", - "flow": "flow" + "flow": "flow", + "rollup:dev": "rollup -c scripts/rollup/rollup.config.dev.js", + "rollup:prod": "rollup -c scripts/rollup/rollup.config.prod.js" }, "jest": { "modulePathIgnorePatterns": [ diff --git a/scripts/rollup/rollup.config.dev.js b/scripts/rollup/rollup.config.dev.js new file mode 100644 index 0000000000000..cbec66400a1df --- /dev/null +++ b/scripts/rollup/rollup.config.dev.js @@ -0,0 +1,35 @@ +/** + * Copyright (c) 2013-present, 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. + */ +'use strict'; + +var babel = require('rollup-plugin-babel'); +var replace = require('rollup-plugin-replace'); +var resolve = require('rollup-plugin-node-resolve'); + +var babelEs6ModulifyPlugin = require('../babel/transform-es6-modulify'); + +module.exports = { + dest: 'build/react.rollup.dev.js', + entry: 'build/modules/ReactUMDEntry.js', + moduleName: 'React', + format: 'umd', + plugins: [ + babel({ + babelrc: false, + plugins: [babelEs6ModulifyPlugin], + }), + replace({ + 'process.env.NODE_ENV': JSON.stringify('development'), + }), + resolve({ + main: true, + }), + ], + sourceMap: false, +}; diff --git a/scripts/rollup/rollup.config.prod.js b/scripts/rollup/rollup.config.prod.js new file mode 100644 index 0000000000000..34be1e522821a --- /dev/null +++ b/scripts/rollup/rollup.config.prod.js @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2013-present, 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. + */ +'use strict'; + +var babel = require('rollup-plugin-babel'); +var replace = require('rollup-plugin-replace'); +var resolve = require('rollup-plugin-node-resolve'); +var uglify = require('rollup-plugin-uglify'); + +var babelEs6ModulifyPlugin = require('../babel/transform-es6-modulify'); + +module.exports = { + dest: 'build/react.rollup.prod.js', + entry: 'build/modules/ReactUMDEntry.js', + moduleName: 'React', + format: 'umd', + plugins: [ + babel({ + babelrc: false, + plugins: [babelEs6ModulifyPlugin], + }), + replace({ + 'process.env.NODE_ENV': JSON.stringify('production'), + }), + resolve({ + main: true, + }), + uglify(), + ], + sourceMap: false, +};