type-comparator
type-comparator copied to clipboard
Angular warns on CommonJS or AMD dependencies
When a class in Angular app uses types from the library, Angular prints the following warning while executing ng build.

Versions Angular: v14+ (I've not checked on earlier ones). type-comparator: 0.2.9
Let me dive into the problem. :)
I suppose the module property in tsconfig.json should be changed from commonjs to at least ES2015.
That's true.
But then other consumers cannot do require('type-comparator'). Just tested....
Even node-fetch made a major release to support ESM...
Not sure it's right direction... But may be someone help me to find a way to support both CJS and ESM 😄
@AlexElin I hope this link will help you https://angular.io/guide/build#configuring-commonjs-dependencies
for me it works
@vasaeps3 In effect it's just ignoring the warning (suppressing it). In my opinion a correct solution would be providing ESM modules.
There're a several ways to do this:
- Switch to ESM from CJS. It's a breaking change. However, the version of this library starts with 0. According to the semver docs, it's ok to change public API in this case.
- Provide both ESM and CJS.