-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Closed
Copy link
Description
Issue Description
Current Behavior
Getting TypeError: equal is not a function error when using Apollo Client 4.0.3 with @wry/equality version 0.5.7 during SSR (Server-Side Rendering).
Error Stack Trace
TypeError: equal is not a function
at maskFragment (file:///path/to/node_modules/@apollo/client/masking/maskFragment.js:23:9)
at QueryManager.maskFragment (file:///path/to/node_modules/@apollo/client/core/QueryManager.js:948:13)
at file:///path/to/node_modules/@apollo/client/react/hooks/useFragment.js:54:48
at Object.useMemo (/path/to/node_modules/react-dom/cjs/react-dom-server.node.development.js:3903:20)
at process.env.NODE_ENV.exports.useMemo (/path/to/node_modules/react/cjs/react.development.js:1209:34)
at useFragment_ (file:///path/to/node_modules/@apollo/client/react/hooks/useFragment.js:33:24)
at useFragment (file:///path/to/node_modules/@apollo/client/react/hooks/useFragment.js:17:51)
Root Cause Analysis
The issue is in /masking/maskFragment.js which uses:
import equal from "@wry/equality";However, @wry/equality 0.5.7 has a build bug where the ESM version (lib/index.js) is missing the default export:
ESM version (lib/index.js) - BROKEN:
export function equal(a, b) { ... }
// Missing: export default equal;CommonJS version (lib/bundle.cjs) - WORKS:
exports.equal = equal;
exports.default = equal; // ← This existsWorkaround
Temporarily fix by changing the import in maskFragment.js:
// Change from:
import equal from "@wry/equality";
// To:
import { equal } from "@wry/equality";Link to Reproduction
https://
Reproduction Steps
- Install Apollo Client 4.0.3
- Use useFragment hook in SSR context with ESM modules
- Error occurs because import equal from "@wry/equality" returns undefined in ESM
@apollo/client version
4.0.3
Metadata
Metadata
Assignees
Labels
No labels