Skip to content

fix: resolve workspace MetaMask packages from the monorepo root - #167

Draft
ulissesferreira wants to merge 7 commits into
mainfrom
ulissesferreira/fix-typescript-package-resolution-5832
Draft

fix: resolve workspace MetaMask packages from the monorepo root#167
ulissesferreira wants to merge 7 commits into
mainfrom
ulissesferreira/fix-typescript-package-resolution-5832

Conversation

@ulissesferreira

@ulissesferreira ulissesferreira commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Explanation

The shared TypeScript config mapped every @metamask/* import to ../*/src. That assumed every scoped package lived in a sibling directory of the consumer. Published @metamask/* dependencies do not, and a package-local baseUrl reinterpreted those inherited paths against the wrong directory.

This change resolves workspace packages from the monorepo root and leaves published packages on node_modules:

  • TypeScript maps @metamask/* to ./packages/*/src. A local candidate is used only when that src directory exists; otherwise resolution continues to the installed package.
  • TypeScript path patterns allow only one *, so @metamask/snap-networks-utils/* has an explicit subpath mapping for extra entry points such as /logger.
  • Snap packages extend tsconfig.snaps.json with composite: false so they can typecheck sibling workspace source without project-reference build artifacts.
  • Snap configs do not set baseUrl unless they also re-declare those paths. Solana keeps baseUrl for src/... imports and restates the mappings relative to it.
  • Jest uses the same local-source-then-installed-package rule.

Logger now assigns optional prefix and decorators only when they are provided, so Solana (exactOptionalPropertyTypes) can typecheck against workspace source.

Adding a workspace package does not require an allowlist change for package-root imports. Importing a published @metamask/* package that is not in this repo continues to use the installed types.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them
Open in Web Open in Cursor 

cursoragent and others added 7 commits August 18, 2026 23:24
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
…ypescript-package-resolution-5832

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
Map @metamask/* imports to packages/*/src (including subpaths) from the
repository root, disable composite for Snap configs so they can consume
sibling source, and fall back to node_modules when no local package exists.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
TypeScript path patterns allow only one star, so keep the root wildcard
for package-root imports and add an explicit mapping for
@metamask/snap-networks-utils subpaths. Assign optional Logger fields
without writing undefined so Snap consumers with exactOptionalPropertyTypes
can typecheck against local source.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
Remove the TypeScript resolution plan and design notes from the
branch, document the consumer-facing package changes, and update
snap manifest shasums to match the CI build.

Co-authored-by: Ulisses Ferreira <ulisses@hey.com>
@cursor cursor Bot changed the title fix: resolve only selected MetaMask packages locally fix: resolve workspace MetaMask packages from the monorepo root Aug 18, 2026
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