Skip to content

Remove the node protocol from the require statement#250

Merged
mattt merged 4 commits intomainfrom
fix/require-node-crypto-bundler-error
May 2, 2024
Merged

Remove the node protocol from the require statement#250
mattt merged 4 commits intomainfrom
fix/require-node-crypto-bundler-error

Conversation

@aron
Copy link
Copy Markdown
Contributor

@aron aron commented May 2, 2024

This should improve the situation for certain JavaScript bundlers in the ecosystem which do not like the node:crypto require statement, see #225 and #243.

@aron
Copy link
Copy Markdown
Contributor Author

aron commented May 2, 2024

Urgh, this is probably a no-go too, if we remove the node: prefix we break Cloudflare:

✘ [ERROR] Could not resolve "crypto"

    ../../lib/util.js:95:21:
      95 │     crypto = require("crypto").webcrypto;
         ╵                      ~~~~~~~~

  The package "crypto" wasn't found on the file system but is built into node.
  Add "node_compat = true" to your wrangler.toml file and make sure to prefix the module name with "node:" to enable Node.js compatibility.

@aron aron force-pushed the fix/require-node-crypto-bundler-error branch 2 times, most recently from ab30893 to 2e68c8d Compare May 2, 2024 13:35
@@ -0,0 +1,14 @@
{
"name": "replicate-next",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aron Thanks for taking the time to add an integration test for Next.js!

Copy link
Copy Markdown
Contributor

@mattt mattt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this. Thanks so much for your work on this. Here's hoping that this will resolve the issues folks were having with standard library imports.

aron added 4 commits May 2, 2024 14:30
@mattt mattt force-pushed the fix/require-node-crypto-bundler-error branch from 2e68c8d to 6ae67a2 Compare May 2, 2024 21:30
@mattt mattt merged commit 587d445 into main May 2, 2024
@mattt mattt deleted the fix/require-node-crypto-bundler-error branch May 2, 2024 21:32
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

Successfully merging this pull request may close these issues.

2 participants