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

Some operators e.g. rxjs/operator/multicast pulls in code for *all* operators now #2812

Closed
jayphelps opened this issue Aug 25, 2017 · 3 comments

Comments

@jayphelps
Copy link
Member

jayphelps commented Aug 25, 2017

It looks like now that the older operator files import the lettable operators, they (unintentionally?) import all operators.

import { multicast as higherOrder } from '../operators';

import { buffer as higherOrder } from '../operators';

export { audit } from './audit';
export { auditTime } from './auditTime';
export { buffer } from './buffer';
export { bufferCount } from './bufferCount';
export { bufferTime } from './bufferTime';
export { bufferToggle } from './bufferToggle';
export { bufferWhen } from './bufferWhen';
export { catchError } from './catchError';
export { concat } from './concat';
export { concatAll } from './concatAll';
export { concatMap } from './concatMap';
export { concatMapTo } from './concatMapTo';
export { count } from './count';
export { debounce } from './debounce';
export { debounceTime } from './debounceTime';
export { defaultIfEmpty } from './defaultIfEmpty';
export { delay } from './delay';
export { delayWhen } from './delayWhen';
export { dematerialize } from './dematerialize';
export { distinctUntilChanged } from './distinctUntilChanged';
export { distinctUntilKeyChanged } from './distinctUntilKeyChanged';
export { elementAt } from './elementAt';
export { every } from './every';
export { exhaust } from './exhaust';
export { exhaustMap } from './exhaustMap';
export { expand } from './expand';
export { filter } from './filter';
export { finalize } from './finalize';
export { find } from './find';
export { findIndex } from './findIndex';
export { first } from './first';
export { groupBy } from './groupBy';
export { ignoreElements } from './ignoreElements';
export { map } from './map';
export { materialize } from './materialize';
export { max } from './max';
export { mergeAll } from './mergeAll';
export { mergeMap } from './mergeMap';
export { min } from './min';
export { multicast } from './multicast';
export { observeOn } from './observeOn';
export { publish } from './publish';
export { race } from './race';
export { reduce } from './reduce';
export { refCount } from './refCount';
export { scan } from './scan';
export { subscribeOn } from './subscribeOn';
export { switchAll } from './switchAll';
export { switchMap } from './switchMap';
export { takeLast } from './takeLast';
export { tap } from './tap';
export { timestamp } from './timestamp';
export { toArray } from './toArray';
export { window } from './window';
export { windowCount } from './windowCount';
export { windowTime } from './windowTime';
export { windowToggle } from './windowToggle';
export { windowWhen } from './windowWhen';
export { zip } from './zip';


I also see this pattern is used in some pending PRs too

I've been out of the loop, so it's entirely possible I'm confused or there is some magic that prevents it from being a problem--without requiring people use treeshaking. Or maybe that's the plan?

@cartant
Copy link
Collaborator

cartant commented Sep 28, 2017

Using this harness with a non-tree-shaking, CommonJS bundler:

const { Observable } = require("rxjs/Observable");
require("rxjs/add/operator/map");

When bundling rxjs@5.4.3, the resultant bundle size is 39,151 bytes.

When bundling rxjs@5.5.0-beta.2, the resultant bundle size is 550,768 bytes.

If, in operator/map.ts, this were to be used instead:

import { map as higherOrder } from '../operators/map'; 

The resultant bundle size would be 42,638 bytes.

@jayphelps jayphelps changed the title Some "lettable" operators e.g. rxjs/operator/multicast pulls in code for *all* operators Some operators e.g. rxjs/operator/multicast pulls in code for *all* operators now Sep 28, 2017
@jayphelps
Copy link
Member Author

jayphelps commented Sep 28, 2017

@cartant good catch, you're right! The problem is inverted: it's not the lettable operators which pull in the others, it's the older operator files that pull in all the lettables, as they defer their implementation to the lettable forms but do not specifically import only what they need

@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants