-
Notifications
You must be signed in to change notification settings - Fork 14
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
Ts esm commonjs support #17
Ts esm commonjs support #17
Conversation
Apologies by the way for the large diff, I had to switch linters and figured I'd add formatting while I was at it. To summarize the necessary portions of the changes:
A few things I didn't touch:
|
Thanks - but I'd rather not. This is a server-only module. I will rewrite it as ESM at some point but I do not really see any reason to increasing bundle size to have both formats exported (since one can I admit those are personal preferences. Goes without saying you are most welcome to use your fork. |
Smart to close, there required an entry-point extension fix required to properly release. If you change your mind I'll reopen |
(PSA) On the topic of ESM/CJS, projects do exist where once you convert to ESM, CJS projects will break and be locked into a lower major version of your package. It's unfortunate, but does exist see Chalk's decision to support common.js then ESM. All CJS projects using TypeScript broke (this was thousands of open source/production repos) and were locked on a major version below the latest release for about 3 years. |
Yup. That's why I'd wait for Node 24 LTS supporting sync ESM require without experimental flag. |
Hey there! I came across this repo and thought it could save a me a little time in spinning up a solution of my own. I noticed that the code is common.js now living in a mostly es-modules/typescript world. I took a sec to setup build compatibility for all three formats and figured I'd PR it if you're interested.
When making a release to
npm
, callingyarn build
will compile separate builds fores-module
,common-js
, andtypescript
projects. The distribution of the correct build to the correct project is handled through the project'spackage.json
which now contains the following:You'll notice in the "files" declaration, I'm now serving both the generated
dist
directory as well as the source files.