Warning: browser application depends on CommonJS modules | CommonJS or AMD dependencies can cause optimization bailouts.

When we used some js base module than angular gives us warning like: CommonJS or AMD dependencies can cause optimization bailouts. To disable these warnings, add the CommonJS module name to allowedCommonJsDependencies option in the build options located in angular.json file.

"build": {
  "builder": "@angular-devkit/build-angular:browser",
  "options": {
     "allowedCommonJsDependencies": [
        "lodash"
     ]
     ...
   }
   ...
},

It is recommended that you avoid depending on CommonJS modules in your Angular applications. Depending on CommonJS modules can prevent bundlers and minifiers from optimizing your application, which results in larger bundle sizes.

Angular

Leave a Reply