user1066231
user1066231

Reputation: 593

rxjs/observable/of alternate for Angular 10, to avoid warning CommonJS or AMD dependencies can cause optimization bailouts

After upgrading to Angular 10, started receiving warning

".. *.ts depends on 'rxjs/observable/of'. CommonJS or AMD dependencies can cause optimization bailouts."

Found in internet about how to disable the warning by using "allowedCommonJsDependencies". But want to properly replace the below implementation so the warning is truly addressed instead of just disabling it. any help in this regard, ie finding the right alternate for the function 'observable.of' that addresses the above warning in Angular 10..

import { of } from 'rxjs/observable/of';


 private readRes(path: string, langType: LanguageType) {
if (['html', 'webcomponent'].includes(langType) || !path) {
  return of(path);
}

Upvotes: 5

Views: 1220

Answers (1)

abhay tripathi
abhay tripathi

Reputation: 4022

In RxJs 6+ , use import { of } from 'rxjs';

Before RxJs 6, use import { of } from 'rxjs/observable/of';

Upvotes: 4

Related Questions