Skip to content

fix(apollo-client): keep octane namespace tree-shakeable in getApolloContext - #1275

Merged
domgan-oai merged 7 commits into
mainfrom
claude/inspiring-kapitsa-47c91d
Sep 23, 2026
Merged

domgan-oai merged 7 commits into
mainfrom
claude/inspiring-kapitsa-47c91d

Conversation

@trueadm

@trueadm trueadm commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

getApolloContext in @octanejs/apollo-client checked 'createContext' in React against import * as React from 'octane'. An in test on a namespace import forces Vite/rolldown (and esbuild) to materialize the full namespace object (src_exports = __exportAll({...})). That keeps every public octane export alive: generic createRoot/hydrateRoot, the returned-value reconciler, the transition graph and so on. So every app using the binding loses tree-shaking, even when the compiler has specialized its root.

The guard now uses a named createContext import (invariant(typeof createContext === 'function', 37)), marked with a // DEVIATION: comment. The Symbol.for('__APOLLO_CONTEXT__') singleton logic is unchanged.

I audited the other apollo files that use import * as React from 'octane'. None use in or computed-key access, except useSyncExternalStore.js: its React[uSESKey] uses a constant key, and the build shows it already resolves statically.

examples/cinebase production bundle (npx vite build):

min gzip
before 672.72 kB 203.73 kB
after 497.37 kB 151.67 kB (−52.06 kB, −25.6%)

After the fix the unminified build has no __exportAll.

Regression guard

  • New binding-apollo-client scenario in benchmarks/bundle-size/run-minimal.mjs. Its fixture renders ApolloProvider + useApolloClient through a local root, and the bundle runs in jsdom ({ text: 'provided', cleaned: true }). For Vite the scenario asserts that __createVoidRoot stays in the bundle and createRoot does not. It also forbids the unused useQuery/useMutation/useSuspenseQuery modules.
  • With the old in check restored, the scenario fails: devalue, pulled in by the full namespace, trips the generic forbidden-module gate.
  • Budgets are the measured sizes rounded up to 1 KiB. Unrelated runtime commits on main move this scenario by a few hundred bytes, and tighter rounding needed re-measuring after every merge.
  • Per-PR CI previously ran only behavior-root and three budget scenarios. A new shard-1 step runs this scenario without byte budgets, and scripts/ci-workflow.test.mjs pins the step.
  • The benchmark package gains @octanejs/apollo-client, @apollo/client, graphql and rxjs: +12 lockfile lines, all already-locked versions. pnpm sync then refreshed the lockfile hash in every binding's audit/react-parity.json and in the octane-evals manifest.

Validation

  • pnpm format:check (repo-wide)
  • pnpm typecheck (not run repo-wide; pnpm typecheck:files passed; the benchmark fixture isn't in any typecheck project)
  • pnpm test (not run in full)
  • targeted tests:
    • vitest run --project apollo-client: 30/30
    • node --test scripts/ci-workflow.test.mjs: 67/67
    • benchmarks/bundle-size/minimal-gates.test.mjs: 6/6
    • node benchmarks/bundle-size/run-minimal.mjs --budgets binding-apollo-client: pass for Vite and esbuild
    • old code restored: scenario fails as expected
    • pnpm install --frozen-lockfile --offline accepts the lockfile

Risk / follow-ups

  • The bindings-audit report/revalidate flow was not run; this is a single source fix, not an audit.
  • The new CI step adds one Vite + one esbuild build of the Apollo fixture to shard 1.
  • The unminified cinebase build still contains a function hydrateRoot that does not come from Apollo. I didn't investigate it.

Provenance

  • An agent produced this diff (agent-authored)

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Note

Low Risk
Single guarded import change in Apollo context setup with regression bundle tests; no auth or data-path changes.

Overview
getApolloContext no longer uses import * as React from 'octane' with 'createContext' in React. It now imports createContext by name and guards with typeof createContext === 'function', so bundlers do not materialize the full octane namespace and unused public exports (including generic roots) can tree-shake again. The singleton __APOLLO_CONTEXT__ behavior is unchanged.

CI and bundle-size tooling add a binding-apollo-client minimal scenario (Apollo provider + useApolloClient, Vite root-specialization checks, size budgets, reachability probe) and a shard-1 step that runs it without byte budgets. The benchmark workspace picks up Apollo-related deps; lockfile refresh updates audit parity hashes and eval manifests.

Reviewed by Cursor Bugbot for commit 86322c4. Bugbot is set up for automated code reviews on this repo. Configure here.

…Context

`getApolloContext` tested `'createContext' in React` against
`import * as React from 'octane'`. The `in` test forces bundlers to
materialize the whole namespace object, retaining every public octane
export (generic createRoot/hydrateRoot, returned-value reconciler,
transition graph) and undoing compiler root specialization for every app
using the binding. Check a named `createContext` import instead.

examples/cinebase production bundle: 203.73 kB -> 151.67 kB gzip.

Add a binding-apollo-client scenario to the bundle-reachability harness
(executes in jsdom, asserts __createVoidRoot survives and createRoot does
not reach the Vite bundle) and gate it per PR in CI shard 1.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix labels Sep 23, 2026
@github-actions
github-actions Bot marked this pull request as draft September 23, 2026 08:31
@domgan-oai
domgan-oai marked this pull request as ready for review September 23, 2026 09:45
…adroom

Prettier rewraps the fixture's <output> child (lint checks failed on it).
The 64-byte budget rounding was tripped by unrelated runtime growth on
main; round to 256 bytes over the current measurement instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel

vercel Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated
octane-website Skipped Skipped Sep 23, 2026 11:53am UTC
octane-website-mcp Skipped Skipped Sep 23, 2026 11:53am UTC

Request Review

@vercel
vercel Bot temporarily deployed to Preview – octane-website September 23, 2026 11:23 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp September 23, 2026 11:23 Inactive
trueadm and others added 4 commits September 23, 2026 12:27
…tsa-47c91d

# Conflicts:
#	packages/alien-signals/audit/react-parity.json
#	packages/apollo-client/audit/react-parity.json
#	packages/aria/audit/react-parity.json
#	packages/base-ui-utils/audit/react-parity.json
#	packages/base-ui/audit/react-parity.json
#	packages/better-auth/audit/react-parity.json
#	packages/cmdk/audit/react-parity.json
#	packages/colorful/audit/react-parity.json
#	packages/day-picker/audit/react-parity.json
#	packages/dexie/audit/react-parity.json
#	packages/dnd-kit/audit/react-parity.json
#	packages/draggable/audit/react-parity.json
#	packages/drei/audit/react-parity.json
#	packages/dropzone/audit/react-parity.json
#	packages/email/audit/react-parity.json
#	packages/embla-carousel/audit/react-parity.json
#	packages/floating-ui/audit/react-parity.json
#	packages/formisch/audit/react-parity.json
#	packages/gsap/audit/react-parity.json
#	packages/hook-form/audit/react-parity.json
#	packages/i18next/audit/react-parity.json
#	packages/inertia/audit/react-parity.json
#	packages/ink/audit/react-parity.json
#	packages/input-otp/audit/react-parity.json
#	packages/intersection-observer/audit/react-parity.json
#	packages/jotai/audit/react-parity.json
#	packages/lexical/audit/react-parity.json
#	packages/livestore/audit/react-parity.json
#	packages/lucide/audit/react-parity.json
#	packages/mantine-hooks/audit/react-parity.json
#	packages/markdown/audit/react-parity.json
#	packages/mobx/audit/react-parity.json
#	packages/monaco-editor/audit/react-parity.json
#	packages/motion/audit/react-parity.json
#	packages/nuqs/audit/react-parity.json
#	packages/octane-evals/datasets/train/user-apps-v1/manifest.jsonl
#	packages/octane-is/audit/react-parity.json
#	packages/opentui/audit/react-parity.json
#	packages/pdf/audit/react-parity.json
#	packages/phosphor-icons/audit/react-parity.json
#	packages/popper/audit/react-parity.json
#	packages/radix/audit/react-parity.json
#	packages/rainbowkit/audit/react-parity.json
#	packages/react-error-boundary/audit/react-parity.json
#	packages/react-map-gl/audit/react-parity.json
#	packages/recharts/audit/react-parity.json
#	packages/redux-toolkit/audit/react-parity.json
#	packages/redux/audit/react-parity.json
#	packages/remix-router/audit/react-parity.json
#	packages/resizable-panels/audit/react-parity.json
#	packages/rxjs/audit/react-parity.json
#	packages/select/audit/react-parity.json
#	packages/shadcn/audit/react-parity.json
#	packages/solana-kit/audit/react-parity.json
#	packages/sonner/audit/react-parity.json
#	packages/spring/audit/react-parity.json
#	packages/streamdown/audit/react-parity.json
#	packages/styled-components/audit/react-parity.json
#	packages/swr/audit/react-parity.json
#	packages/syntax-highlighter/audit/react-parity.json
#	packages/tanstack-ai/audit/react-parity.json
#	packages/tanstack-devtools/audit/react-parity.json
#	packages/tanstack-form/audit/react-parity.json
#	packages/tanstack-hotkeys/audit/react-parity.json
#	packages/tanstack-pacer/audit/react-parity.json
#	packages/tanstack-query/audit/react-parity.json
#	packages/tanstack-router-ssr-query/audit/react-parity.json
#	packages/tanstack-router/audit/react-parity.json
#	packages/tanstack-store/audit/react-parity.json
#	packages/tanstack-table/audit/react-parity.json
#	packages/tanstack-virtual/audit/react-parity.json
#	packages/testing-library/audit/react-parity.json
#	packages/textarea-autosize/audit/react-parity.json
#	packages/three/audit/react-parity.json
#	packages/tiptap/audit/react-parity.json
#	packages/transition-group/audit/react-parity.json
#	packages/usehooks-ts/audit/react-parity.json
#	packages/valtio/audit/react-parity.json
#	packages/vaul/audit/react-parity.json
#	packages/visx/audit/react-parity.json
#	packages/wagmi/audit/react-parity.json
#	packages/waypoint/audit/react-parity.json
#	packages/window/audit/react-parity.json
#	packages/xstate-store/audit/react-parity.json
#	packages/xstate/audit/react-parity.json
#	packages/xyflow/audit/react-parity.json
#	packages/zag/audit/react-parity.json
#	packages/zustand/audit/react-parity.json
…tsa-47c91d

# Conflicts:
#	packages/alien-signals/audit/react-parity.json
#	packages/apollo-client/audit/react-parity.json
#	packages/aria/audit/react-parity.json
#	packages/base-ui-utils/audit/react-parity.json
#	packages/base-ui/audit/react-parity.json
#	packages/better-auth/audit/react-parity.json
#	packages/cmdk/audit/react-parity.json
#	packages/colorful/audit/react-parity.json
#	packages/day-picker/audit/react-parity.json
#	packages/dexie/audit/react-parity.json
#	packages/dnd-kit/audit/react-parity.json
#	packages/draggable/audit/react-parity.json
#	packages/drei/audit/react-parity.json
#	packages/dropzone/audit/react-parity.json
#	packages/email/audit/react-parity.json
#	packages/embla-carousel/audit/react-parity.json
#	packages/floating-ui/audit/react-parity.json
#	packages/formisch/audit/react-parity.json
#	packages/gsap/audit/react-parity.json
#	packages/hook-form/audit/react-parity.json
#	packages/i18next/audit/react-parity.json
#	packages/inertia/audit/react-parity.json
#	packages/ink/audit/react-parity.json
#	packages/input-otp/audit/react-parity.json
#	packages/intersection-observer/audit/react-parity.json
#	packages/jotai/audit/react-parity.json
#	packages/lexical/audit/react-parity.json
#	packages/livestore/audit/react-parity.json
#	packages/lucide/audit/react-parity.json
#	packages/mantine-hooks/audit/react-parity.json
#	packages/markdown/audit/react-parity.json
#	packages/mobx/audit/react-parity.json
#	packages/monaco-editor/audit/react-parity.json
#	packages/motion/audit/react-parity.json
#	packages/nuqs/audit/react-parity.json
#	packages/octane-evals/datasets/train/user-apps-v1/manifest.jsonl
#	packages/octane-is/audit/react-parity.json
#	packages/opentui/audit/react-parity.json
#	packages/pdf/audit/react-parity.json
#	packages/phosphor-icons/audit/react-parity.json
#	packages/popper/audit/react-parity.json
#	packages/radix/audit/react-parity.json
#	packages/rainbowkit/audit/react-parity.json
#	packages/react-error-boundary/audit/react-parity.json
#	packages/react-map-gl/audit/react-parity.json
#	packages/recharts/audit/react-parity.json
#	packages/redux-toolkit/audit/react-parity.json
#	packages/redux/audit/react-parity.json
#	packages/remix-router/audit/react-parity.json
#	packages/resizable-panels/audit/react-parity.json
#	packages/rxjs/audit/react-parity.json
#	packages/select/audit/react-parity.json
#	packages/shadcn/audit/react-parity.json
#	packages/solana-kit/audit/react-parity.json
#	packages/sonner/audit/react-parity.json
#	packages/spring/audit/react-parity.json
#	packages/streamdown/audit/react-parity.json
#	packages/styled-components/audit/react-parity.json
#	packages/swr/audit/react-parity.json
#	packages/syntax-highlighter/audit/react-parity.json
#	packages/tanstack-ai/audit/react-parity.json
#	packages/tanstack-devtools/audit/react-parity.json
#	packages/tanstack-form/audit/react-parity.json
#	packages/tanstack-hotkeys/audit/react-parity.json
#	packages/tanstack-pacer/audit/react-parity.json
#	packages/tanstack-query/audit/react-parity.json
#	packages/tanstack-router-ssr-query/audit/react-parity.json
#	packages/tanstack-router/audit/react-parity.json
#	packages/tanstack-store/audit/react-parity.json
#	packages/tanstack-table/audit/react-parity.json
#	packages/tanstack-virtual/audit/react-parity.json
#	packages/testing-library/audit/react-parity.json
#	packages/textarea-autosize/audit/react-parity.json
#	packages/three/audit/react-parity.json
#	packages/tiptap/audit/react-parity.json
#	packages/transition-group/audit/react-parity.json
#	packages/usehooks-ts/audit/react-parity.json
#	packages/valtio/audit/react-parity.json
#	packages/vaul/audit/react-parity.json
#	packages/visx/audit/react-parity.json
#	packages/wagmi/audit/react-parity.json
#	packages/waypoint/audit/react-parity.json
#	packages/window/audit/react-parity.json
#	packages/xstate-store/audit/react-parity.json
#	packages/xstate/audit/react-parity.json
#	packages/xyflow/audit/react-parity.json
#	packages/zag/audit/react-parity.json
#	packages/zustand/audit/react-parity.json
Unrelated runtime commits on main keep moving this scenario by a few
hundred bytes; 256-byte rounding needed re-measuring after every merge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vercel
vercel Bot temporarily deployed to Preview – octane-website-mcp September 23, 2026 11:53 Inactive
@vercel
vercel Bot temporarily deployed to Preview – octane-website September 23, 2026 11:53 Inactive
@domgan-oai
domgan-oai merged commit bc7f8d1 into main Sep 23, 2026
29 checks passed
@domgan-oai
domgan-oai deleted the claude/inspiring-kapitsa-47c91d branch September 23, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-authored Diff or issue body substantially produced by an AI agent fix PR: bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants