You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
src/kysely/index.js uses CommonJS require('kysely'), which fails at runtime against kysely 0.29.x (now ESM-only / async) on Bun, and is also incompatible with Node.js require(esm) for async modules.
This is distinct from #29 / #30, which address TypeScript type resolution. This issue is about the JavaScript runtime crash.
Environment
pgvector: 0.2.1
kysely: 0.29.0+ (was dual CJS/ESM until 0.28.x; became "type": "module" and ESM-only in 0.29.0)
Bun: 1.3.14 (also reproducible on Node.js 22+ with NodeNext when kysely is treated as an async module)
TypeError: require() async module "/.../node_modules/kysely/dist/index.js" is unsupported. use "await import()" instead.
at <anonymous> (/.../node_modules/pgvector/src/kysely/index.js:1:9)
Root cause
node_modules/pgvector/src/kysely/index.js line 1:
const{ sql }=require('kysely');
kysely 0.29.x is ESM-only ("type": "module") and contains top-level await, making it an async ESM module. Bun (and Node.js ≥22 in some configurations) refuses to load async ESM via CommonJS require().
This crashes the host process as soon as pgvector/kysely is loaded.
#30 adds an index.d.mts for TypeScript type resolution under NodeNext.
It does not touch src/kysely/index.js, so the runtime require('kysely') call still happens and still fails.
Possible fixes
Convert src/kysely/index.js to ESM (import { sql } from 'kysely') — breaks CommonJS consumers using require('pgvector/kysely').
Dual build the /kysely subpath — ship dist/kysely/index.cjs and dist/kysely/index.mjs, wire them via the exports["./kysely"]require / import conditions.
Same approach as the (closed) feat: Add ESM support with dual-module setup #6.
Drop the /kysely helper and document the one-liner — toSql and the distance helpers are short enough (sql\${col} <-> ${toSql(value)}``) that consumers can inline them; that's what we did downstream as a workaround.
Workaround for affected users
The only function we used from pgvector/kysely was toSql, which is trivially:
Summary
src/kysely/index.jsuses CommonJSrequire('kysely'), which fails at runtime against kysely 0.29.x (now ESM-only / async) on Bun, and is also incompatible with Node.jsrequire(esm)for async modules.This is distinct from #29 / #30, which address TypeScript type resolution. This issue is about the JavaScript runtime crash.
Environment
"type": "module"and ESM-only in 0.29.0)Reproduction
Actual error
Root cause
node_modules/pgvector/src/kysely/index.jsline 1:kysely 0.29.x is ESM-only (
"type": "module") and contains top-levelawait, making it an async ESM module. Bun (and Node.js ≥22 in some configurations) refuses to load async ESM via CommonJSrequire().This crashes the host process as soon as
pgvector/kyselyis loaded.Why PR #30 does not fix this
#30 adds an
index.d.mtsfor TypeScript type resolution under NodeNext.It does not touch
src/kysely/index.js, so the runtimerequire('kysely')call still happens and still fails.Possible fixes
src/kysely/index.jsto ESM (import { sql } from 'kysely') — breaks CommonJS consumers usingrequire('pgvector/kysely')./kyselysubpath — shipdist/kysely/index.cjsanddist/kysely/index.mjs, wire them via theexports["./kysely"]require/importconditions.Same approach as the (closed) feat: Add ESM support with dual-module setup #6.
/kyselyhelper and document the one-liner —toSqland the distance helpers are short enough (sql\${col} <-> ${toSql(value)}``) that consumers can inline them; that's what we did downstream as a workaround.Workaround for affected users
The only function we used from
pgvector/kyselywastoSql, which is trivially:We inlined this and dropped the
pgvectordependency entirely.