Skip to content

refactor(core): split client into base config and extended client#2906

Closed
matthewvolk wants to merge 1 commit intocanaryfrom
CATALYST-1808-base-client
Closed

refactor(core): split client into base config and extended client#2906
matthewvolk wants to merge 1 commit intocanaryfrom
CATALYST-1808-base-client

Conversation

@matthewvolk
Copy link
Contributor

@matthewvolk matthewvolk commented Mar 3, 2026

Summary

  • Extracts shared BigCommerce client configuration into a new framework-agnostic core/client/base.ts module
  • Updates core/next.config.ts to import baseClient from ./client/base instead of client from the barrel ./client
  • Updates core/client/index.ts to spread baseClientConfig instead of duplicating config fields

Motivation

In Next.js 16, core/client/index.ts statically imports next/headers, next/navigation, and next-intl/server. When next.config.ts imports this module, those imports poison the process-wide AsyncLocalStorage context, causing "workUnitAsyncStorage" invariant errors at runtime.

This is Approach B from CATALYST-1808. Compared to the dynamic-imports approach in PR #2905 (Approach A), this approach:

  • Avoids runtime overhead of dynamic import() on every request
  • Keeps all Next.js-dependent hooks in index.ts exactly as-is
  • Is a smaller, more surgical change (new file + two edits)

Test plan

  • pnpm tsc --noEmit in core/ — no new type errors
  • pnpm build — Next.js config resolution works without AsyncLocalStorage errors
  • Grep confirms next.config.ts no longer imports from ./client barrel
  • All 30+ consumer files importing from ~/client continue working unchanged

Extract shared client configuration into a framework-agnostic `base.ts`
module so `next.config.ts` no longer transitively imports `next/headers`,
`next/navigation`, or `next-intl/server`. This prevents AsyncLocalStorage
poisoning during config resolution in Next.js 16.
@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2026

⚠️ No Changeset found

Latest commit: 9a80d1d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Mar 3, 2026

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

Project Deployment Actions Updated (UTC)
catalyst Building Building Preview, Comment Mar 3, 2026 6:40pm

Request Review

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2026

Bundle Size Report

Comparing against baseline from 8b5fee6 (2026-03-03).

No bundle size changes detected.

@matthewvolk
Copy link
Contributor Author

Closing in favor of #2905

@matthewvolk matthewvolk closed this Mar 4, 2026
@matthewvolk matthewvolk deleted the CATALYST-1808-base-client branch March 4, 2026 20:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant