You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was having some problems while trying to use the Babel transpiler with Typebox modules because it makes use of BigInts which are not supported in older vesions of JS and Babel can't transpile them, so I wasn't being able to run the code on a ES5 JS VM with Nakama.
The solution I was able to get it working was to patch (with git patches and patch-package) the library and remove the uses of BigInt on the modules I was importing. ( Like typebox/value/hash that uses BigInts )
Another solution (as stated in https://babeljs.io/docs/babel-plugin-syntax-bigint) would be to make use of the JSBI library in Typebox and eventually run babel-plugin-transform-jsbi-to-bigint to codemod it to BigInt in the future.
I'm creating this issue because someone can get into an similar problem and this may be useful somehow, also I wanted to know if my current approach is correct or it wasn't needed.
The text was updated successfully, but these errors were encountered:
Suero152
changed the title
Uses of BigInt over the project breaks compatibility (?)
Uses of BigInt over the project breaks compatibility w/ ES5 (?)
May 14, 2024
The minimum ES target for TypeBox is ES2020 (so does expect the runtime to have support for the BigInt type) Note though that TypeBox doesn't use the BigInt literal syntax internally as some users have experienced issues transforming the 1000n suffix. From this it might be possible to polyfill the globalThis.BigInt constructor only (this might be easier than trying to patch for the syntax)
Unfortunately, I'm not familiar with the Nakama runtime or babel transform plugins so can't provide much assistance here, but do appreciate having links and references submitted for the benefit of other users. In terms of your outlined approach, I guess it's fine if it works :)
Would you like me to convert this issue into a discussion?
The minimum ES target for TypeBox is ES2020 (so does expect the runtime to have support for the BigInt type) Note though that TypeBox doesn't use the BigInt literal syntax internally as some users have experienced issues transforming the 1000n suffix. From this it might be possible to polyfill the globalThis.BigInt constructor only (this might be easier than trying to patch for the syntax)
Unfortunately, I'm not familiar with the Nakama runtime or babel transform plugins so can't provide much assistance here, but do appreciate having links and references submitted for the benefit of other users. In terms of your outlined approach, I guess it's fine if it works :)
Would you like me to convert this issue into a discussion?
Thanks for the speedy response, yeah you can convert into a discussion if you want, tysm for supporting this amazing lib
I was having some problems while trying to use the Babel transpiler with Typebox modules because it makes use of BigInts which are not supported in older vesions of JS and Babel can't transpile them, so I wasn't being able to run the code on a ES5 JS VM with Nakama.
The solution I was able to get it working was to patch (with git patches and patch-package) the library and remove the uses of BigInt on the modules I was importing. ( Like typebox/value/hash that uses BigInts )
Another solution (as stated in https://babeljs.io/docs/babel-plugin-syntax-bigint) would be to make use of the JSBI library in Typebox and eventually run babel-plugin-transform-jsbi-to-bigint to codemod it to BigInt in the future.
I'm creating this issue because someone can get into an similar problem and this may be useful somehow, also I wanted to know if my current approach is correct or it wasn't needed.
The patch I used to remove some BigInt usages: https://gist.github.com/Suero152/7508faa894f12477a5c2fec7d3a974da
The text was updated successfully, but these errors were encountered: