bignumber.js icon indicating copy to clipboard operation
bignumber.js copied to clipboard

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

Open jbakoc1 opened this issue 4 years ago • 8 comments

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?

jbakoc1 avatar Nov 10 '20 12:11 jbakoc1

It's the bignumber.mjs file.

See the package.json:

"module": "bignumber.mjs",

MikeMcl avatar Nov 10 '20 18:11 MikeMcl

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

phip1611 avatar Mar 01 '21 07:03 phip1611

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

jbakoc1 avatar Mar 01 '21 13:03 jbakoc1

Same issue here, any update?

abcfy2 avatar Mar 19 '21 03:03 abcfy2

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

Amir-Afkhami avatar Apr 08 '21 20:04 Amir-Afkhami

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.

jbakoc1 avatar Apr 09 '21 07:04 jbakoc1

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

gabrielbiga avatar Apr 14 '21 03:04 gabrielbiga

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

jbakoc1 avatar Apr 14 '21 11:04 jbakoc1