Skip to content

Import Decimal from decimal.js rather than decimal.mjs#3165

Closed
nikolas wants to merge 1 commit intojosdejong:developfrom
nikolas:patch-1
Closed

Import Decimal from decimal.js rather than decimal.mjs#3165
nikolas wants to merge 1 commit intojosdejong:developfrom
nikolas:patch-1

Conversation

@nikolas
Copy link
Copy Markdown

@nikolas nikolas commented Feb 24, 2024

The decimal.js package provides the decimal.js as well as decimal.mjs files. See: https://github.com/MikeMcl/decimal.js

In certain webpack configurations, the decimal.mjs file is loaded, causing the error:

Uncaught TypeError: decimal_js__WEBPACK_IMPORTED_MODULE_0__.default.clone is not a function
    createBigNumberClass BigNumber.js:12
    assertAndCreate factory.js:35

When we are more specific with this import, this error is resolved.

The `decimal.js` package provides the decimal.js as well as decimal.mjs files. See: https://github.com/MikeMcl/decimal.js

In certain webpack configurations, the decimal.mjs file is loaded, causing the error:
```
Uncaught TypeError: decimal_js__WEBPACK_IMPORTED_MODULE_0__.default.clone is not a function
    createBigNumberClass BigNumber.js:12
    assertAndCreate factory.js:35
```

When we are more specific with this import, this error is resolved.
@josdejong
Copy link
Copy Markdown
Owner

Thanks for your PR Nikolas.

In general, I would like to move code to ESM, and not to CommonJS/UMD, and use the regular import instead of pointing to a specific file.

Can we figure out what is going wrong in your setup? Maybe we can come up with an other solution. How can I reproduce this issue?

@gwhitney
Copy link
Copy Markdown
Collaborator

Since this is over a year old and no more information was forthcoming, closing.

@gwhitney gwhitney closed this Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants