jacktuck / unfurl

Metadata scraper with support for oEmbed, Twitter Cards and Open Graph Protocol for Node.js :zap:
MIT License
481 stars 52 forks source link

Use global URL object #92

Closed wereHamster closed 2 years ago

wereHamster commented 2 years ago

The global URL has been added in Node.js v10.

This would be technically a breaking change, but I doubt people are still using Node.js older than v10. Version 12 is the oldest LTS at this moment.

jacktuck commented 2 years ago

I'm not sure if this change is worthwhile, it breaks older node version and provides nothing new? In general I'm not a fan of globals.

wereHamster commented 2 years ago

It makes it less specific to Node.js and more compatible with other runtimes (eg. Deno, Web/Cloudflare Workers etc). The other dependency that's specific to Node.js is fetch, but that API has just been added to Node.js v18, that's too recent to depend on.

Alternative could be to provide a «pure» version (import { unfurl } from "unfurl.js/pure") that uses global URL and fetch, parallel to the regular "unfurl.js" package which would continue to depend on Node.js specifics and node-fetch.

jacktuck commented 2 years ago

Thanks for the PR but I don't think we should have to worry about supporting runtimes like CF workers, deno, etc. This just doesn't seem worth it to me.