knex icon indicating copy to clipboard operation
knex copied to clipboard

Deno Module

Open felipefdl opened this issue 4 years ago • 21 comments

Feature discussion / request

I would like to use Knex on Deno (https://deno.land/).

felipefdl avatar May 12 '20 20:05 felipefdl

@felipefdl Are there any solutions for CommonJS and npm dependency support available for Deno already?

kibertoad avatar May 12 '20 20:05 kibertoad

@kibertoad Not sure, probably not. Maybe it's not time to implement yet, but will be great have knex on Deno.

felipefdl avatar May 12 '20 20:05 felipefdl

@felipefdl Definitely. It's not clear what needs to be done for that, as obviously full fork of Knex.js over to Deno is not really feasible or sustainable. What changes in Knex codebase would make it more compatible with Deno without breaking Node.js support?

kibertoad avatar May 12 '20 20:05 kibertoad

The major problem is on import dependencies since Deno doesn't use Commonjs and doesn't use package.json as well. If Knex was written typescript, maybe it can use an alias on imports, but it isn't the case, you can use a trick, creating a file with all dependencies used by the node, and another file with all dependency used by Deno, and import by the platform. I don't know if it is a good design, but it is a point to think about.

felipefdl avatar May 12 '20 20:05 felipefdl

Also, the Deno has (in construction) module to add Node Compatibility. https://deno.land/std/node/

Maybe when it is done, we can run knex without problem.

felipefdl avatar May 12 '20 20:05 felipefdl

Stopping by to lend my support for this request.

shellscape avatar Aug 22 '21 16:08 shellscape

I want this too

craigcosmo avatar Sep 19 '21 19:09 craigcosmo

I want this three

pasha-bolokhov avatar Feb 17 '22 16:02 pasha-bolokhov

I want this four

sunw31 avatar Apr 30 '22 02:04 sunw31

@OlivierCavadenti What do you think about conversion of knex to TS for 3.0?

kibertoad avatar Apr 30 '22 08:04 kibertoad

@OlivierCavadenti What do you think about conversion of knex to TS for 3.0?

Yeah sure its a good candidate, i can take a look of this issue after that

OlivierCavadenti avatar May 01 '22 11:05 OlivierCavadenti

#5144 is a good entry point for that, actually

kibertoad avatar May 01 '22 11:05 kibertoad

Friendly reminder that Deno has different "primitives" (i.e. crypto, network, buffers, etc) than Node.js so presumably the Node.js SQL drivers won't work with it. Especially those that build .node C++ modules. Here's the Deno Postgres driver for reference: https://github.com/denodrivers/postgres

code-ape avatar May 01 '22 12:05 code-ape

Why not use the Deno drivers then?

pasha-bolokhov avatar May 05 '22 17:05 pasha-bolokhov

Ok, I want this now, what is going on here?

vanpipy avatar Aug 30 '22 09:08 vanpipy

Nothing. Feel free to send PRs :D

kibertoad avatar Aug 30 '22 09:08 kibertoad

Nothing. Feel free to send PRs :D

Sadness, I will try but do not promise...:D

vanpipy avatar Aug 30 '22 09:08 vanpipy

I found a way to use the knex without any changed, that is importing the module via an online CDN site like esm.sh, but the question is coming. All of the CDN sites is just giving the module used in the browser environment, this means a module should a cross-platform module always, or the dev needs polyfill the gap to reach the cross-platform goal.

An example, trying to use the knex via Skypack (yep, i tried...), an error throwed as below:

error: Uncaught (in promise) Error: [Package Error] "timers" does not exist. (Imported by "tarn").

Because of the tarn is not a 'cross-platform' module, the timers cannot be found via the CDN. I just think to make every module is a cross-platform or try to polyfill everything is not good idea. Or better?

Anyway, importing module from the CDN is great way and the problem will be solved if the CND can give the module bases different environment.

vanpipy avatar Sep 01 '22 01:09 vanpipy

The Deno 1.25 added npm support, maybe it works, i didn’t try yet.

https://deno.com/blog/v1.25

felipefdl avatar Sep 01 '22 01:09 felipefdl

The Deno 1.25 added npm support, maybe it works, i didn’t try yet.

https://deno.com/blog/v1.25

Thanks, it looks great. I am trying!

vanpipy avatar Sep 01 '22 01:09 vanpipy

Hi, @felipefdl ,

For now, the deno cannot support to use node package fully. Maybe --unstable to stable is the day. Here is the detail.

vanpipy avatar Sep 01 '22 02:09 vanpipy

Run with deno 1.26.1 but failed, has anyone tried it yet?

vanpipy avatar Oct 10 '22 09:10 vanpipy