ngneat / until-destroy

🦊 RxJS operator that unsubscribe from observables on destroy
https://netbasal.com/
MIT License
1.74k stars 100 forks source link

Incorrect import from rxjs or bundle problem? #189

Closed slydor closed 2 years ago

slydor commented 2 years ago

Hi! Thank you for this wonderful package!

After updating @ngneat/until-destroy from v9.0.2 to v9.1.0 our builds had import errors, and we are not sure why:

./node_modules/@ngneat/until-destroy/fesm2015/ngneat-until-destroy.mjs:79:26-34 - Error: export 'mergeMap' (imported as 'mergeMap') was not found in 'rxjs' (possible exports: ArgumentOutOfRangeError, AsyncSubject, BehaviorSubject, ConnectableObservable, EMPTY, EmptyError, GroupedObservable, NEVER, Notification, NotificationKind, ObjectUnsubscribedError, Observable, ReplaySubject, Scheduler, Subject, Subscriber, Subscription, TimeoutError, UnsubscriptionError, VirtualAction, VirtualTimeScheduler, animationFrame, animationFrameScheduler, asap, asapScheduler, async, asyncScheduler, bindCallback, bindNodeCallback, combineLatest, concat, config, defer, empty, forkJoin, from, fromEvent, fromEventPattern, generate, identity, iif, interval, isObservable, merge, never, noop, observable, of, onErrorResumeNext, pairs, partition, pipe, queue, queueScheduler, race, range, scheduled, throwError, timer, using, zip)

We use rxjs 6.6.6, Angular 13.2.5 and nx 13.8.4.

In the bundle @ngneat/until-destroy/fesm2015/ngneat-until-destroy.mjs we have this line:

import { Subject, from, mergeMap, EMPTY, filter, Observable, observeOn, asapScheduler, catchError, Subscription } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

but actually, some operators must be pulled from 'rxjs/operators' as far as I know:

import { Subject, from, EMPTY, Observable, asapScheduler, Subscription } from 'rxjs';
import { takeUntil, mergeMap, filter, observeOn, catchError} from 'rxjs/operators';

In https://github.com/ngneat/until-destroy/commit/93199cfbb7cd01c72fc8f0531c81c15ae2baef50 I see the very same imports, i.e. {mergeMap} from rxjs.

Is this only available in rxjs 7 or do we lack something else here?

GregoireLgt commented 2 years ago

@slydor Having the same problem, it is indeed because this type of import is RxJS 7.x compatible but not 6.x image

slydor commented 2 years ago

@GregoireLgt thanks for looking that up! Then this release 9.1.0 would contain a breaking change, since in the package.json either v6 or v7 of rxjs is set as peerDep.

arturovt commented 2 years ago

Hey. Sorry, that wasn't meant to be a breaking change. This was just an autocomplete in my VSCode 🤦

I've published @ngneat/until-destroy@9.1.1.