Blazzze IL
Blazzze IL

Reputation: 99

Why do i get too many rxjs file calls in my angular 2 project? (seems to be all of them)

EDIT: i have another project thats also not packaged up, and has calls for observable,subscription,subscriver (and BehaviorSubject). this project however uses those three but not BehaviorSubject.

in the other project it makes 63 rxjs calls, and in this project it makes 340 rxjs calls

I'm asking where to look for what is making those calls (both projects are same in their..settings... both using systemjs,bot run in JIT compilation (for now)

im using Observables, subscription etc in my project, and everytime i import i import them specifically

import { Subscription } from 'rxjs/Subscription';
import { Observable } from 'rxjs/Observable';

also no lines that are like

import "rxjs/Rx"; 

anywhere in the project, but still, when the project starts, it calls for 340 files

enter image description here

Upvotes: 0

Views: 141

Answers (1)

Poul Kruijt
Poul Kruijt

Reputation: 71921

That's because those imports have imports of their own. For instance if you do:

import 'rxjs/add/operator/map';

And look inside map what it imports, and look another level deeper you get:

import { Operator } from '../Operator';
import { Subscriber } from '../Subscriber';
import { Observable } from '../Observable';
import { Observer, PartialObserver } from './Observer';
import { Operator } from './Operator';
import { Subscriber } from './Subscriber';
import { Subscription, AnonymousSubscription, TeardownLogic } from './Subscription';
import { IfObservable } from './observable/IfObservable';
import { ErrorObservable } from './observable/ErrorObservable';

... etc, because some of these imports will import other stuff as well, you get that chain of all the files, but still, this is by far not the entire rxjs library, and with a good package manager (or by using the angular-cli), the final bundle will only contain what's actually necessary for your app

Upvotes: 1

Related Questions