From c6c9abdd0424c32649defb6903047a272b5da28c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C5=A0pa=C4=8Dek?= Date: Mon, 28 Aug 2023 10:09:43 +0200 Subject: [PATCH] Rename index.ts to node.ts and add ./node import --- CHANGELOG.md | 1 + README.md | 7 +------ package.json | 17 ++++++++++++----- src/__tests__/client.test.ts | 4 ++-- src/__tests__/helpers.ts | 2 +- src/{index.ts => node.ts} | 0 6 files changed, 17 insertions(+), 14 deletions(-) rename src/{index.ts => node.ts} (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5f86939..0192535 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Updated `@libsql/hrana-client` to version 0.5.0, which implements Hrana 3 - Dropped workarounds for broken WebSocket support in Miniflare 2 +- Added a `@libsql/client/node` import for explicit Node.js-specific module ## 0.3.1 -- 2023-07-20 diff --git a/README.md b/README.md index d4a7ba7..21b5994 100644 --- a/README.md +++ b/README.md @@ -30,18 +30,13 @@ For environments that don't have a local filesystem, but support HTTP or WebSock - Browsers - CloudFlare Workers +- Vercel Edge Functions - Netlify Edge Functions ```typescript import { createClient } from "@libsql/client/web"; ``` -For environments that only support HTTP, including Vercel Edge Functions: - -```typescript -import { createClient } from "@libsql/client/http"; -``` - For Deno: ```typescript diff --git a/package.json b/package.json index 4352952..1a358c7 100644 --- a/package.json +++ b/package.json @@ -23,19 +23,25 @@ "license": "MIT", "type": "module", - "main": "lib-cjs/index.js", - "types": "lib-esm/index.d.ts", + "main": "lib-cjs/node.js", + "types": "lib-esm/node.d.ts", "exports": { ".": { - "types": "./lib-esm/index.d.ts", + "types": "./lib-esm/node.d.ts", "import": { "workerd": "./lib-esm/web.js", "deno": "./lib-esm/web.js", "edge-light": "./lib-esm/web.js", "netlify": "./lib-esm/web.js", - "default": "./lib-esm/index.js" + "node": "./lib-esm/node.js", + "default": "./lib-esm/node.js" }, - "require": "./lib-cjs/index.js" + "require": "./lib-cjs/node.js" + }, + "./node": { + "types": "./lib-esm/node.d.ts", + "import": "./lib-esm/node.js", + "require": "./lib-cjs/node.js" }, "./http": { "types": "./lib-esm/http.d.ts", @@ -60,6 +66,7 @@ }, "typesVersions": { "*": { + ".": ["./lib-esm/node.d.ts"], "http": ["./lib-esm/http.d.ts"], "hrana": ["./lib-esm/hrana.d.ts"], "sqlite3": ["./lib-esm/sqlite3.d.ts"], diff --git a/src/__tests__/client.test.ts b/src/__tests__/client.test.ts index 531bf82..d73d793 100644 --- a/src/__tests__/client.test.ts +++ b/src/__tests__/client.test.ts @@ -7,8 +7,8 @@ import { fetch } from "@libsql/hrana-client"; import "./helpers.js"; -import type * as libsql from ".."; -import { createClient } from ".."; +import type * as libsql from "../node.js"; +import { createClient } from "../node.js"; const config = { url: process.env.URL ?? "ws://localhost:8080", diff --git a/src/__tests__/helpers.ts b/src/__tests__/helpers.ts index d0513b1..c48d019 100644 --- a/src/__tests__/helpers.ts +++ b/src/__tests__/helpers.ts @@ -1,7 +1,7 @@ import { expect } from "@jest/globals"; import type { MatcherFunction } from "expect"; -import { LibsqlError } from ".."; +import { LibsqlError } from "../node.js"; const toBeLibsqlError: MatcherFunction<[code?: string, message?: RegExp]> = function (actual, code?, messageRe?) { diff --git a/src/index.ts b/src/node.ts similarity index 100% rename from src/index.ts rename to src/node.ts