-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Making package compatible with ESM #2534
base: master
Are you sure you want to change the base?
Conversation
f8c9305
to
6720773
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the name exports
is special, this seems like a hack. How about index.mjs and the appropriate package.json exports
field?
The whole The problem with
I feel this is a rather drastic change. When the one I made works and officially supported by node, while stays backwards compatible. Let's not make perfect the enemy of the good. |
6720773
to
9a334eb
Compare
Seems appropriate enough?
and this also seems fine if you want it for pg 8. There are few files and there’s nothing it’ll be necessary to keep in sync after a new major version that shouldn’t be kept in sync. |
Just to be clear. I do not mind doing it as you are asking. I wanted to make it as simple as possible to make it easier to get it merged. If you are saying that I should do the full thing to get it merged, sure. I just do not want to spend super extra time and then this does not get merged (is one of those PRs which can get hard to keep merge-ready if it is not merged soon after it is made). So to make it clear:
|
This would be a nice-to-have for us, is this still able to be merged with a major version bump to pg@8? |
What's preventing this from being merged in? Seems like a simple feature with ergonomic benefits given the shift from |
I can't tell if this contains breaking changes or not. Does this release require a semver major bump? Is there any way to write tests for both |
There's no breaking change here. All it's doing is allowing I just tested the PR locally and it works in both CJS and ESM environments. I think the chance of a regression in this behavior is incredibly small and thus the benefit of an automated test is negligible. |
In recent version of node, node is using cjs-module-lexer to try to detect names of exports in CJS modules. It is doing static analysis so it cannot detect everything. Previously this package was using a constructor which throw things off, but I do not there was much benefit of having that, or am I missing something? I simplified it into a simple function and now node can import it as a ESM module. Tested with node v16.0.0. E.g.: