fix: resolve workspace MetaMask packages from the monorepo root - #167
Draft
ulissesferreira wants to merge 7 commits into
Draft
fix: resolve workspace MetaMask packages from the monorepo root#167ulissesferreira wants to merge 7 commits into
ulissesferreira wants to merge 7 commits into
Conversation
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>
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.
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-localbaseUrlreinterpreted those inherited paths against the wrong directory.This change resolves workspace packages from the monorepo root and leaves published packages on
node_modules:@metamask/*to./packages/*/src. A local candidate is used only when thatsrcdirectory exists; otherwise resolution continues to the installed package.*, so@metamask/snap-networks-utils/*has an explicit subpath mapping for extra entry points such as/logger.tsconfig.snaps.jsonwithcomposite: falseso they can typecheck sibling workspace source without project-reference build artifacts.baseUrlunless they also re-declare those paths. Solana keepsbaseUrlforsrc/...imports and restates the mappings relative to it.Loggernow assigns optionalprefixanddecoratorsonly 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