CommonJS¶
Rule¶
Always prefer native ECMAScript modules (ESM) throughout your application and its dependencies. ESM is a fully specified web standard and JavaScript language feature with strong static analysis support. This makes bundle optimizations more powerful than other module formats.
Angular CLI also supports importing CommonJS dependencies into your project and will bundle these dependencies automatically.
Here is a list of known CommonJS libraries and their replacements :
| CommonJS | ESM |
|---|---|
| moment | dayjs |
| lodash | lodash-es |