0

I'm getting a number of such warnings on various files while upgrading project from angular 12 to angular 13 (originally written in Angular 6).

'..ts' depends on 'rxjs/BehaviorSubject'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

'..ts' depends on 'rxjs/add/observable/throw'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

'..ts' depends on 'rxjs/add/operator/catch'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

'..ts' depends on 'rxjs/Observable'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

'..ts' depends on 'rxjs/operators/map'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

'..ts' depends on 'rxjs/operators/tap'. CommonJS or AMD dependencies can cause optimization bailouts. For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

The link provided says here CommonJS is making your bundles larger, but I'm not clear what change should I make to my code. Please advise! For example, I have:

import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { map } from 'rxjs/operators/map';
import { tap } from 'rxjs/operators/tap';
import { catchError, retry, delay } from 'rxjs/operators';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';

In my package.json I have

"rxjs": "^6.5.3", "rxjs-compat": "^6.6.7",

and I'm using

"typescript": "~4.6.2"

SilverFish
  • 1,014
  • 6
  • 28
  • 65
  • 1
    Does this answer your question? [Upgrading to Angular 10 - Fix CommonJS or AMD dependencies can cause optimization bailouts](https://stackoverflow.com/questions/62592903/upgrading-to-angular-10-fix-commonjs-or-amd-dependencies-can-cause-optimizatio) – JSON Derulo May 04 '23 at 05:49
  • Thanks, I had added "rxjs/BehaviorSubject", "rxjs/add/observable/throw", "rxjs/add/operator/catch", "rxjs/Observable", "rxjs/operators/map", "rxjs/operators/tap" but adding "rxjs-compat" did the trick – SilverFish May 04 '23 at 14:50

0 Answers0