danang-id / simple-crypto-js

Simplified AES cryptography for safer and easier encryption and decryption processes of any JavaScript objects.
https://simplecrypto.js.org
MIT License
85 stars 27 forks source link

Unable make it work with Remix #52

Open Loschcode opened 5 months ago

Loschcode commented 5 months ago

I'm on a Remix project, I added simple crypto through pnpm then on top of my file I just added

import SimpleCrypto from "simple-crypto-js";

const secretKey = "some-unique-key";
const crypto = new SimpleCrypto(secretKey);

But this doesn't work properly with Remix build

 info  rebuilding... (~ app/routes/_tools.qr-code-time-tracking.tsx)
 info  rebuilt (496ms)
TypeError: SimpleCrypto is not a constructor
    at file:///...website/app/routes/_tools.qr-code-time-tracking.tsx:12:16
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

Do you know what could be going on right now?

Loschcode commented 5 months ago

Your documentation is wrong, you should import it this way

import { SimpleCrypto } from "simple-crypto-js";

I'd advise updating your doc because other people might see it crash.