From cb68c1da9624aad6132e18c1d4009086db259893 Mon Sep 17 00:00:00 2001 From: Andres Suarez Date: Mon, 24 Oct 2016 11:31:02 -0400 Subject: [PATCH] chore(build): Use rollup to bundle cjs build --- package.json | 11 +++++++---- tools/make-umd-bundle.js | 23 ++++++++++++++++++----- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 66252b7102..aed14f46d2 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "clean_spec": "Clean up existing test spec build output", "clean_dist_cjs": "Clean up existing CJS package output", "clean_dist_es6": "Clean up existing ES6 package output", + "clean_dist_global": "Clean up existing Global package output", "commit": "Run git commit wizard", "compile_dist_cjs": "Compile codebase into CJS module", "compile_dist_es6": "Compile codebase into ES6", @@ -56,7 +57,7 @@ "build_es6": "npm-run-all clean_dist_es6 copy_src_es6 compile_dist_es6", "build_es6_for_docs": "npm-run-all clean_dist_es6 copy_src_es6 compile_dist_es6_for_docs", "build_closure_core": "node ./tools/make-closure-core.js", - "build_global": "shx rm -rf ./dist/global && mkdirp ./dist/global && node tools/make-umd-bundle.js && npm-run-all build_closure_core", + "build_global": "npm-run-all clean_dist_global build_es6 && mkdirp ./dist/global && node tools/make-umd-bundle.js && npm-run-all build_closure_core", "build_perf": "webdriver-manager update && npm-run-all build_cjs build_global perf", "build_test": "shx rm -rf ./dist/ && npm-run-all build_cjs clean_spec build_spec test_mocha", "build_cover": "shx rm -rf ./dist/ && npm-run-all build_cjs build_spec cover", @@ -67,6 +68,7 @@ "clean_spec": "shx rm -rf spec-js", "clean_dist_cjs": "shx rm -rf ./dist/cjs", "clean_dist_es6": "shx rm -rf ./dist/es6", + "clean_dist_global": "shx rm -rf ./dist/global", "copy_src_cjs": "mkdirp ./dist/cjs/src && shx cp -r ./src/* ./dist/cjs/src", "copy_src_es6": "mkdirp ./dist/es6/src && shx cp -r ./src/* ./dist/es6/src", "commit": "git-cz", @@ -142,10 +144,11 @@ }, "homepage": "https://github.com/ReactiveX/RxJS", "devDependencies": { - "babel-polyfill": "6.9.1", + "babel-core": "6.17.0", + "babel-polyfill": "6.16.0", + "babel-preset-es2015": "6.16.0", "benchmark": "^2.1.0", "benchpress": "2.0.0-beta.1", - "browserify": "13.0.1", "chai": "^3.5.0", "color": "^0.11.1", "colors": "1.1.2", @@ -177,6 +180,7 @@ "platform": "^1.3.1", "promise": "^7.1.1", "protractor": "^3.1.1", + "rollup": "0.36.3", "rx": "latest", "shx": "^0.1.4", "sinon": "^2.0.0-pre", @@ -187,7 +191,6 @@ "typings": "^1.3.3", "validate-commit-msg": "^2.3.1", "watch": "^0.18.0", - "watchify": "3.7.0", "webpack": "^1.13.1", "xmlhttprequest": "1.8.0" }, diff --git a/tools/make-umd-bundle.js b/tools/make-umd-bundle.js index ba65b684b4..f85cd63fa6 100644 --- a/tools/make-umd-bundle.js +++ b/tools/make-umd-bundle.js @@ -1,8 +1,21 @@ -var browserify = require('browserify'); +var rollup = require('rollup'); var fs = require('fs'); -var b = browserify('dist/cjs/Rx.js', { - baseDir: 'dist/cjs', - standalone: 'Rx' +var babel = require('babel-core'); + +rollup.rollup({ + entry: 'dist/es6/Rx.js' +}).then(function (bundle) { + var result = bundle.generate({ + format: 'es' + }); + + var out = babel.transform(result.code, { + compact: false, + presets: [ + ['es2015', {loose: true}] + ], + }); + + fs.writeFileSync('dist/global/Rx.js', out.code); }); -b.bundle().pipe(fs.createWriteStream('dist/global/Rx.js'));