I know the README says Not for use in Webpack, but Webpack isn't only used for outputting browser code. When using a target other than web (NodeJS, Electron, etc.) there's no reason this library shouldn't be able to be bundled using Webpack too.
The reason it doesn't work is because of this block of code:
This PR addresses the issue by turning the registeredAlgorithms into a factory function, rather than a path, allowing Webpack to effectively track which files should be bundled. This will allow users to use Webpack for any NodeJS target
I know the README says Not for use in Webpack, but Webpack isn't only used for outputting browser code. When using a target other than
web
(NodeJS, Electron, etc.) there's no reason this library shouldn't be able to be bundled using Webpack too.The reason it doesn't work is because of this block of code:
https://github.com/anvilresearch/webcrypto/blob/5303c62ac2f0c0cef293d9a8d3d54e0b794149aa/src/algorithms/SupportedAlgorithms.js#L84
Webpack doesn't handle dynamic
require
very well.This PR addresses the issue by turning the
registeredAlgorithms
into a factory function, rather than a path, allowing Webpack to effectively track which files should be bundled. This will allow users to use Webpack for any NodeJS target