From 5514dc19d9779fb6b0d7bbae8268dc21dd1dde39 Mon Sep 17 00:00:00 2001 From: Rob Wormald Date: Mon, 30 Nov 2015 17:22:52 -0800 Subject: [PATCH] refactor(facade): use rxjs package move to new RxJS distribution. BREAKING CHANGE: RxJS imports now are via `rxjs` instead of `@reactivex/rxjs` Individual operators can be imported `import 'rxjs/operators/map'` --- gulpfile.js | 11 ++--- karma-js.conf.js | 2 +- modules/angular2/package.json | 2 +- modules/angular2/src/facade/async.ts | 15 ++++--- .../src/http/backends/mock_backend.ts | 3 +- modules/angular2/src/http/package.json | 2 +- modules/angular2/test/http/http_spec.ts | 3 +- modules/angular2/test/public_api_spec.ts | 43 ++----------------- modules/angular2_material/package.json | 2 +- npm-shrinkwrap.clean.json | 6 +-- npm-shrinkwrap.json | 12 +++--- package.json | 2 +- test-main.js | 2 +- tools/broccoli/broccoli-check-imports.ts | 2 +- tools/broccoli/broccoli-typescript.ts | 2 +- tools/broccoli/trees/browser_tree.ts | 2 +- 16 files changed, 42 insertions(+), 69 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index cda5ac647e..467172529c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -146,7 +146,7 @@ var BENCHPRESS_BUNDLE_CONFIG = { packageJson: './dist/js/cjs/benchpress/package.json', includes: ['angular2'], excludes: ['reflect-metadata', 'selenium-webdriver', 'zone.js'], - ignore: ['@reactivex/rxjs'], + ignore: [], dest: CONFIG.dest.benchpress_bundle }; @@ -815,8 +815,7 @@ gulp.task('static-checks', ['!build.tools'], function(done) { // Make sure the two typings tests are isolated, by running this one in a tempdir var tmpdir = path.join(os.tmpdir(), 'test.typings', new Date().getTime().toString()); gulp.task('!pre.test.typings.layoutNodeModule', ['build.js.cjs'], function() { - return gulp.src(['dist/js/cjs/angular2/**/*', 'node_modules/@reactivex/rxjs/dist/cjs/**'], - {base: 'dist/js/cjs'}) + return gulp.src(['dist/js/cjs/angular2/**/*', 'node_modules/rxjs/**'], {base: 'dist/js/cjs'}) .pipe(gulp.dest(path.join(tmpdir, 'node_modules'))); }); gulp.task('!pre.test.typings.copyTypingsSpec', function() { @@ -1152,9 +1151,11 @@ var JS_DEV_DEPS = [ // Splice in RX license if rx is in the bundle. function insertRXLicense(source) { - var n = source.indexOf('System.register("@reactivex/rxjs/dist/cjs/Subject"'); + var n = source.indexOf('System.register("rxjs/Subject"'); if (n >= 0) { - var rxLicense = licenseWrap('node_modules/@reactivex/rxjs/LICENSE.txt'); + // TODO: point this to Rx once Rx includes license in dist + // https://github.com/angular/angular/issues/5558 + var rxLicense = licenseWrap('LICENSE'); return source.slice(0, n) + rxLicense + source.slice(n); } else { return source; diff --git a/karma-js.conf.js b/karma-js.conf.js index b4d099748c..b407d1c120 100644 --- a/karma-js.conf.js +++ b/karma-js.conf.js @@ -25,7 +25,7 @@ module.exports = function(config) { // Including systemjs because it defines `__eval`, which produces correct stack traces. 'modules/angular2/src/testing/shims_for_IE.js', 'node_modules/systemjs/dist/system.src.js', - {pattern: 'node_modules/@reactivex/rxjs/**', included: false, watched: false, served: true}, + {pattern: 'node_modules/rxjs/**', included: false, watched: false, served: true}, 'node_modules/reflect-metadata/Reflect.js', 'tools/build/file2modulename.js', 'test-main.js', diff --git a/modules/angular2/package.json b/modules/angular2/package.json index 2557f1fbd6..64ee9c46d7 100644 --- a/modules/angular2/package.json +++ b/modules/angular2/package.json @@ -9,7 +9,7 @@ "repository": <%= JSON.stringify(packageJson.repository) %>, "dependencies": { "reflect-metadata": "<%= packageJson.dependencies['reflect-metadata'] %>", - "@reactivex/rxjs": "<%= packageJson.dependencies['@reactivex/rxjs'] %>", + "rxjs": "<%= packageJson.dependencies['rxjs'] %>", "zone.js": "<%= packageJson.dependencies['zone.js'] %>" }, "devDependencies": <%= JSON.stringify(packageJson.defaultDevDependencies) %> diff --git a/modules/angular2/src/facade/async.ts b/modules/angular2/src/facade/async.ts index be10aa075d..6502a76a1f 100644 --- a/modules/angular2/src/facade/async.ts +++ b/modules/angular2/src/facade/async.ts @@ -4,11 +4,16 @@ import {global, isPresent, noop} from 'angular2/src/facade/lang'; import {PromiseWrapper, Promise, PromiseCompleter} from 'angular2/src/facade/promise'; export {PromiseWrapper, Promise, PromiseCompleter} from 'angular2/src/facade/promise'; -import {Subject} from '@reactivex/rxjs/dist/cjs/Subject'; -import {Observable as RxObservable} from '@reactivex/rxjs/dist/cjs/Observable'; -import {Subscription} from '@reactivex/rxjs/dist/cjs/Subscription'; -import {Operator} from '@reactivex/rxjs/dist/cjs/Operator'; -export {Subject} from '@reactivex/rxjs/dist/cjs/Subject'; +import {Subject} from 'rxjs/Subject'; +import {Observable as RxObservable} from 'rxjs/Observable'; +import {Subscription} from 'rxjs/Subscription'; +import {Operator} from 'rxjs/Operator'; + +import 'rxjs/observable/fromPromise'; +import 'rxjs/operators/toPromise'; + +export {Subject} from 'rxjs/Subject'; + export namespace NodeJS { diff --git a/modules/angular2/src/http/backends/mock_backend.ts b/modules/angular2/src/http/backends/mock_backend.ts index d5ebd127da..7dc6358ed9 100644 --- a/modules/angular2/src/http/backends/mock_backend.ts +++ b/modules/angular2/src/http/backends/mock_backend.ts @@ -5,7 +5,8 @@ import {ReadyStates} from '../enums'; import {Connection, ConnectionBackend} from '../interfaces'; import {isPresent} from 'angular2/src/facade/lang'; import {BaseException, WrappedException} from 'angular2/src/facade/exceptions'; -import {Subject, ReplaySubject} from '@reactivex/rxjs/dist/cjs/Rx'; +import {Subject} from 'rxjs/Subject'; +import {ReplaySubject} from 'rxjs/subjects/ReplaySubject'; /** * diff --git a/modules/angular2/src/http/package.json b/modules/angular2/src/http/package.json index f63b16fb23..d62248b6cd 100644 --- a/modules/angular2/src/http/package.json +++ b/modules/angular2/src/http/package.json @@ -9,7 +9,7 @@ "repository": <%= JSON.stringify(packageJson.repository) %>, "dependencies": { "angular2": "<%= packageJson.version %>", - "@reactivex/rxjs": "<%= packageJson.dependencies['@reactivex/rxjs'] %>", + "rxjs": "<%= packageJson.dependencies['rxjs'] %>", "reflect-metadata": "<%= packageJson.dependencies['reflect-metadata'] %>" }, "devDependencies": <%= JSON.stringify(packageJson.defaultDevDependencies) %> diff --git a/modules/angular2/test/http/http_spec.ts b/modules/angular2/test/http/http_spec.ts index f67bc03f09..d55fcd19d5 100644 --- a/modules/angular2/test/http/http_spec.ts +++ b/modules/angular2/test/http/http_spec.ts @@ -29,7 +29,8 @@ import { Http, Jsonp } from 'angular2/http'; -import {Observable, Subject} from '@reactivex/rxjs/dist/cjs/Rx'; +import {Observable} from 'rxjs/Observable'; +import {Subject} from 'rxjs/Subject'; class SpyObserver extends SpyObject { onNext: Function; diff --git a/modules/angular2/test/public_api_spec.ts b/modules/angular2/test/public_api_spec.ts index 3163681a9f..43cb60b58c 100644 --- a/modules/angular2/test/public_api_spec.ts +++ b/modules/angular2/test/public_api_spec.ts @@ -689,47 +689,12 @@ var NG_ALL = [ 'EventEmitter.emit():js', 'Observable:js', 'Observable#create():js', - 'Observable.buffer():js', - 'Observable.bufferCount():js', - 'Observable.bufferTime():js', - 'Observable.bufferToggle():js', - 'Observable.bufferWhen():js', - 'Observable.catch():js', - 'Observable.combineAll():js', - 'Observable.combineLatest():js', - 'Observable.concat():js', - 'Observable.concatAll():js', - 'Observable.concatMap():js', - 'Observable.concatMapTo():js', - 'Observable.count():js', - 'Observable.debounce():js', - 'Observable.debounceTime():js', - 'Observable.defaultIfEmpty():js', - 'Observable.delay():js', - 'Observable.dematerialize():js', - 'Observable.distinctUntilChanged():js', - 'Observable.do():js', - 'Observable.every():js', - 'Observable.expand():js', - 'Observable.filter():js', - 'Observable.finally():js', - 'Observable.first():js', - 'Observable.flatMap():js', - 'Observable.flatMapTo():js', 'Observable.forEach():js', - 'Observable.groupBy():js', - 'Observable.ignoreElements():js', - 'Observable.last():js', + 'Observable#fromPromise():js', 'Observable.lift():js', - 'Observable.map():js', - 'Observable.mapTo():js', - 'Observable.materialize():js', - 'Observable.merge():js', - 'Observable.mergeAll():js', - 'Observable.mergeMap():js', - 'Observable.mergeMapTo():js', - 'Observable.multicast():js', - 'Observable.observeOn():js', + 'Observable.subscribe():js', + 'Observable.take():js', + 'Observable.toPromise():js', 'OutputMetadata', 'OutputMetadata.bindingPropertyName', diff --git a/modules/angular2_material/package.json b/modules/angular2_material/package.json index baa2f096df..1bcf8b367a 100644 --- a/modules/angular2_material/package.json +++ b/modules/angular2_material/package.json @@ -9,7 +9,7 @@ "repository": <%= JSON.stringify(packageJson.repository) %>, "dependencies": { "angular2": "<%= packageJson.version %>", - "@reactivex/rxjs": "<%= packageJson.dependencies['@reactivex/rxjs'] %>", + "rxjs": "<%= packageJson.dependencies['rxjs'] %>", "zone.js": "<%= packageJson.dependencies['zone.js'] %>" }, "devDependencies": <%= JSON.stringify(packageJson.defaultDevDependencies) %> diff --git a/npm-shrinkwrap.clean.json b/npm-shrinkwrap.clean.json index 38819c5aca..67bd7339a6 100644 --- a/npm-shrinkwrap.clean.json +++ b/npm-shrinkwrap.clean.json @@ -1,8 +1,5 @@ { "dependencies": { - "@reactivex/rxjs": { - "version": "5.0.0-alpha.10" - }, "angular": { "version": "1.4.7" }, @@ -13184,6 +13181,9 @@ } } }, + "rxjs": { + "version": "5.0.0-alpha.11" + }, "selenium-webdriver": { "version": "2.48.2", "dependencies": { diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 9dca270d6a..b70e522c19 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -2,11 +2,6 @@ "name": "angular-srcs", "version": "2.0.0-alpha.46", "dependencies": { - "@reactivex/rxjs": { - "version": "5.0.0-alpha.10", - "from": "@reactivex/rxjs@5.0.0-alpha.10", - "resolved": "http://registry.npmjs.org/@reactivex/rxjs/-/rxjs-5.0.0-alpha.10.tgz" - }, "angular": { "version": "1.4.7", "from": "https://registry.npmjs.org/angular/-/angular-1.4.7.tgz", @@ -20211,6 +20206,11 @@ } } }, + "rxjs": { + "version": "5.0.0-alpha.11", + "from": "http://registry.npmjs.org/rxjs/-/rxjs-5.0.0-alpha.11.tgz", + "resolved": "http://registry.npmjs.org/rxjs/-/rxjs-5.0.0-alpha.11.tgz" + }, "selenium-webdriver": { "version": "2.48.2", "from": "https://registry.npmjs.org/selenium-webdriver/-/selenium-webdriver-2.48.2.tgz", @@ -20341,7 +20341,7 @@ }, "source-map-loader": { "version": "0.1.5", - "from": "source-map-loader@*", + "from": "source-map-loader@>=0.1.5 <0.2.0", "resolved": "https://registry.npmjs.org/source-map-loader/-/source-map-loader-0.1.5.tgz", "dependencies": { "loader-utils": { diff --git a/package.json b/package.json index b12b5083e1..909a56b2f1 100644 --- a/package.json +++ b/package.json @@ -31,8 +31,8 @@ "test": "gulp test.all.js && gulp test.all.dart" }, "dependencies": { - "@reactivex/rxjs": "5.0.0-alpha.10", "reflect-metadata": "0.1.2", + "rxjs": "^5.0.0-alpha.11", "zone.js": "0.5.8" }, "devDependencies": { diff --git a/test-main.js b/test-main.js index 49a9fabd1d..d0d01a6131 100644 --- a/test-main.js +++ b/test-main.js @@ -14,7 +14,7 @@ System.config({ 'benchpress/*': 'dist/js/dev/es5/benchpress/*.js', 'angular2/*': 'dist/js/dev/es5/angular2/*.js', 'angular2_material/*': 'dist/js/dev/es5/angular2_material/*.js', - '@reactivex/rxjs/*': 'node_modules/@reactivex/rxjs/*.js' + 'rxjs/*': 'node_modules/rxjs/*.js' } }); diff --git a/tools/broccoli/broccoli-check-imports.ts b/tools/broccoli/broccoli-check-imports.ts index 7659a4049b..cbe446987f 100644 --- a/tools/broccoli/broccoli-check-imports.ts +++ b/tools/broccoli/broccoli-check-imports.ts @@ -17,7 +17,7 @@ class CheckImports implements DiffingBroccoliPlugin { "angular2/src/core", "angular2/src/facade", ], - "angular2/src/facade": ["angular2/src/facade", "@reactivex/rxjs"], + "angular2/src/facade": ["angular2/src/facade", "rxjs"], "angular2/src/common": ["angular2/core", "angular2/src/facade", "angular2/src/common"] //"angular2/src/render": [ // "angular2/animate", diff --git a/tools/broccoli/broccoli-typescript.ts b/tools/broccoli/broccoli-typescript.ts index b7e997b79a..0f01daeaef 100644 --- a/tools/broccoli/broccoli-typescript.ts +++ b/tools/broccoli/broccoli-typescript.ts @@ -263,7 +263,7 @@ class CustomLanguageServiceHost implements ts.LanguageServiceHost { } else if (this.compilerOptions.moduleResolution === ts.ModuleResolutionKind.NodeJs && tsFilePath.match(/^node_modules/)) { absoluteTsFilePath = path.resolve(tsFilePath); - } else if (tsFilePath.match(/^@reactivex/)) { + } else if (tsFilePath.match(/^rxjs/)) { absoluteTsFilePath = path.resolve('node_modules', tsFilePath); } else { absoluteTsFilePath = path.join(this.treeInputPath, tsFilePath); diff --git a/tools/broccoli/trees/browser_tree.ts b/tools/broccoli/trees/browser_tree.ts index 5da5ed6226..51d2a85bbb 100644 --- a/tools/broccoli/trees/browser_tree.ts +++ b/tools/broccoli/trees/browser_tree.ts @@ -279,7 +279,7 @@ module.exports = function makeBrowserTree(options, destinationPath) { // typescript resolves dependencies automatically if (modules.bundle_deps) { var nodeModules = new Funnel( - 'node_modules', {include: ['@reactivex/**/**', 'parse5/**/**', 'css/**/**'], destDir: '/'}); + 'node_modules', {include: ['rxjs/**/**', 'parse5/**/**', 'css/**/**'], destDir: '/'}); } if (generateEs6) {