fix: publish the ESM build of @metamask/mobile-wallet-protocol-core - #85
Open
imaksp wants to merge 2 commits into
Open
fix: publish the ESM build of @metamask/mobile-wallet-protocol-core#85imaksp wants to merge 2 commits into
imaksp wants to merge 2 commits into
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
packages/corebuilds both CJS and ESM (tsup src/index.ts --format cjs,esm --dts --splitting) but its manifest declares onlymain+types, so the publisheddist/index.mjsanddist/index.d.mtsare unreachable and every bundler resolves the CommonJS build. This addsmodule+exports.dapp-clientandwallet-client— same repo, same build script — already declare both fields.coreis 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 areundefined.@metamask/connect-multichaindoes exactly that in#createDappClient(), somwpCore.SessionStore.create(kvstore)throwsundefined is not an objectin 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 apnpm patch.Issue
Reported downstream as MetaMask/connect-monorepo#342, which covers two bugs of the same kind — this change fixes the
mwpCore.SessionStorehalf of it.Checklist
🤖 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-corealways resolving to CommonJS even thoughtsupalready emitsdist/index.mjsanddist/index.d.mts.Adds
moduleand a conditionalexportsmap (ESMimport→.mjs/.d.mts, CJSrequire→.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.