Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node JS: crypto import polyfill not taken into account? #49

Open
matteocargnelutti opened this issue Dec 17, 2022 · 2 comments
Open

Node JS: crypto import polyfill not taken into account? #49

matteocargnelutti opened this issue Dec 17, 2022 · 2 comments

Comments

@matteocargnelutti
Copy link
Contributor

Hi there 👋 !

I see that there is now a polyfill to automatically import and declare crypto in the global scope.

Unfortunately, I'm getting the following error when using WARCRecord.create() after removing my own global import of crypto :

ReferenceError: crypto is not defined

For reference, I'm importing crypto as such to compensate for its absence:

import crypto from 'crypto'
global.crypto = crypto

I'm using warcio.js 2.0.1 with Node 18+.

Thanks in advance,

@ikreymer
Copy link
Member

Yes, the current polyfill applies only to the test suite. I was having trouble setting up a proper polyfill for the node build.
Though, Node 18 does have --experimental-global-webcrypto for making crypto global and I guess in node 19, this is the default..

@jlarmstrongiv
Copy link
Contributor

Finally found a way to have automatic polyfills:

Use inject with a separate polyfills file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants