MikeMcl / bignumber.js

A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic
http://mikemcl.github.io/bignumber.js
MIT License
6.68k stars 742 forks source link

Angular 10 module depends on 'bignumber.js'. CommonJS or AMD dependencies can cause optimization bailouts. #278

Open jbakoc1 opened 3 years ago

jbakoc1 commented 3 years ago

After upgrading to Angular version 10 I get the message depends on 'bignumber.js'. CommonJS or AMD dependencies can cause optimization bailouts. Are you going to publishing an ES module?

MikeMcl commented 3 years ago

It's the bignumber.mjs file.

See the package.json:

"module": "bignumber.mjs",
phip1611 commented 3 years ago

Did anyone found a solution how angular build finds the *.mjs file? I have the same problem too.

jbakoc1 commented 3 years ago

@phip1611 The way I found was to rename the bignumber.mjs -> bignumber.js There is probably a better way that I don't know 😉

abcfy2 commented 3 years ago

Same issue here, any update?

Amir-Afkhami commented 3 years ago

This is because in Angular you must add this for each CommonJS Dependency: "options": { "allowedCommonJsDependencies": ["bignumber.js"] }

jbakoc1 commented 3 years ago

This is because in Angular you must add this for each CommonJS Dependency: "options": { "allowedCommonJsDependencies": ["bignumber.js"] }

This option tells the compiler to ignore the warning. Not fixing the issue.

gabrielbiga commented 3 years ago

I'm not 100% sure why, but importing like that seems to solve the warning:

import { BigNumber } from 'bignumber.js/bignumber';

webpack-bundle-analyzer: bignumbermjs

jbakoc1 commented 3 years ago

I confirm this. I changed my imports. Thanks @gabrielbiga