Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert to ESM #484

Open
gajus opened this issue May 10, 2023 · 4 comments
Open

Convert to ESM #484

gajus opened this issue May 10, 2023 · 4 comments

Comments

@gajus
Copy link
Owner

gajus commented May 10, 2023

Now that ESM is stable, it is time to evaluate converting Slonik to an ESM dependency, just like all Sindre's packages.

Not doing this has also been a blocker from updating several dependencies.

For now, I am starting with lesser known packages, such as Lightship that became ESM since v8 and collecting feedback. However, raising this issue to open a discussion if necessary.

@rkaw92
Copy link

rkaw92 commented Jun 9, 2023

Hi, here's 1 data point that may be in favor of giving it some time: TypeStrong/ts-node#1997

It seems like ts-node is popular and a lot of developers rely on it, so it may be counter-productive to break it now. I share your sentiment about issues with Sindre's excellent packages being ESM only. If it's any help, I was faced with the same issue and decided to stay on CommonJS, even if it means sticking with older utilities for a while.

@gajus
Copy link
Owner Author

gajus commented Jun 11, 2023

For what it is worth, https://github.com/gajus/lightship has been converted to ESM, and we are using it in CommonJS project (it compiles to ESM and CJS). As far as I can tell, it works with no issue.

@rkaw92
Copy link

rkaw92 commented Jun 13, 2023

That's a reassuring success story, thanks. I guess my worry is, if some transitive runtime dependency of slonik is ESM-only, then even if this package itself is somehow built as CJS, an attempt to require() it might fail due to that dependency. Which would effectively "taint" the entire dependency tree... unless I'm missing something.

I'm just one developer and I'd hate to stifle progress - just saying that my experience, at this point in time, has been rather miserable with ESM-only dependencies and ts-node's loader support clashing with recent Node.js (20.x) changes on this front. So, if this isn't very high-priority for you, it may be prudent to wait a bit for tooling support to get better.

@firxworx
Copy link

I think as long as it joint compiles ESM + CJS for the time being (until the rest of the world catches up)

I use nx monorepo (https://github.com/nrwl/nx) and their node generators and ability to generate dependency graph seem stuck a bit on CJS for the next while. In order to have shared libraries between modern front-end react frameworks (e.g. Vite, Astro, etc) and express/fastify/etc backends I build both ESM + CJS.

Its cool to have slonik + related code in libs where they can freely import zod schemas from libs that are mutually shared front-end and back-end and everything Just Works (tm).

Sharing this use-case for consideration while you plan the future of this wonderful library :)

Thanks a lot for your work on slonik and the extremely detailed and thoughtful articles. They are few but they are powerful heavy hitters that I have shared many times!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants