kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
9.82k stars 250 forks source link

add `import` prop @ `FileMigrationProvider`. #994

Open igalklebanov opened 1 month ago

igalklebanov commented 1 month ago

Hey :wave:

This PR allows passing an optional custom import function @ FileMigrationProvider. e.g. this would allow consumers to pass a function that uses tsImport by tsx to import TS files without the need to precompile them when using Node.js or a similar JavaScript runtime that doesn't have built-in TS file support.

Also adds onDiscarded optional prop, so external tooling can warn users about files that were ignored by the migration provider.

Also extracts file extension check to a protected method - can be overridden to only support TS files by an extending class. Also adds cjs & cts support.

These changes were inspired by https://github.com/kysely-org/kysely-ctl/blob/main/src/kysely/ts-file-migration-provider.mts , a custom provider implementation in kysely-ctl that only works with TS migration files, on all runtimes.

vercel[bot] commented 1 month ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
kysely ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 18, 2024 10:04am