I'm trying to fix some issues with cjs modules in my angular application, that is giving me warnings. To focus on one example, jsondiffpatch, i have installed the latest version (0.4.1). When running a ng build, I get the following from angular cli:
Warning: [filepath/some-component.ts] depends on 'jsondiffpatch'. CommonJS or AMD dependencies can cause optimization bailouts.
However, when clicking into the installed jsondiffpatch package, I can see that the package.json does indeed link to an esm build "module": "dist/jsondiffpatch.esm.js".
It seems I am misunderstanding how bundling works. Why would angular not recognise/use the esm file and instead opt to use the cjs file (if that is what is happening)? And how can i correct this?