Import is an empty module in Vite
billy4479 opened this issue · 5 comments
billy4479 commented
import * as argon2 from 'argon2-browser'
console.log(argon2.hash) // undefined
I'm using Vite as bundler and Typescript
antelle commented
Sounds like bundler issues
ooesili commented
@billy4479 did you ever figure this out?
billy4479 commented
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.
davidyuk commented
I think the author has published an npm package with the changes though.
it is published as @aeternity/argon2-browser
luojinzhang commented
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'
),
},
}