2017-10-21 173 views
1

我正在分析我的角度應用程序包,我不明白爲什麼rxjs導入一個功能模塊1.b6e2bed6d2a2d3892bd9.chunk.js,我在該模塊導入的所有內容如下所示:爲什麼整個rxjs導入到一個功能角模塊

import { Observable } from 'rxjs/Observable'; 

webpack-bundle-analyzer

如何找出爲什麼整個rxjs是模塊是進口?

+0

你應該使用**樹搖**的https:/ /webpack.js.org/guides/tree-shaking/ – Hosar

+1

我正在運行帶有角度cli的prod版本! 'ng build --prod --stats -json && webpack-bundle-analyzer dist/stats.json' –

+0

您可能想嘗試添加一個'--build-optimizer'標誌以獲得更好的結果(儘管需要更長的時間) 。 –

回答

0

答: 我發現問題的根源,我該模塊上進口customHttpProvider,我想ng-jhipster包拉動全rxjs

import { Injector } from '@angular/core'; 
import { Http, RequestOptions, XHRBackend } from '@angular/http'; 
import { JhiInterceptableHttp } from 'ng-jhipster'; 
import { AuthExpiredInterceptor } from './auth-expired.interceptor'; 
import { ErrorHandlerInterceptor } from './errorhandler.interceptor'; 
import { NotificationInterceptor } from './notification.interceptor'; 

export function interceptableFactory(
    backend: XHRBackend, 
    defaultOptions: RequestOptions, 
    injector: Injector 
    //stateStorageService: StateStorageService, 
    //eventManager: EventManager 
) { 
    return new JhiInterceptableHttp(
     backend, 
     defaultOptions, 
     [ 
      new AuthExpiredInterceptor(injector 
       //, stateStorageService 
      ), 
      // Other interceptors can be added here 
      new ErrorHandlerInterceptor(
       //eventManager 
      ), 
      new NotificationInterceptor() 
     ] 
    ); 
}; 

export function customHttpProvider() { 
    return { 
     provide: Http, 
     useFactory: interceptableFactory, 
     deps: [ 
      XHRBackend, 
      RequestOptions, 
      Injector, 
      //StateStorageService, 
      //EventManager 
     ] 
    }; 
}; 
相關問題