torus-node icon indicating copy to clipboard operation
torus-node copied to clipboard

Buffer not found in static build using sveltekit and Torus library

Open ralyodio opened this issue 2 years ago • 1 comments

I need a way to alias Buffer for the browser.

Not sure which module requires this but its probably crypto related.

500

Buffer is not defined

@http://localhost:3000/_app/pages/index.svelte-2478ade3.js:1:111754

Problem is using Torus node library.

Here is a repo: https://github.com/ralyodio/torus-bufer

npm i
npm run build
npm run preview

...you will see error. npm run dev works fine since node handles requests. Its the browser only environment that is the issue.

The polyfill in svelte.config.js appears to not work: https://github.com/ralyodio/torus-bufer/blob/master/svelte.config.js

ralyodio avatar May 19 '22 14:05 ralyodio

Can someone please tell us how to fix? We are blocked by this issue. It works with with npm run dev which uses node to serve (and has Buffer). but when doing npm run build for a static sveltekit build Buffer is undefined in the browser.

Is there a browser version of torus-node? The specific module we are using is "@toruslabs/openlogin": "^1.7.1",

ralyodio avatar May 19 '22 14:05 ralyodio