kysely icon indicating copy to clipboard operation
kysely copied to clipboard

add `import` prop @ `FileMigrationProvider`.

Open igalklebanov opened this issue 1 year ago • 2 comments

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.

igalklebanov avatar May 18 '24 23:05 igalklebanov