Skip to content

chore(deps): update kysely-codegen to v0.20.0 - #226

Merged
toiroakr merged 15 commits into
mainfrom
chore/update-kysely-codegen
Nov 12, 2026
Merged

toiroakr merged 15 commits into
mainfrom
chore/update-kysely-codegen

Conversation

@toiroakr

@toiroakr toiroakr commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Updates kysely-codegen to 0.20.0 for kysely-tailordb-codegen. chore(deps): update dependencies and support Kysely 0.29 #225 left it at 0.18.5 because the bundled function.js failed to load with __filename is not defined in ES module scope.
  • Cause: 0.20.0 parses type expressions with the TypeScript compiler API, but declares typescript neither as a dependency nor as a peer dependency. esbuild therefore bundles whichever typescript is installed in this package. TypeScript 6 brings in a 4.6 MB CommonJS bundle that refers to __filename, so function.js cannot load as an ES module. TypeScript 7.0.2 only brings in a small placeholder, which loads but makes the result depend on the installed version.
  • Fix: add typescript to mockPackages in build.js, which already replaces cosmiconfig with an empty module. The only call, extractTypeIdentifiers, is wrapped in try/catch, and its result matters only for custom imports and overrides, which src/function.ts does not pass. Bundling the real compiler instead would make function.js about 4.6 MB larger and still need __filename to be defined. The stub for git-diff is dropped because 0.20.0 no longer uses it.
  • Checked with a mocked column metadata table (arrays, enums, an unknown type, a view and an auto-incrementing column): function.js built with TypeScript 7.0.2 and with 6.0.3 is the same size and generates the same code as with 0.18.5.
  • Checked on a real workspace: a temporary workspace (24h TTL, deleted afterwards) with four TailorDB tables (Category, Comment, Task, User) and a machine user. Running the 0.18.5 and the 0.20.0 function.js with tailor function test-run both succeed and produce the same generated code (1824 bytes). Running node dist/cli.js -a tailordb -n main-db -m admin -o out.ts against that workspace writes the same file, and its --help output and the error for a missing option are the same as before.
  • This PR is stacked on chore(deps): update dependencies and support Kysely 0.29 #225 (its base is that branch), which is stacked on fix(kysely-tailordb): stop depending on the global Tailordb namespace #224. Once fix(kysely-tailordb): stop depending on the global Tailordb namespace #224 and chore(deps): update dependencies and support Kysely 0.29 #225 are merged, change the base to main.

The published declarations referenced `Tailordb.Client`, a global type
namespace that only the deprecated @tailor-platform/function-types
declares. Without that package, consumers that do not skip library
checks got TS2833 (or TS2503 when no ambient types were loaded at all).

Describe the client by the three methods the dialect calls instead.
Both the legacy `Tailordb.Client` and the `tailordb.Client` of
@tailor-platform/sdk are assignable to it, and runtime behavior is
unchanged. The package no longer needs function-types for its own type
check, so drop it from tsconfig and devDependencies, and point the
README at the SDK runtime globals.
…are accepted

Add a type-only test that passes both the legacy `Tailordb.Client` of
@tailor-platform/function-types and the `tailordb.Client` of
@tailor-platform/sdk to TailordbDialect. If either package changes the
shape of its client in a way the dialect cannot accept, type-check now
fails, including when Renovate bumps the SDK.

The test needs the SDK exports map to resolve, so it has its own
tsconfig with bundler module resolution and type-check runs both.
Kysely 0.29 makes `TableMetadata.isForeign` required, so the copy of the
PostgreSQL introspector's `parseTableMetadata` in kysely-tailordb-codegen
no longer type-checks. Fill it in from `table_type`, the way Kysely's own
introspector does (`relkind` `f` is a foreign table), and point the link in
the comment at the 0.29.8 source.
- typescript 5.9.3 -> 6.0.3 (kysely-tailordb, kysely-tailordb-codegen, logger).
  TypeScript 7 is not an option yet: tsup builds the declarations through
  rollup-plugin-dts, which needs the TypeScript compiler API that 7.0 no
  longer provides.
- tsup 8.5.1 -> 9.0.0.
- esbuild 0.28.1 -> 0.28.2.
- @types/node 22.20.5 -> 24.19.2, to match the Node 24 the repository
  declares in engines.
The CLI of kysely-tailordb-codegen only uses `requiredOption`, `opts` and
`error`, and its `--help` output and the error for a missing option are
the same as before. commander 15 requires Node.js 22.12 or later, which is
below the Node 24 the repository declares in engines.

kysely-codegen stays on 0.18.5: bundling 0.20.0 into function.js produces
a file that fails to load with `__filename is not defined in ES module
scope`.
Migrate the biome.json of kysely-tailordb and kysely-tailordb-codegen to
the 2.x schema, keeping the same formatting and lint settings. Two
things differ from 1.9: `vcs.root` has to point at the repository root
for biome to find .gitignore, and `**/*.md` is excluded from the
formatter because 2.x would otherwise start formatting the READMEs.

The two `biome-ignore` comments in kysely-tailordb now carry a reason,
which 2.x requires.
@changesets/cli 2.31.1 -> 3.0.3 and @changesets/changelog-github
0.7.0 -> 1.0.1. `changeset status` reads the existing config and the
pending changesets without changes.
The only dependency whose range moved when updating within the declared
ranges. The CLI of kysely-tailordb-codegen builds and prints the same
`--help` output, and the generated code for a mocked TailorDB client is
the same as before.
The two entries were temporary exceptions for Renovate security updates
to kysely 0.28.17 and esbuild 0.28.1. Neither version is in the
lockfile any more, so the exceptions no longer match anything.
commander 15 requires Node.js 22.12 or later, while 14 runs on Node 20 and
kysely-tailordb-codegen declares no engines. Updating it in a patch release
would silently drop Node 20 for the CLI, so leave it out of this update and
decide the Node floor, or a different CLI library, separately.
Build kysely-tailordb with tsdown 0.23.7. `fixedExtension: false` keeps the
output names as they were (`index.js`, `index.cjs`, `index.d.ts` and
`index.d.cts`), so package.json needs no change to `main`, `module`,
`types` and `exports`.

The ESM and CommonJS builds export the same `TailordbDialect` and run the
same way against a mocked client, and the declarations type-check in the
same three environments as before. TypeScript stays on 6.0.3.
typescript 6.0.3 -> 7.0.2 in kysely-tailordb, kysely-tailordb-codegen and
logger. With tsdown in place of tsup, all three packages build and
type-check on 7.0.2, the declarations of kysely-tailordb still type-check
with and without function-types or the SDK runtime globals, and the CLI
and generated code of kysely-tailordb-codegen are unchanged.

tsdown warns that the tsgo declaration generator for TypeScript 7.0 is
deprecated and will be removed in the next minor, so revisit this when
TypeScript 7.1 is out.
kysely-codegen 0.20 parses type expressions with the TypeScript compiler
API, but it declares typescript neither as a dependency nor as a peer
dependency. When function.js is bundled, esbuild therefore picks up
whichever typescript is installed here. With TypeScript 6 that is a 4.6 MB
CommonJS bundle that refers to `__filename`, so function.js fails to load
with `__filename is not defined in ES module scope`. With TypeScript 7.0.2
only a small placeholder file is bundled, which loads but depends on the
installed version.

The only call, `extractTypeIdentifiers`, is wrapped in try/catch and only
matters for custom imports and overrides, which src/function.ts does not
pass. Replace typescript with an empty module in the same mockPackages
plugin that already stubs git-diff and cosmiconfig, so the bundle no longer
depends on the TypeScript version.

function.js, built with either TypeScript 6.0.3 or 7.0.2, produces the same
generated code as with kysely-codegen 0.18.5, both for a mocked column
metadata table and when run on a workspace with four TailorDB tables.
The CLI prints the same --help and the same missing-option error as before.
git-diff is no longer a dependency of kysely-codegen 0.20 (it uses diff),
so the stub for it in mockPackages matched nothing. Drop it, and say in the
comment that the stubbed typescript only breaks the bundle on 6.x.
@toiroakr
toiroakr marked this pull request as ready for review November 11, 2026 13:50
@toiroakr
toiroakr requested a review from a team as a code owner November 11, 2026 13:50

@jackchuka jackchuka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Base automatically changed from chore/update-dependencies to main November 12, 2026 00:48
@toiroakr
toiroakr merged commit afe745f into main Nov 12, 2026
6 checks passed
@toiroakr
toiroakr deleted the chore/update-kysely-codegen branch November 12, 2026 00:56
@github-actions github-actions Bot mentioned this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants