libsql icon indicating copy to clipboard operation
libsql copied to clipboard

Update default export for deno?

Open davesteinberg opened this issue 4 months ago • 0 comments

Deno 2 seems to fully support libsql's node client. Would it make sense to update the . export for deno so users get the node client by default?

Or is the intent that Deno users should explicitly import from @libsql/client/node if that's what they want?

I've encountered a problem with Drizzle, which is that it does the import for you, and it just imports from @libsql/client. It doesn't provide any mechanism to request the node or web client specifically. So using a file: DB URL simply does not work with Drizzle on Deno.

It definitely seems like a problem, but it's not clear to me where it should be fixed. So, I've asked about it over there, and now I'm asking here, as well.

Another possible solution could be for the user to specify a custom condition, though Deno doesn't support that yet. Even if/when it does, I think libsql's exports would have to be defined differently for that to work, since currently there's no higher-priority condition than deno you could specify that would give you the node client. I suppose something as simple as this could work?

    "exports": {
        ".": {
            "types": "./lib-esm/node.d.ts",
            "import": {
                "web": "./lib-esm/web.js",
                "node": "./lib-esm/node.js",
                "default": "./lib-esm/web.js"
            },
            "require": "./lib-cjs/node.js"
        },

I believe this would give you the same default on all runtimes, but you could specify "web" on Node or specify "node" elsewhere to get the non-default option.

davesteinberg avatar Oct 15 '24 13:10 davesteinberg