Closed thedocbwarren closed 3 years ago
This appears to be coming from @trust/webcrypto. This is a dependency of hashlink.
Looks like that code is in the @trust/webcrypto
dependency that gets installed. src/algorithms/index.js
file registers something with ../algorithms/SHA
path, that path exists, and SupportedAlgorithms.js
requires it. So probably some issue with how webpack tries to handle dynamic requires.
I doubt using webpack with a node output target has been tested much. If fixes are needed to make that work better, let us know. Sometimes the crypto issues with webpack can get tricky.
Ok, think I solved the issue. The webpack process bundles this library unless it's used as an external. I am publishing a UMD module. It's clobbering that path as you mentioned. Using as an "external" in the webpack.config solves it like so:
externals: [
{
"hashlink": {
commonjs: "hashlink",
commonjs2: "hashlink",
amd: "hashlink",
root: "hashlink"
}
]
This tells me you are right, it's the dynamic require with the ../ path.
Ultimately for my usage I do not want to bundle, an external is what I want. Other users may wish different.
I think this is good honestly. Thank you for the support.
When using:
during mocha test I receive:
Error: Cannot find module '../algorithms/SHA'
Code is webpacked and using node 14 along with node output target