transcend-io / penumbra

Encrypt/decrypt anything in the browser using streams on background threads.
https://penumbra-example.vercel.app/
Apache License 2.0
145 stars 19 forks source link

Webpack example #189

Closed 0michalsokolowski0 closed 3 years ago

0michalsokolowski0 commented 3 years ago

Hello,

I spent a couple of hour trying make import work without any success. When I trying to import any function e.g. "encrypt" I am getting undefined.

Could you provide an example of usage with any Webpack based project? In my case example with create-react-app for instance would be extremely helpful.

michaelfarrell76 commented 3 years ago

did you see this? https://github.com/transcend-io/penumbra#webpack

0michalsokolowski0 commented 3 years ago

Yes, I did see this. But still I wasn't able to make it work.

0michalsokolowski0 commented 3 years ago

It might be enough for production build, but still how I am supposed to use it with webpack-server. For me it is far from clear and unfortunately it make the lib unusable for me.

michaelfarrell76 commented 3 years ago

@0michalsokolowski0 sorry to hear that! the crypto operations are quick heavy and so we had to bundle the code into a web worker which is non trivial to bundle with webpack.

i can help you debug if you share more information on the error you are seeing and the webpack config you have

0michalsokolowski0 commented 3 years ago

Thanks for the quick response. My problem is pretty simple, I have an application created with CRA (example) I am trying to import penumbra, then I am getting error: Cannot read property 'encrypt' of undefined.

My primary issue is how to bundle the library into my app with webpack-dev-server to run it locally. I've spent quite a lot of time trying to accomplish this (even with CRA ejected) without success.. 😞

michaelfarrell76 commented 3 years ago

@0michalsokolowski0 penumbra requires additional webpack/HTML setup outside of just the npm import. im not too familiar with create react app, but i was able to get it working here: https://codesandbox.io/s/cranky-browser-2mh68?file=/src/App.tsx its not the prettiest but it works!

michaelfarrell76 commented 3 years ago

https://github.com/transcend-io/penumbra/issues/75

michaelfarrell76 commented 3 years ago

@0michalsokolowski0 gonna close this for now since the example is there but please re-open and ping me if you cant get this to work with that example!