Skip to content

fix: publish the ESM build of @metamask/mobile-wallet-protocol-core - #85

Open
imaksp wants to merge 2 commits into
MetaMask:mainfrom
imaksp:fix/core-esm-exports
Open

fix: publish the ESM build of @metamask/mobile-wallet-protocol-core#85
imaksp wants to merge 2 commits into
MetaMask:mainfrom
imaksp:fix/core-esm-exports

Conversation

@imaksp

@imaksp imaksp commented Jul 28, 2026

Copy link
Copy Markdown

Description

  • FIXED:
    • packages/core builds both CJS and ESM (tsup src/index.ts --format cjs,esm --dts --splitting) but its manifest declares only main + types, so the published dist/index.mjs and dist/index.d.mts are unreachable and every bundler resolves the CommonJS build. This adds module + exports.

dapp-client and wallet-client — same repo, same build script — already declare both fields. core is the only package without them, so this copies their block verbatim.

Why it matters

Resolved as CJS, await import('@metamask/mobile-wallet-protocol-core') gives esbuild-based bundlers a namespace whose named members are undefined. @metamask/connect-multichain does exactly that in #createDappClient(), so mwpCore.SessionStore.create(kvstore) throws undefined is not an object in any browser build of MetaMask Connect — reproduced on Angular 22 / esbuild, where connecting via the MWP QR flow fails outright. We currently ship this change as a pnpm patch.

Issue

Reported downstream as MetaMask/connect-monorepo#342, which covers two bugs of the same kind — this change fixes the mwpCore.SessionStore half of it.

Checklist

  • Tests are included if applicable — manifest-only change, no test surface
  • Any added code is fully documented

🤖 Generated with Claude Code


Note

Low Risk
Manifest-only change with no runtime code edits; aligns core with sibling packages and fixes incorrect module resolution for ESM consumers.

Overview
Fixes @metamask/mobile-wallet-protocol-core always resolving to CommonJS even though tsup already emits dist/index.mjs and dist/index.d.mts.

Adds module and a conditional exports map (ESM import.mjs / .d.mts, CJS require.js / .d.ts), matching the other packages in this repo. The changelog records the fix under Unreleased → Fixed.

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

Akash P and others added 2 commits July 28, 2026 13:26
`packages/core` builds both CJS and ESM but declares only `main` and
`types`, so the published `dist/index.mjs` and `dist/index.d.mts` are
unreachable and every bundler resolves the CommonJS build.

Add `module` and `exports`, mirroring the block `dapp-client` and
`wallet-client` already carry.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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