-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Buffer
compatibility for browsers
#765
Comments
This might relate to the following PR, in the sense that the
|
@Dhaiwat10 I created this issue from a conversation with @Braqzen. @Braqzen Do you happen to have a simple repro for this problem? |
The steps are something like this (hopefully a repro):
The contract that I have is a simple counter. It has a single storage variable which is incremented and decremented by 1 when the function is called. It has a couple more functions but I doubt they matter. |
This can appear within any browser environment that is using Cryptography IIRC, but most typical setups include a polyfill that makes We wouldn't want to add anything into TS-SDK to change how that works, but we should at least document and test for it. |
Yeah, Vite is one of the few 'popular' setups that don't polyfill these things. I believe that's the reason why none of our tests are failing in #728 when run in a browser environment - it uses puppeteer which runs a headless version of Chromium under the hood. |
Mostly due to the fact that it's environment specific (browser), dependent on build tool, and easier for consumer to add then remove. If it's solely just inside the dependencies then that's fine with me |
Probably related: |
We will need to polyfill |
So for browser testing in #1630, I went down the consumer configuration route, rather than introducing the polyfill our side. Purely from the stance of trying to introduce minimal interruption to the packages themselves, and only changing the test infrastructure. On doing some digging, this is what's recommended rather than attempting to account for it on our side. I did have success in polyfilling it our side via I could also do an example with documentation based on the |
@FuelLabs/sdk-ts Pretty old one - is this still valid? |
@nedsalk and I chatted around the browser testing time and ended up opting to polyfill at the app level, as we do with the browser tests. This discussion sums it up well. Going to close this for now as we've gone back and fourth quite a bit, it could be revisited if raised by users but it's not a blocker as an app dev can resolve it. |
We need to support
Buffer
usage inside the Browsers.For example, someone using React with Vite might fall into this error:
And then having to resort to custom mapping configurations such by installing the
buffer
package:pnpm install buffer
And then configuring custom mappings in
vite.config.js
:The text was updated successfully, but these errors were encountered: