-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: calculator-bn.js #701
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Its Babel that you are having an issue with. The presets: [
[
'@babel/preset-env',
{
modules,
targets,
},
],
'@babel/preset-typescript',
], It has to do with the error you were getting.
I found this comment on an issue someone submitted on Though I don't know much about Babel or what that changes about the config. It all compiled okay on my machine, but we'd need @sarahdayan to consider what this changes about the build process, or if it can be overridden for just this package. |
}, | ||
"dependencies": { | ||
"@dinero.js/core": "2.0.0-alpha.12", | ||
"bn.js": "^5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an exact version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a peerDependency instead? There's two ways it'll work with dinero - by passing BN instances into amount
, and by calculator-bn using it internally. Ideally those are both supported in a similar way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding it as a peerDependency could solve the issue with rollup too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though, I think it then needs to be added to devDependencies
in the root package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, already added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe this file belongs in the library packages/calculator-bn.js/src/bn.js.d.ts
. It would probably be best if it was a custom types packages and used as a dependency.
@types/bn.js from DefinitelyTyped wasn't working for me because of their |
@johnhooks i wasn't getting this error 🤔
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit ac195a9:
|
@johnhooks here's the error i get on build (regardless of order in babel.config.js)
|
package.json
Outdated
@@ -42,10 +42,12 @@ | |||
"@babel/preset-env": "7.20.2", | |||
"@babel/preset-typescript": "7.18.6", | |||
"@microsoft/api-extractor": "7.33.5", | |||
"@rollup/plugin-commonjs": "^23.0.5", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lmk if u want this + adding it to rollup config in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sarahdayan would need to take a look at this. Perhaps not rolling up bn.js
and having it a peer dependency of @dinero.js/calculator-bn.js
would work, it could be configured as external.
EDIT: Though I don't know how that would affect the umd
builds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added as peerDep, removed this d102791. Thanks for the tips, i'm a rollup noob!
It was in the Circle CI log, it was one of the errors on my system. |
Co-authored-by: John Hooks <bitmachina@outlook.com>
Co-authored-by: John Hooks <bitmachina@outlook.com>
Hey @mvayngrib and sorry for the late response. Thanks for all your work so far! I'm trying to keep Dinero.js lean at the moment though, so anything that's tied to a specific library may not be a good fit yet. What do you think about making this a third-party Dinero.js calculator available as an npm package on your end? Based on how much traction it gets, we could reconsider bringing it to the monorepo. How does it sound? |
@sarahdayan sure, let me close this for now |
Summary
implement calculator for https://github.com/indutny/bn.js/ (very commonly used in the world of crypto)
draft while i figure out the TS types for bn.js, both the inlined and the DefinitelyTyped one is making rollup unhappy 😢lmk if you want me to add a section to the docs mirroring this one
dinero.js/website/data/docs/guides/using-different-amount-types.mdx
Line 39 in e7e9a19