cipchk / ngx-filesaver

Simple file save with FileSaver.js
https://cipchk.github.io/ngx-filesaver/
MIT License
86 stars 18 forks source link

Bump to ngx-filesaver 15.0.1 results in Errors #42

Closed TheCell closed 1 year ago

TheCell commented 1 year ago

We are using this package in our Angular 15 application and during a regular maintenance task we updated the package from 15.0.0 to 15.0.1. However, the version bump results in errors: image

Error: export 'takeUntil' (imported as 'takeUntil') was not found in 'rxjs' (possible exports: Ar
gumentOutOfRangeError, AsyncSubject, BehaviorSubject, ConnectableObservable, EMPTY, EmptyError, GroupedObservable, NEVER, Notification, NotificationKind, ObjectUnsub
scribedError, Observable, ReplaySubject, Scheduler, Subject, Subscriber, Subscription, TimeoutError, UnsubscriptionError, VirtualAction, VirtualTimeScheduler, animat
ionFrame, 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, q
ueue, queueScheduler, race, range, scheduled, throwError, timer, using, zip)

I suspect it has to do with this commit b2978bd86bac9f8249fbbc12525de06916612f3a.

I tried to setup a new angular project, import ngx-filesaver 15.0.1 and rxjs takeuntil directly but it does not result in the error on its own. But If I manually set the rxjs version of the project to ^6.6.7

"rxjs": "^6.6.7",

and then using the older import for rxjs in my component, it will fail with the same error message.

import { Component } from '@angular/core';
import { FileSaverService } from 'ngx-filesaver';
import { fromEvent, interval } from 'rxjs';
import { takeUntil } from 'rxjs/operators';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'angular-tour-of-heroes';

  public constructor (private _FileSaverService: FileSaverService)
  {
    console.log(_FileSaverService);

    const source = interval(1000);
    const clicks = fromEvent(document, 'click');
    const result = source.pipe(takeUntil(clicks));
    result.subscribe(x => console.log(x));
  }
}

Is the newly added imports to lib/src/filesaver.directive.ts a breaking change? In version 6.6.7 the 'takeUntil' was still imported like this: import { takeUntil } from 'rxjs/operators'; (which we imported from there) Might be helpful.

cipchk commented 1 year ago

The main version number of ngx-filesave has always been consistent with that of angular.

Starting from angular 15.0, the rxjs version has been updated to 7.8.

And rxjs has beed deprecated 'rxjs/operators' since 7.2. The above are some historical factors, and it is reasonable to use 'rxjs' instead of 'rxjs/operators'.

TheCell commented 1 year ago

Thank you very much for your answer. I think this issue can be closed, it's a mistake on our part to not have upgraded rxjs when upgrading Angular until now!