Angular-cli: RXJS lettable operators

Created on 2 Dec 2017  路  7Comments  路  Source: angular/angular-cli

There are severals discussions around the rxjs imorts.

Does the CLI handle this correctly?

import {map} from 'rxjs/operators/map';

Vs

import {map} from 'rxjs/operators';

In which case does tree shaking work in CLI projects?

Most helpful comment

Shouldn't matter either way, but the terser version is way easier to maintain and read.

Anyway, in RxJS 6 you'll be able to import everything from 'rxjs' which will be awesome if it can be properly tree shaken.

All 7 comments

Functionally, this works great, my group is using it on multiple projects already.

We have not yet verified whether the tree shakes correctly with CLI; hopefully someone from the team can answer that part. It should do so, but there could be some tweak yet needed. (If you need to deploy shortly in a case where the bundle size is vital, just try it and see if it affects your bundle size.)

We have changed everything to lettable imports like this: import {map} from 'rxjs/operators';

No change in payload after migration. This is the reason I was asking.

Both ways should support tree shaking. In my case I get a slight bundle size increase when importing from rxjs/operators instead of long import (499K vs 496K), which is probably caused by inclusion of file with re-exports of all operators. In both cases source-map-explorer indicates that no extra operators are included.

Shouldn't matter either way, but the terser version is way easier to maintain and read.

Anyway, in RxJS 6 you'll be able to import everything from 'rxjs' which will be awesome if it can be properly tree shaken.

@elvirdolic like @devoto13 said it should work correctly

I also saw my bundle size increase by 10 KB as RxJS increased from 60 KB to 122 KB when using the new lettable operators. I also mentioned this in https://github.com/angular/angular-cli/issues/8854#issuecomment-354532989. Still looking for the issue that is tracking this bundle increase bug.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adwd picture adwd  路  173Comments

elvisbegovic picture elvisbegovic  路  100Comments

Maistho picture Maistho  路  140Comments

hansl picture hansl  路  163Comments

bjornharvold picture bjornharvold  路  172Comments