Jsonforms uses lodash which causes "optimization bailouts" (angular)

Hi,

I’m using Angular 13.3.7 with @jsonforms/angular and @jsonforms/angular-material version 3.0.0-beta.2

In the logs i’ve tons of “bailout” warnings caused by jsonforms and its dependencies. How to optimize the import of this external dependencies?

Warning: node_modules\@jsonforms\angular-material\__ivy_ngcc__\lib\esm\other\master-detail\master.js depends on 'lodash/get'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\angular-material\__ivy_ngcc__\lib\esm\other\master-detail\master.js depends on 'lodash/some'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\angular-material\__ivy_ngcc__\lib\esm\other\object.renderer.js depends on 'lodash/isEmpty'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\angular-material\__ivy_ngcc__\lib\esm\other\object.renderer.js depends on 'lodash/startCase'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\angular\__ivy_ngcc__\lib\esm\abstract-control.js depends on 'lodash/merge'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\angular\__ivy_ngcc__\lib\esm\jsonforms-root.component.js depends on 'ajv'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\angular\__ivy_ngcc__\lib\esm\jsonforms.component.js depends on 'lodash/maxBy'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'ajv-formats'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/cloneDeep'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/endsWith'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/filter'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/find'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/fp/set'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/has'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/includes'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/isEqual'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/isFunction'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/keys'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/range'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/reduce'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/remove'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/toPairs'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Warning: node_modules\@jsonforms\core\lib\jsonforms-core.esm.js depends on 'lodash/union'. CommonJS or AMD dependencies can cause optimization bailouts.
For more info see: https://angular.io/guide/build#configuring-commonjs-dependencies

Hi @derdeka,

we only use specialized imports e.g. import isEmpty from 'lodash/isEmpty' which is basically manual treeshaking. You can therefore ignore these warnings. There is an option (i.e. allowedCommonJsDependencies: ["lodash"]) which can be handed over to the builder.

I did not try it myself but you should also be able to alias lodash to lodash-es via webpack. So if you try to go this route please report :wink: