sqlx-ts icon indicating copy to clipboard operation
sqlx-ts copied to clipboard

Support for arbitrary/more extensions (`.mts`, `.cts`, `.mjs`,…)

Open JulianCataldo opened this issue 1 year ago • 3 comments

Hey, I love this project, thanks for your hard work!

I wonder if it's possible to add any kind extensions to the CLI, like you could with Prettier or ESLint. Actually, it's only for .js or .ts`, meaning you can't use some files in a lot of projects.

At least, standard extensions : ctsx, cjsx, js, ts, mts, cts, mjs, cjs (I hope I haven't forgot one 😅) would be awesome.

Bye

JulianCataldo avatar Jun 17 '24 17:06 JulianCataldo

Thanks for the idea, this is interesting

I can potentially extend https://github.com/JasonShin/sqlx-ts/blob/953ee1c47da9c9e113e0c4dbeba45d411b5c6f93/src/common/cli.rs#L28C9-L28C12 to support the additional JS types.

jsx/tsx is a tricky one because that requires a whole lot of work in the parser to grab sql string literals - (maybe or maybe not)

JasonShin avatar Jun 18 '24 04:06 JasonShin

No worries for the JSX/TSX part. I think that, conceptually, this is not the typical place where you should put sql queries ;) I think most dev will agree, even more if it add difficulty for dev/maintenance.

I tried sqlx-ts with ESM and CommonJS, and excluding the file extension issue, it went smoothly.

JulianCataldo avatar Jun 18 '24 18:06 JulianCataldo

I will assign this task to @AnantSutar

We will support tjs, mjs, cjs

What needs to be done

Support tjs, mjs, and cjs in the codebase

JasonShin avatar Mar 16 '25 00:03 JasonShin

Fixed https://github.com/JasonShin/sqlx-ts/releases/tag/v0.31.0

JasonShin avatar Nov 22 '25 03:11 JasonShin