Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RxJS operators used by ui-router are missing when built using angular-cli AoT #46

Closed
christopherthielen opened this issue Feb 10, 2017 · 1 comment
Labels
Milestone

Comments

@christopherthielen
Copy link
Member

christopherthielen commented Feb 10, 2017

If you don't explicitly import all the RxJS operators that UI-Router requires (primarily for the UISref directive) they seem to get tree-shaked away when running in AoT (--aot) and/or production build (--prod).

UI-Router imports the operators in the index file:

import "rxjs/Observable";
import "rxjs/ReplaySubject";
import "rxjs/BehaviorSubject";
import "rxjs/Subscription";
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/combineLatest';
import 'rxjs/add/observable/fromPromise';
import 'rxjs/add/operator/switchMap';
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/operator/concat';
import 'rxjs/add/operator/map';

but they seem to get stripped away (likely due to webpack tree shaking) and cause an exception at runtime

TypeError: this._globals.start$.switchMap is not a function
    at UISrefStatus.ngAfterContentInit (vendor.bundle.js:13026)
    at View_ContactListComponent1.webpackJsonp.762.View_ContactListComponent1.detectChangesInternal (1.chunk.js:1074)
    at View_ContactListComponent1.AppView.detectChanges (vendor.bundle.js:7364)
    at ViewContainer.detectChangesInNestedViews (vendor.bundle.js:10602)
    at View_ContactListComponent0.webpackJsonp.762.View_ContactListComponent0.detectChangesInternal (1.chunk.js:1188)
    at View_ContactListComponent0.AppView.detectChanges (vendor.bundle.js:7364)
    at View_ContactListComponent0.AppView.internalDetectChanges (vendor.bundle.js:7349)
    at View_ContactsComponent0.webpackJsonp.764.View_ContactsComponent0.detectChangesInternal (1.chunk.js:1645)
    at View_ContactsComponent0.AppView.detectChanges (vendor.bundle.js:7364)
    at View_ContactsComponent0.AppView.internalDetectChanges (vendor.bundle.js:7349)
    at View_ContactsComponent_Host0.webpackJsonp.764.View_ContactsComponent_Host0.detectChangesInternal (1.chunk.js:1573)
    at View_ContactsComponent_Host0.AppView.detectChanges (vendor.bundle.js:7364)
    at ViewRef_.detectChanges (vendor.bundle.js:36485)
    at UIView.applyInputBindings (vendor.bundle.js:8271)
    at UIView.applyUpdatedConfig (vendor.bundle.js:8229)

I'm not sure what best practice is regarding these imports, but it seems to work if the imports are moved into each file that requires the operator.

Related to: #28

@aitboudad
Copy link
Contributor

see #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants