Search code examples
angulartypescriptlodash

Optimization bailouts warning when using lodash in Angular project


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

This is how i use lodash in my x component.ts

import * as _ from 'lodash';
....
....

foo(){
 this.myObject = _.mapValues(this.myObject , () => true);
}

How do I get rid of this warning?


Solution

  • Instead of using the CommonJS variant of lodash, you could use lodash-es (ES modulized).