toposort icon indicating copy to clipboard operation
toposort copied to clipboard

Deno support

Open rluvaton opened this issue 3 years ago • 4 comments

Can you please add Deno support? Since this project doesn't have any dependency it should be fairly easy

rluvaton avatar Jan 02 '21 22:01 rluvaton

What does deno need?

marcelklehr avatar Jan 02 '21 22:01 marcelklehr

You don't really need anything but mod.js file is welcome

rluvaton avatar Jan 02 '21 22:01 rluvaton

Cool. You're welcome to submit a pull request in case you don't want to wait for me to get around to this :)

marcelklehr avatar Jan 03 '21 18:01 marcelklehr

Cool. You're welcome to submit a pull request in case you don't want to wait for me to get around to this :)

@marcelklehr I started to work on it so I added the file mod.js

export * as topsort from './index.js';

And then I wanted to test if this work so I import it and got the error

error: Uncaught ReferenceError: module is not defined
module.exports = function(edges) {

There are a couple of options to solve this issue:

  1. Change the code to use the export keyword, not a good option cause this will break some node's version capabilities.
  2. import module from https://deno.land/[email protected]/node (Deno Node compatibility) to support CommonJS (CJS) importing. import big file for small change
  3. Developers that want to use this with Deno will need to use some CDNs that convert node project to browser compatible package (module is not needed). An example of CDN that will work is SkyPack and there are more.

I prefer the 3rd option, which won't change the code and can prevent possible errors (which is critical cause many libraries depend on this) If you want I can update the README with instructions for how to use this library with Deno.

Love to hear what you think

rluvaton avatar Jan 03 '21 19:01 rluvaton