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
Do not know how to serialize a BigInt #2375
Comments
Hi @TomMettam, I am unable to replicate. Can you please provide a minimal reproduction? |
I don't really know where to begin when doing that, because I can't imagine what it could be trying to serialise. What does the app JSON encode during the process? |
I suspected that it might be rollup, but without a reproduction it is hard to tell what is happened. |
Hello. Creating a minimal reproduction isn't feasible for me because my project is huge, and the error reported from ng-packagr isn't in any way helpful in knowing what might be triggering the errror. So I added some code to diagnose the issue. The exception is thrown in
I added some code to scan the object for bigints, and it spat out the following:
I don't really know what any of these properties mean, but can you tell me, based on this, where the troublesome bigint may be sitting? |
Thanks for the above, so it appears to be this line ng-packagr/src/lib/flatten/rollup.ts Line 83 in 9b93a18
|
Well, I'm not sure if that is the "cause", it's the contents of bundle.cache which are the issue - there's a bigint in there which JSON.stringify can't serialize |
I've patched the script ng-packagr/src/lib/flatten/rollup.ts to find out, where the BigInt is located:
And this was the result:
In my case this was the problematic code:
BigInt literals like 1n or 97n produce this kind or error. Replace them with BigInt(1) (resp. BigInt(97)) and the problem is gone. Hope that helps..... |
just stumbled across this, with the confusing behavior that it didn't compile locally but working without issues in the CI build ... as ng-packagr automatically disables the cache in CI environments, the error may be hidden / not reproducible in some environments. ng-packagr/src/lib/ng-package/options.di.ts Lines 23 to 24 in 2c618ae
the issue is also triggered by BigInt literal in my code (same error message as in the original description), I can confirm replacing |
Type of Issue
Description
When building an angular library, I get the error "Do not know how to serialize a BigInt"
My project does use BigInts, but doesn't attempt to serialize them at any point
How To Reproduce
It's unclear exactly what is being serialized here so I don't know how to reproduce the error
Expected Behaviour
Project should build
Version Information
Please include all version numbers that might be relevant, e.g. third-party libraries
The text was updated successfully, but these errors were encountered: