libsql-client-ts icon indicating copy to clipboard operation
libsql-client-ts copied to clipboard

Fix CJS imports for `@libsql/client`

Open L-Mario564 opened this issue 1 month ago • 1 comments

Addresses #182.

This PR aims to fix CJS imports, something that may be blocking the Drizzle Team from merging https://github.com/drizzle-team/drizzle-orm/pull/4998 due to our CJS import test for drizzle-orm/libsql. We assume this issue is caused by what is described in #182 which is using the same typings for both ESM and CJS.

ATTW was used to verify the new build outputs work in both ESM and CJS.

libsql-core subpackage:

Current

npm run build && npm pack && attw ./[generated package file].tgz
Screenshot_20251114_092458

In this PR

npm ru build && cd dist && npm pack --pack-destination .. && cd .. && attw ./[generated package file].tgz
Screenshot_20251114_094433

libsql-client subpackage:

In this PR

Screenshot_20251114_103915

Changes made

  • Introduce tsup to properly generate .cjs and .d.cts files.
  • Remove unusued imports in libsql-core/src/util.ts.
  • Update publish workflow according to the new output produced by tsup.
  • Remove what seems to be unused prebuild and postbuild scripts in libsql-core and libsql-client.
  • Remove files that are no longer relevant with to tsup (like tsconfig.build-cjs.json).
  • Update @libsql/core in libsql-client. Had to update as there was a type introduced in 0.16.0 and the build wasn't going to work if I kept @libsql/core on 0.15.x.

L-Mario564 avatar Nov 14 '25 19:11 L-Mario564

@penberg Hi there. Let me know if there's anything that needs to be done with this PR for it to be merged. Would greatly appreciate it!

L-Mario564 avatar Nov 17 '25 20:11 L-Mario564