Problem
When using mathjs in an Angular project (and likely other modern ESM-first bundlers), the following warnings are emitted during the build:
▲ [WARNING] Module 'seedrandom' used by 'node_modules/mathjs/lib/esm/function/probability/util/seededRNG.js' is not ESM
▲ [WARNING] Module 'escape-latex' used by 'node_modules/mathjs/lib/esm/utils/latex.js' is not ESM
▲ [WARNING] Module 'javascript-natural-sort' used by 'node_modules/mathjs/lib/esm/function/relational/compareNatural.js' is not ESM
▲ [WARNING] Module 'tiny-emitter' used by 'node_modules/mathjs/lib/esm/utils/emitter.js' is not ESM
CommonJS or AMD dependencies can cause optimization bailouts.
For more information see: https://angular.dev/tools/cli/build#configuring-commonjs-dependencies
Proposal
All four of these dependencies are tiny libraries that haven't been updated in 7+ years:
| Package |
Last publish |
Size |
seedrandom |
7 years ago |
small |
escape-latex |
7 years ago |
small |
javascript-natural-sort |
9 years ago |
small |
tiny-emitter |
7 years ago |
small |
Since they are unmaintained and unlikely to ever ship ESM builds, I'd suggest inlining their code directly into mathjs as proper ESM modules. This would:
- Eliminate the CommonJS warnings for Angular/esbuild/Vite users
- Allow tree-shaking to work properly on this code
- Remove external dependencies that are effectively abandoned
I'll follow up with PRs to inline each of these.
Problem
When using mathjs in an Angular project (and likely other modern ESM-first bundlers), the following warnings are emitted during the build:
Proposal
All four of these dependencies are tiny libraries that haven't been updated in 7+ years:
seedrandomescape-latexjavascript-natural-sorttiny-emitterSince they are unmaintained and unlikely to ever ship ESM builds, I'd suggest inlining their code directly into mathjs as proper ESM modules. This would:
I'll follow up with PRs to inline each of these.