From 65e402aab792bac83321047d5a6a3f2f21ea3609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arvid=20Torbj=C3=B8rnsen?= Date: Tue, 27 Oct 2026 17:21:53 +0100 Subject: [PATCH] Build the Node package for Node's own ESM loader node/package.json is "type": "module", so Node loads node/dist as ESM, and its loader needs a full path in each relative import. The build used "moduleResolution": "bundler", which let "./database" through without an extension, so importing the package in Node failed with ERR_MODULE_NOT_FOUND. The Node build now compiles with "module" and "moduleResolution" "NodeNext", TypeScript's setting for code Node loads directly, and its relative imports name their ".js" files. The React Native package keeps "bundler" in the root tsconfig, which excludes node/. Fixes #474 Co-Authored-By: Claude Opus 5.5 --- node/src/database.ts | 2 +- node/src/index.ts | 8 ++++---- node/src/test.spec.ts | 2 +- node/tsconfig.json | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/node/src/database.ts b/node/src/database.ts index 972f78d2..3ac5793e 100644 --- a/node/src/database.ts +++ b/node/src/database.ts @@ -13,7 +13,7 @@ import type { SQLBatchTuple, Transaction, UpdateHookOperation, -} from "./types"; +} from "./types.js"; export class NodeDatabase implements DB { private db: Database.Database; diff --git a/node/src/index.ts b/node/src/index.ts index 6743eadf..948100ca 100644 --- a/node/src/index.ts +++ b/node/src/index.ts @@ -1,8 +1,8 @@ import * as path from "node:path"; -import { NodeDatabase } from "./database"; -import type { DB, DBParams, OPSQLiteProxy } from "./types"; +import { NodeDatabase } from "./database.js"; +import type { DB, DBParams, OPSQLiteProxy } from "./types.js"; -export { NodeDatabase as Database } from "./database"; +export { NodeDatabase as Database } from "./database.js"; export type { BatchQueryResult, ColumnMetadata, @@ -16,7 +16,7 @@ export type { SQLBatchTuple, Transaction, UpdateHookOperation, -} from "./types"; +} from "./types.js"; class OPSQLiteProxyImpl implements OPSQLiteProxy { open(options: { diff --git a/node/src/test.spec.ts b/node/src/test.spec.ts index fa406d9a..01dad318 100644 --- a/node/src/test.spec.ts +++ b/node/src/test.spec.ts @@ -1,7 +1,7 @@ import * as fs from "node:fs"; import * as path from "node:path"; import * as os from "node:os"; -import { isIOSEmbedded, isLibsql, isSQLCipher, open } from "./index"; +import { isIOSEmbedded, isLibsql, isSQLCipher, open } from "./index.js"; describe("op-sqlite Node.js tests", () => { let db: ReturnType; diff --git a/node/tsconfig.json b/node/tsconfig.json index a4695d8c..ae09fd4a 100644 --- a/node/tsconfig.json +++ b/node/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "ES2020", - "module": "ESNext", + "module": "NodeNext", "lib": ["ES2020"], "declaration": true, "declarationMap": true, @@ -12,7 +12,7 @@ "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, - "moduleResolution": "bundler", + "moduleResolution": "NodeNext", "allowSyntheticDefaultImports": true, "resolveJsonModule": true, "types": ["node", "jest"]