Open imathews opened 1 month ago
I would be happy to do so, if only I knew how to do this. That is, I can probably figure it out (as I've done in the past for some other projects), but I always find it such a frustratingly confusing part of the whole NodeJS ecosystem that I'd rather not touch it with even a ten-foot pole :)
If you're willing to implement this ESM build, then I'm always open for a pull request.
What are your thoughts on making this package ESM-only (as opposed to dual CJS / ESM)? Given that this is a fairly new library (and pre 1.0) it might be a reasonable breaking change to make, and maybe better to do it earlier on. I do see that all the examples use ESM.
Moving to ESM-only should only involve tweaking a few lines in the .tsconfig + package.json. Dual bundles are definitely possible, but a bit more to maintain and manage.
The ESM-only approach will cause issues for those using CJS in node, as you can no longer require('sql-parser-cst')
(instead, need to do import('sql-parser-cst').then()
. Though it looks like this will no longer be an issue in Node 23, with backports to v22 and maybe v20: https://github.com/nodejs/node/pull/55085. It could make sense to wait until these backports land...
My personal motivation here is to enable tree-shaking in the browser, which isn't possible with the current build.
I would be fine with making it ESM-only. Personally for me, the only use case of this library is within prettier-plugin-sql-cst. As long as that one keeps working (I'm OK with also doing changes there to adopt this switch), I'm fine with a breaking change.
Sounds good. I'll try to put together a PR for you to look at shortly
Would it be possible to provide an ESM build of this library, to allow for better integration with more modern bundling tools + browsers?