JasonShin / sqlx-ts

node.js compile-time SQL validations & type generations
https://jasonshin.github.io/sqlx-ts/
MIT License
176 stars 6 forks source link

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

Open JulianCataldo opened 3 months ago

JulianCataldo commented 3 months ago

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

JasonShin commented 3 months ago

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)

JulianCataldo commented 3 months ago

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.