unfurl icon indicating copy to clipboard operation
unfurl copied to clipboard

Use global URL object

Open wereHamster opened this issue 2 years ago • 2 comments

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.

wereHamster avatar Jun 05 '22 18:06 wereHamster

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.

jacktuck avatar Jun 06 '22 21:06 jacktuck

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.

wereHamster avatar Jun 07 '22 09:06 wereHamster

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.

jacktuck avatar Oct 23 '22 02:10 jacktuck