Angular application fails to polyfill WebCrypto for libraries that depend on it

For Workes & Pages, what is the name of the domain?

my-angular-app-ato.pages.dev

What is the error number?

N/A

What is the issue or error you’re encountering

✘ [ERROR] Deployment failed! - Failed to publish your Function. Got error: Uncaught Error: No such module “crypto”. imported from “chunk-TUV5YX6S.mjs”

What steps have you taken to resolve the issue?

I have isolated the issue down to occurring precisely when a library that expects a polyfilled WebCrypto module is instantiated in a component’s constructor.

However because cryptographic functions are so delicate, and depend so much on WebCrypto’s javascript-free implementation, I cannot simply use a fully-javascript library without introducing vulnerabilities.

What are the steps to reproduce the issue?

Fork the above, run “npm run deploy”

If you remove my service from the main-page component’s constructor, it will deploy correctly. Add it back, and the bug pops up again.

I suspect it’s an issue with the implementation of the polyfill fix.