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.
Fixes #305... again again.
The
esm
wrapper (as described in bufbuild/protobuf-es#509) creates problems when using a peer dependency that defines it's exports without an import proxy (in our case, react-query).Current situation
Our exports look like:
The above meant the following:
QueryClientProvider
from@tanstack/react-query
, it resolved to theesm
version of the contextuseQuery
from@tanstack/react-query
, it resolved instead to thecjs
version of the package (since NextJS SSR is considered a "node" environment)This mismatch between the esm and cjs versions causes a problem detecting context
Alternatives considered
We could expose our own hooks/components with a one-to-one mapping from
@tanstack/react-query
and require our ownQueryClientProvider
to be initialized. This would bypass these kinds of issues, but introduce more setup and potential for confusion. It would mean that usingreact-query
for anything non-connect related would require an additional query client provider which MAY actually be the same client depending on where (node/browser) it's running.Reason we chose this solution
By not using an
ESM
wrapper, we avoid these possible import mismatches. It does introduce the possibility of dual package hazard with class instances (where instanceof is used, like with ConnectError) but we don't use any of that in connect-query so we can be relatively safe in that regard.