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

crypto-browserify has an upstream dependency on node:crypto #238

Open
sagargurtu opened this issue Jan 3, 2025 · 3 comments
Open

crypto-browserify has an upstream dependency on node:crypto #238

sagargurtu opened this issue Jan 3, 2025 · 3 comments

Comments

@sagargurtu
Copy link

  • crypto-browserify depends on browserify-sign@^4.2 link
  • browserify-sign@^4.2 depends on elliptic@^6.5 link
  • elliptic@^6.5 depends on brorand@^1.1 link
  • brorand@^1.1 uses crypto link
@ljharb
Copy link
Member

ljharb commented Jan 3, 2025

Looks like that will only affect a web worker, but also elliptic distributes a bundle, so it could be addressed in either place. (cc @indutny)

In a regular browser or node context, there shouldn't be any issue.

@sagargurtu
Copy link
Author

sagargurtu commented Jan 3, 2025

I'm polyfilling Node.js builtins in my application using a Vite plugin. Whenever Vite encounters an import of "crypto", the plugin resolves it to "crypto-browserify". However, the issue mentioned above creates a cyclic dependency on "crypto", which ultimately breaks the build.

This condition in the upstream dependency will not be evaluated during vite build, causing Vite to resolve "crypto" in the else block, which in turn creates the cyclic dependency.

@ljharb
Copy link
Member

ljharb commented Jan 3, 2025

A cyclic dependency shouldn't break the build either - cycles are perfectly supported by both CJS and ESM.

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

2 participants