Daninet / hash-wasm

Lightning fast hash functions using hand-tuned WebAssembly binaries
https://npmjs.com/package/hash-wasm
Other
894 stars 50 forks source link

How to pull in only a subset of algos via npm? #11

Closed namero999 closed 3 years ago

namero999 commented 3 years ago

Is this supposed to be taken care of via tree-shaking at build time?

"dependencies": {
    "hash-wasm": "latest"
}

import { md5 } from 'hash-wasm'

Or is there a better way?

Thanks!

Daninet commented 3 years ago

If tree shaking is enabled in your Webpack configuration, it will only bundle the md5 algorithm in the way you described.

Otherwise, you can directly import the md5 bundle: import { md5 } from 'hash-wasm/dist/md5.umd.min.js I don't recommend it, because the types declarations are not working in this case.