Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deno support? #504

Open
Nezteb opened this issue Sep 12, 2023 · 0 comments
Open

Deno support? #504

Nezteb opened this issue Sep 12, 2023 · 0 comments

Comments

@Nezteb
Copy link

Nezteb commented Sep 12, 2023

Desired Behavior

I have a simple test script in a Deno environment:

import {
  createPool,
  type DatabaseConnection,
} from "slonik";

async function run() {
  const connectionString = Deno.env.get("DB_URL") ?? "";

  const pool = await createPool(connectionString);

  return pool.connect(async (connection: DatabaseConnection) => {
    const result = await connection.one(sql.unsafe`SELECT 1 as id`);
    console.log(result);
    return result;
  });
}

run();

Though, instead of from "slonik", I have to use a URL: https://deno.land/[email protected]/basics/modules

I tried using a couple CDNs that will supposedly convert CommonJS code to ESM for you to no avail:

  • https://esm.sh/
    • https://esm.sh/slonik
      error: Uncaught Error: Could not find module root given file: "https://www.esm.sh/v132/[email protected]/deno/bindings.mjs". Do you have a `package.json` file?
      
  • https://www.skypack.dev/
    • https://cdn.skypack.dev/slonik
      error: Module not found "https://deno.land/std/node/crypto.ts".
      at https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/pg.js:2:8
      

Motivation

Knex has a couple similar issues:

Implementation

Some notes on migrating from Node to Deno: https://deno.land/[email protected]/node/migrate

Requires #484 to be done. A tool like https://github.com/garronej/denoify might be usable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant