Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Deno compatibility #7

Open
NightScript370 opened this issue Jan 27, 2022 · 1 comment
Open

Deno compatibility #7

NightScript370 opened this issue Jan 27, 2022 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers todo

Comments

@NightScript370
Copy link

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:

  • Deno relies on module imports with the extension
  • Node.js relies on module imports without the extension

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.

@abdulrahman1s abdulrahman1s added enhancement New feature or request good first issue Good for newcomers todo labels May 25, 2022
@abdulrahman1s
Copy link
Owner

I got some free time this week. 😄
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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers todo
Projects
None yet
Development

No branches or pull requests

2 participants