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

Use proper way of rxjs imports #172

Closed
pburgmer opened this issue Nov 20, 2017 · 5 comments
Closed

Use proper way of rxjs imports #172

pburgmer opened this issue Nov 20, 2017 · 5 comments

Comments

@pburgmer
Copy link

Hi,

First of all: Thanks for this cool library.

We have some trouble building a bigger application with the Angular CLI. Digging deeper I saw you import Observables like this: import { Observable } from 'rxjs/Rx';. This kind of import statements leads to a bigger file size. Please see https://christianliebel.com/2017/07/import-rxjs-correctly/ for more details.

Could you please update your import statements to import { Observable } from 'rxjs/Observable'; and add the operators manually.

Thanks

@rychkog
Copy link
Contributor

rychkog commented Nov 20, 2017

@pburgmer Agree, this is a good point. Will update the lib during this week.

@pburgmer
Copy link
Author

Thanks

@Myrmex
Copy link

Myrmex commented Nov 21, 2017

Maybe this comment can be useful: I'm finding that in my Angular CLI app using ng2tree works fine but only when not compiling in prod mode (with or without --aot); when I compile for production (--prod), I get an error which seems related to this style of rxjs import. Hope making that update will solve this, too.
Here is the build error:

ERROR in ./node_modules/rxjs/_esm5/observable/BoundNodeCallbackObservable.js
Module build failed: TypeError: Cannot read property 'type' of undefined
    at Object.getEffectiveTypeAnnotationNode (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:9341:18)
    at assignContextualParameterTypes (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:41652:25)
    at checkFunctionExpressionOrObjectLiteralMethod (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:41948:29)
    at checkExpressionWorker (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:42959:28)
    at checkExpression (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:42898:42)
    at checkExpressionCached (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:42779:38)
    at checkReturnStatement (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:45418:54)
    at checkSourceElement (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:46763:28)
    at Object.forEach (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:1506:30)
    at checkBlock (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:44563:16)
    at checkSourceElement (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:46742:28)
    at checkFunctionExpressionOrObjectLiteralMethodDeferred (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:41990:21)
    at checkDeferredNodes (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:46828:25)
    at checkSourceFileWorker (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:46863:17)
    at checkSourceFile (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:46842:13)
    at Object.forEach (D:\Projects\Core20\Spa\chironweb\node_modules\typescript\lib\typescript.js:1506:30)
 @ ./node_modules/rxjs/_esm5/observable/bindNodeCallback.js 2:0-76
 @ ./node_modules/rxjs/_esm5/add/observable/bindNodeCallback.js
 @ ./node_modules/rxjs/_esm5/Rx.js
 @ ./node_modules/ng2-tree/src/menu/node-menu.service.js
 @ ./src/app/app.module.ngfactory.js
 @ ./src/main.ts
 @ multi ./src/main.ts

@pburgmer
Copy link
Author

I have the same error.

@avadhootha
Copy link

I updated the same issue over angular cli project as well - angular/angular-cli#2281

Upgrading the typescript version to 2.6 also resolves the issue. But I think this library eventually have to replace the statements import { Observable } from 'rxjs/Rx'; as @pburgmer said.

rychkog pushed a commit that referenced this issue Nov 24, 2017
fix(*): import rxjs in a proper way. Closes #172 (#173)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants