Skip to content

fix(tempo): mark the mppx/client import of gatewayActions optional for webpack - #5437

Merged
jxom merged 1 commit into
mainfrom
claude/gateway-mppx-webpack
Nov 8, 2026
Merged

jxom merged 1 commit into
mainfrom
claude/gateway-mppx-webpack

Conversation

@jxom

@jxom jxom commented Nov 8, 2026

Copy link
Copy Markdown
Member

Problem

viem/tempo re-exports gatewayActions, whose load() holds a literal import('mppx/client'). mppx is an optional peer, so npm i viem does not install it. Webpack builds every module that it does not skip through sideEffects, and fails on the unresolved import. Next.js's webpack build fails even when the app imports only a constant:

// app/page.jsx, Next.js 16.4.5, no mppx
import { Addresses } from 'viem/tempo'

export default function Page() {
  return <p>{Object.keys(Addresses).length}</p>
}
npx next build --webpack
# ./node_modules/viem/_esm/tempo/GatewayDecorator.js
# Module not found: Can't resolve 'mppx/client'

Plain webpack 5.112.2 fails the same way with optimization.sideEffects: false. Next.js 15 and earlier build with webpack by default. Turbopack, Rolldown, and Vite build it.

Change

load() wraps the import in try, and its catch throws the existing Gateway.MppxNotInstalledError, which pay() threw before. Webpack treats an import() inside try as optional: a missing module becomes a warning, and the import rejects at runtime. The specifier stays literal, so each bundler still bundles mppx when the app installs it. The runtime behavior of gatewayActions does not change.

Alternatives considered:

  • A computed specifier or /* webpackIgnore: true */ hides mppx from bundlers, so a browser app with mppx installed could no longer pay.
  • A loader that the app passes to gatewayActions changes the API.

Validation

With a packed build of this branch and no mppx:

Build Before After
Next.js 16.4.5, the page above, next build --webpack fails builds, with a Can't resolve 'mppx/client' warning
Next.js app with accounts (Tempo ID SDK), next build --webpack fails builds, and the page runs
Same app, Turbopack builds builds
Plain webpack with mppx installed bundles mppx bundles mppx (1.5 MB of lazy chunks against 8 KB without it)

pnpm build and pnpm check pass. The Gateway tests did not run locally, since the test chain needs IPv6. gatewayActions > behavior: pays with the client account covers the load with mppx installed.

No test fails without this change. environments/next resolves Viem's mppx peer from the workspace root's dev dependency, so a webpack build there passes either way. A regression check needs a webpack build where mppx is absent. Direction on where such a check belongs is welcome.


Generated by Claude Code

@changeset-bot

changeset-bot Bot commented Nov 8, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5f21760

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

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

@vercel

vercel Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
viem Error Error Nov 8, 2026 12:51am UTC

Request Review

@jxom
jxom marked this pull request as ready for review November 8, 2026 01:02
@jxom
jxom merged commit 7bfee15 into main Nov 8, 2026
48 of 51 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-08T01:03:27.362582Z 5f21760 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

This branch had an error being deployed

1 failed deployment
Preview — 5f21760f Deployed Nov 8, 2026 by vercel[bot]
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.

2 participants