From b5fa59f6ec34c2f52cb0c33b6c6bff33a8ea62cc Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Wed, 7 Mar 2018 21:56:12 -0800 Subject: [PATCH] fix: correct internal module paths to be systemjs compatible --- .travis.yml | 1 + .../systemjs/systemjs-compatibility-spec.js | 21 +++++++++++++++++++ integration/systemjs/tsconfig.json | 12 +++++++++++ package.json | 2 ++ spec/systemjs-compatibility-spec.ts | 7 ------- src/internal/observable/dom/AjaxObservable.ts | 6 +++--- .../observable/dom/WebSocketSubject.ts | 4 ++-- src/internal/operators/first.ts | 2 +- src/internal/operators/last.ts | 2 +- src/internal/patching/operator/bufferTime.ts | 2 +- .../patching/operator/combineLatest.ts | 2 +- src/internal/patching/operator/windowTime.ts | 4 ++-- 12 files changed, 47 insertions(+), 18 deletions(-) create mode 100644 integration/systemjs/systemjs-compatibility-spec.js create mode 100644 integration/systemjs/tsconfig.json delete mode 100644 spec/systemjs-compatibility-spec.ts diff --git a/.travis.yml b/.travis.yml index 717dd13d6f..83914d4958 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ install: script: - if [ "$FULL_VALIDATE" == "true" ] && [ -n "DANGER_GITHUB_API_TOKEN" ]; then echo {} > ./.babelrc && npx danger; fi - npm test + - npm run test:systemjs after_success: - if [ "$FULL_VALIDATE" == "true" ]; then npm run test:cover && npx nyc report --reporter=text-lcov | npx coveralls; fi diff --git a/integration/systemjs/systemjs-compatibility-spec.js b/integration/systemjs/systemjs-compatibility-spec.js new file mode 100644 index 0000000000..3cfac872ff --- /dev/null +++ b/integration/systemjs/systemjs-compatibility-spec.js @@ -0,0 +1,21 @@ +var System = require('systemjs'); +var path = require('path'); + +System.config({ + map: { 'rxjs': path.join(__dirname, '..', '..', 'dist', 'cjs', '/') }, + packages: { 'rxjs': {main: 'index.js', defaultExtension: 'js' }} +}); + +Promise.all([ + System.import('rxjs'), + System.import('rxjs/ajax'), + System.import('rxjs/operators'), + System.import('rxjs/testing'), + System.import('rxjs/websocket'), +]).then( + function () { console.log('Successfully tested all entry-points with SystemJS!'); }, + function () { + console.error('\n\nFailed to load an entry-points via SystemJS: \n\n', error.message); + process.exit(-1); + } +); diff --git a/integration/systemjs/tsconfig.json b/integration/systemjs/tsconfig.json new file mode 100644 index 0000000000..ab6156db86 --- /dev/null +++ b/integration/systemjs/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "moduleResolution": "classic", + "target": "es2015", + "outDir": "../../dist/integration/", + "rootDir": "." + }, + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/package.json b/package.json index 5330aac415..481003c4a9 100644 --- a/package.json +++ b/package.json @@ -115,6 +115,7 @@ "test": "cross-env TS_NODE_FAST=true mocha --compilers ts:ts-node/register --opts spec/support/coverage.opts \"spec/**/*-spec.ts\"", "test:cover": "cross-env TS_NODE_FAST=true nyc npm test", "test:circular": "dependency-cruise --validate .dependency-cruiser.json -x \"^node_modules\" src", + "test:systemjs": "node integration/systemjs/systemjs-compatibility-spec.js", "tests2png": "mkdirp tmp/docs/img && cross-env TS_NODE_FAST=true mocha --compilers ts:ts-node/register --opts spec/support/tests2png.opts \"spec/**/*-spec.ts\"", "watch": "watch \"echo triggering build && npm run test && echo build completed\" src -d -u -w=15" }, @@ -223,6 +224,7 @@ "sinon-chai": "2.14.0", "source-map-support": "0.5.3", "symbol-observable": "1.0.1", + "systemjs": "^0.21.0", "ts-node": "4.1.0", "tslib": "1.5.0", "tslint": "5.9.1", diff --git a/spec/systemjs-compatibility-spec.ts b/spec/systemjs-compatibility-spec.ts deleted file mode 100644 index 6d9adf4a8e..0000000000 --- a/spec/systemjs-compatibility-spec.ts +++ /dev/null @@ -1,7 +0,0 @@ -// all these imports verify that our ESM imports and exports are SystemJS compatible after transpilation -// this is done by relying on the tsc type-checker configured with "moduleResolution" set to "classic" -import * as rxjs from '../src/index'; -import * as rxjsAjax from '../src/ajax'; -import * as rxjsOperators from '../src/operators'; -import * as rxjsTesting from '../src/testing'; -import * as rxjsWebsocket from '../src/websocket'; diff --git a/src/internal/observable/dom/AjaxObservable.ts b/src/internal/observable/dom/AjaxObservable.ts index 692d0b1b2d..b60082be92 100644 --- a/src/internal/observable/dom/AjaxObservable.ts +++ b/src/internal/observable/dom/AjaxObservable.ts @@ -1,6 +1,6 @@ -import { root } from '../..//util/root'; -import { tryCatch } from '../..//util/tryCatch'; -import { errorObject } from '../..//util/errorObject'; +import { root } from '../../util/root'; +import { tryCatch } from '../../util/tryCatch'; +import { errorObject } from '../../util/errorObject'; import { Observable } from '../../Observable'; import { Subscriber } from '../../Subscriber'; import { TeardownLogic } from '../../types'; diff --git a/src/internal/observable/dom/WebSocketSubject.ts b/src/internal/observable/dom/WebSocketSubject.ts index 8f85d99095..240a64d352 100644 --- a/src/internal/observable/dom/WebSocketSubject.ts +++ b/src/internal/observable/dom/WebSocketSubject.ts @@ -5,8 +5,8 @@ import { Subscription } from '../../Subscription'; import { Operator } from '../../Operator'; import { ReplaySubject } from '../../ReplaySubject'; import { Observer, NextObserver } from '../../types'; -import { tryCatch } from '../..//util/tryCatch'; -import { errorObject } from '../..//util/errorObject'; +import { tryCatch } from '../../util/tryCatch'; +import { errorObject } from '../../util/errorObject'; export interface WebSocketSubjectConfig { url: string; diff --git a/src/internal/operators/first.ts b/src/internal/operators/first.ts index b93345a112..414b483661 100644 --- a/src/internal/operators/first.ts +++ b/src/internal/operators/first.ts @@ -1,7 +1,7 @@ import { Observable } from '../Observable'; import { Operator } from '../Operator'; import { Subscriber } from '../Subscriber'; -import { EmptyError } from '..//util/EmptyError'; +import { EmptyError } from '../util/EmptyError'; import { MonoTypeOperatorFunction } from '../../internal/types'; /** diff --git a/src/internal/operators/last.ts b/src/internal/operators/last.ts index 90a8de3c8a..209fd3e4b0 100644 --- a/src/internal/operators/last.ts +++ b/src/internal/operators/last.ts @@ -1,7 +1,7 @@ import { Observable } from '../Observable'; import { Operator } from '../Operator'; import { Subscriber } from '../Subscriber'; -import { EmptyError } from '..//util/EmptyError'; +import { EmptyError } from '../util/EmptyError'; import { MonoTypeOperatorFunction } from '../../internal/types'; /** diff --git a/src/internal/patching/operator/bufferTime.ts b/src/internal/patching/operator/bufferTime.ts index 01d784c2de..939407aeaa 100644 --- a/src/internal/patching/operator/bufferTime.ts +++ b/src/internal/patching/operator/bufferTime.ts @@ -1,7 +1,7 @@ import { SchedulerLike } from '../../types'; import { async } from '../../scheduler/async'; import { Observable } from '../../Observable'; -import { isScheduler } from '../..//util/isScheduler'; +import { isScheduler } from '../../util/isScheduler'; import { bufferTime as higherOrder } from '../../operators/bufferTime'; /* tslint:disable:max-line-length */ diff --git a/src/internal/patching/operator/combineLatest.ts b/src/internal/patching/operator/combineLatest.ts index 9241ebfe25..2efa62961d 100644 --- a/src/internal/patching/operator/combineLatest.ts +++ b/src/internal/patching/operator/combineLatest.ts @@ -2,7 +2,7 @@ import { Observable } from '../../Observable'; import { ObservableInput } from '../../types'; import { CombineLatestOperator } from '../../observable/combineLatest'; import { of } from '../../observable/of'; -import { isArray } from '../..//util/isArray'; +import { isArray } from '../../util/isArray'; /* tslint:disable:max-line-length */ export function combineLatest(this: Observable, project: (v1: T) => R): Observable; diff --git a/src/internal/patching/operator/windowTime.ts b/src/internal/patching/operator/windowTime.ts index cebba0f417..af75005497 100644 --- a/src/internal/patching/operator/windowTime.ts +++ b/src/internal/patching/operator/windowTime.ts @@ -1,8 +1,8 @@ import { SchedulerLike } from '../../types'; import { async } from '../../scheduler/async'; import { Observable } from '../../Observable'; -import { isNumeric } from '../..//util/isNumeric'; -import { isScheduler } from '../..//util/isScheduler'; +import { isNumeric } from '../../util/isNumeric'; +import { isScheduler } from '../../util/isScheduler'; import { windowTime as higherOrder } from '../../operators/windowTime'; /**