antelle/argon2-browser

Import is an empty module in Vite

billy4479 opened this issue · 5 comments

import * as argon2 from 'argon2-browser'
console.log(argon2.hash) // undefined

I'm using Vite as bundler and Typescript

Sounds like bundler issues

@billy4479 did you ever figure this out?

Not really, I ended up the Web Crypto API but there are many forks that work fine with Vite, just have a look on npm, they are not as popular as this package but they are there.
#78 would probably fix this but it sill hasn't been merged at the time writing. I think the author has published an npm package with the changes though.

I think the author has published an npm package with the changes though.

it is published as @aeternity/argon2-browser

I added this to vite.config.ts to make it work with vite

resolve: {
    alias: {
      'argon2-browser': path.resolve(
       'path/to/root',
        'node_modules/argon2-browser/dist/argon2-bundled.min.js'
      ),
    },
  }