Repository navigation
fix(pg-protocol): ship the ESM entry as esm/index.mjs - #3807
Open
WolfieLeader wants to merge 1 commit into
Open
WolfieLeader wants to merge 1 commit into
WolfieLeader wants to merge 1 commit into
Conversation
pg-protocol is the only package from brianc#3423 whose ESM wrapper is a .js file in a package without "type": "module". Node loads it as ESM only through module syntax detection. Without detection (Node 18, or --no-experimental-detect-module), `import { parse } from 'pg-protocol'` fails with "Named export 'parse' not found". Rename it to esm/index.mjs, like pg, pg-pool, pg-cursor and the other packages.
WolfieLeader
marked this pull request as ready for review
October 6, 2026 14:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
pg-protocol is the only package from #3423 whose ESM wrapper is a
.jsfile in a package without"type": "module". The other packages useesm/index.mjs. Node loads the wrapper as ESM only through module syntax detection. Without detection, a named import fails:That happens by default on Node 18, and on any version with
--no-experimental-detect-module.Change: rename
packages/pg-protocol/esm/index.jstoesm/index.mjs(same content) and pointexports["."].importat it."files"already ships/esm.Test:
packages/pg-esm-test/pg-protocol.test.jsimportspg-protocolin a child Node process with detection off.Full
pg-esm-testsuite on Node 26: 37 pass.pg-protocolmocha suite: 78 passing.When the package's real path is outside
node_modules(a workspace link, for example), Node 26 also prints aMODULE_TYPELESS_PACKAGE_JSONwarning for the old file. The.mjsname removes it.Related to #3700, but this does not fix it. That failure comes from @cloudflare/vitest-plugin resolving
require()with theimportcondition (cloudflare/workers-sdk#12984).Risk: a deep import of
pg-protocol/esm/index.jsbreaks.exportsnever exposed./esm/*, so that path was not importable throughexports.