jshemas / openGraphScraper

Node.js scraper service for Open Graph Info and More!
MIT License
643 stars 102 forks source link

Add Support for Edge Functions #203

Closed rocketman-21 closed 8 months ago

rocketman-21 commented 8 months ago

Is your feature request related to a problem? Please describe.

When deploying serverless functions in an Edge environment (e.g., Vercel's Edge Functions), I encounter a module resolution error with open-graph-scraper and its dependency on undici. The undici library attempts to resolve the 'crypto' module, which is unavailable or not resolved correctly in the edge runtime environment.

Describe the solution you'd like

I'd appreciate it if the pkg library could be enhanced to ensure compatibility with Edge function environments. This would involve ensuring that dependencies, especially native Node.js modules like 'crypto', can be seamlessly resolved and used.

Describe alternatives you've considered

While I've contemplated searching for an alternative to open-graph-scraper that doesn't rely on undici, this approach isn't ideal. It might require significant code refactoring and additional testing, and the alternative libraries might not provide the same features or performance.

rocketman-21 commented 8 months ago

works here

https://github.com/rocketmanh/openGraphScraper-edge

jshemas commented 8 months ago

Hello. This is not something I'm interested in doing at the moment. I added undici as a dependency so users would have a consistent experience no matter what node version they were using and I would have some level of control to fix issues with undici.

If you want, you can perform the request yourself and pass the html into open-graph-scraper-lite It does not use undici and does all of the same things as this package.