Open NightScript370 opened 2 years ago
I got some free time this week. :smile: Porting better-revolt.js to deno isn't hard since we depending on way less libraries than the official revolt.js I think we can easily create an automated script to convert the whole library to deno, I saw something similar at postgres I'll look into that tomorrow.
It would be nice to have a Revolt library that is compatible with Deno. I already submitted an issue on the official JavaScript library, but let's also try and get this one working. There are two ways we can go about it: SkyPack or native.
SkyPack
SkyPack is a CDN meant to convert CommonJS modules to ESM. Currently, you could use this for Deno compatibility but this loses the typings, because SkyPack isn't seeing the typings file. Fortunately, the fix is easy; define the typings file in package.json, under a typings field
Native Compatibility
This would take significantly more work but it would mean that we are able to use the same library on Deno and Node.JS, without relying on a CDN. Since Deno could also natively run TypeScript files, it would mean significantly less work for publication and updating.
There are two major things that one would have to consider before changing our repo:
Every static import would have to be changed to a dynamic one with the following code:
import('<file path>' + ("Deno" in (window || {}) ? '.ts' : ''))
Also, while Node.js relies on a node_modules folder, Deno could import modules from anywhere. This means that the above problems would exist on every module we use as a dependency. It's probably best to start from the end (aka this library) and work our way up to the dependencies.