revolt.js icon indicating copy to clipboard operation
revolt.js copied to clipboard

Deno compatibility

Open NightScript370 opened this issue 3 years ago • 14 comments

It would be nice if we could use this within Deno. Here are the things that would have to occur if we were to proceed with this:

  • [ ] Switch axios to fetch (with the polyfill node-fetch for node.js)
  • [ ] Explicitly define '.ts' file extensions

There are many reasons to use Deno over Node, including the built-in TypeScript support, Permission system and much more

Is there a Revolt channel I could use to discuss revolt.js? It would be best for fast communication

NightScript370 avatar Jan 19 '22 03:01 NightScript370

On your last point, you can join the Revolt Lounge server and discuss this in the Revolt Development channel.

Rexogamer avatar Jan 19 '22 12:01 Rexogamer

Ok, this seems to be more work than I initially expected:

To maintain compatibility with Node, I tried to make a global deps.ts file with import()'s so that we could use URLs for Deno and NPM packages for Node. It ended up being a mess, with every module declaration being lost. That's not a fault of Deno; that's a fault of mine, because I have NO idea how to organize anything.

Also, while '.ts' is required in Deno, it would absolutely break Node. We'd have to use import('<file path>' + ("Deno" in (window || {}) ? '.ts' : ''))

NightScript370 avatar Jan 20 '22 03:01 NightScript370

This should be a little easier once Node 18+ becomes the norm/more widespread as it supports built-in fetch via undici

Rexogamer avatar Apr 24 '22 13:04 Rexogamer

I was told the dev team didn't want to replace axios, so we'll see what happens with that.

NightScript370 avatar Apr 24 '22 21:04 NightScript370

A lot of dependencies on Axios have been untied and it's likely going to be stripped out in the near future, it pretty much entirely on lives within the revolt-api package now.

insertish avatar Apr 24 '22 21:04 insertish

Alright, I'll have to join the Revolt channel again and discuss this. It's been a while since I've been on Revolt, either way, because this was one of the big factors for me. Either way, a work around for said issue exists in the form of PR #35

NightScript370 avatar Apr 24 '22 21:04 NightScript370

Currently halting on https://github.com/denoland/deno/issues/7296 so we don't get the monstrosity that is the comment I made above: https://github.com/revoltchat/revolt.js/issues/34#issuecomment-1017084667

NightScript370 avatar Apr 24 '22 21:04 NightScript370

Hm, so with Deno getting official NPM support and skypack, it may be worthwhile to reconsider whether this is needed or not. Obviously nothing will replace a decentralized module that wouldnt run through a compat layer, but it may be more work than its worth to introduce cross Node and Deno compatibility.

I personally no longer use Revolt, simply because the servers that were initially pro-Revolt decided against having a bridge, meaning im stuck on a different platform.

NightScript370 avatar Sep 12 '22 03:09 NightScript370

For what it's worth, if the lib isn't compatible with Deno yet I'm still in favour of compatibility

Rexogamer avatar Sep 12 '22 15:09 Rexogamer

So I just discovered the hard way that it is not compatible with Deno yet! Would love to see this working with Deno in the future!

Keep up the good work! ❤️

gaycookie avatar Mar 21 '23 15:03 gaycookie

On the first point, I plan to drop axios in the near future: https://github.com/insertish/oapi/issues/2

insertish avatar Apr 14 '23 19:04 insertish

Importing revolt.js using Deno's npm compatibility almost works, but it's broken due to #83. Fixing the second point mentioned in this issue is possible if we use esbuild instead of tsc to build Node releases. Dropping Axios support would be nice as that'd allow revolt.js to run without the compatibility layer included in Deno but that'd take a bit more work.

williamhorning avatar Jul 09 '23 18:07 williamhorning