gramjs icon indicating copy to clipboard operation
gramjs copied to clipboard

CryptoFile for browser

Open MaxNamazov opened this issue 3 years ago • 6 comments

Hello. I'm trying to build the lib for browser usage. I cloned the repo, npm i and then npx webpack in it. It's been built successfully but when I try to use it I get an error: TypeError: CryptoFile_1.default.randomBytes is not a function. I tried to debug a bit and it seems that webpack uses CryptoFile.ts instead of CryptoFile-Browser.ts and since node crypto module is not polyfilled we get an empty crypto module in the result. So what's wrong with my attempt? What part of the code is responsible for mangling imported file names for different build targets? Thanks in advance.

MaxNamazov avatar Nov 02 '22 15:11 MaxNamazov

The easiest way is to download the npm browser pack. it will come with all the correct files.

if you want to use webpack then currently you'll have to rename the files yourself (or use a script that does it for you).

painor avatar Nov 02 '22 18:11 painor

I managed to compile sources after renaming files. Thank you for your help

MaxNamazov avatar Nov 03 '22 06:11 MaxNamazov

I managed to compile sources after renaming files. Thank you for your help

may I ask how you fixed this issue?

YohannesTz avatar Dec 16 '23 10:12 YohannesTz

How do you fix this issue?

izulwahidin avatar Feb 21 '24 05:02 izulwahidin