Fix publish-preview to target only workspaces when adding resolutions - #290
Merged
Merged
Conversation
When the `publish-preview` action runs for a monorepo, before it renames all packages to use the preview NPM scope, it adds resolutions for each package to ensure that imports and references to internal dependencies still work. For example, if `@metamask/accounts-controller` is present in the monorepo, before it is renamed to `@metamask-previews/accounts-controller`, a resolution `"@metamask/accounts-controller": "portal:./path/to/accounts-controller"` will be added. However, this resolution is too broad. If an external dependency relies on a different version of a package that exists in the monorepo, then it will be force-resolved to the version of that package in the monorepo instead of the old version. This can cause type errors in the later step of the `publish-preview` workflow that builds the monorepo, because it subverts an assumption that the code is making. To fix this problem, this commit narrows each added resolution to the version of the corresponding monorepo package it is attempting to target.
mcmire
marked this pull request as ready for review
September 11, 2026 20:29
cryptodev-2s
approved these changes
Sep 11, 2026
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.
When the
publish-previewaction runs for a monorepo, before it renames all packages to use the preview NPM scope, it adds resolutions for each package to ensure that imports and references to internal dependencies still work. For example, if@metamask/accounts-controlleris present in the monorepo, before it is renamed to@metamask-previews/accounts-controller, a resolution"@metamask/accounts-controller": "portal:./path/to/accounts-controller"will be added.However, this resolution is too broad. If an external dependency relies on a different version of a package that exists in the monorepo, then it will be force-resolved to the version of that package in the monorepo instead of the old version. This can cause type errors in the later step of the
publish-previewworkflow that builds the monorepo, because it subverts an assumption that the code is making.To fix this problem, this commit narrows each added resolution to the version of the corresponding monorepo package it is attempting to target.
References
corePR. The controller that fails is unrelated to the changes made in the PR.Manual testing
To reproduce the build failure above:
yarn build -f. You should see a build error forkeyring-controller.To test the change introduced in this PR:
yarn build -f. You should not see any build errors.Note
Low Risk
CI-only change to Yarn resolution keys in the preview publish workflow; no runtime product or auth logic is touched.
Overview
The publish-preview monorepo path no longer adds blanket Yarn resolutions like
"@scope/pkg": "portal:./…", which could override external dependencies that happen to share a name with a workspace package but need a different version.Resolutions are now keyed as
name@^<workspaceVersion>per package, using each workspace’s version from itspackage.json, so only requests aligned with the monorepo copy are redirected to the local portal after preview renaming.The workflow also computes
workspace_listonce and reuses it when building resolutions and when runningprepare_manifestover workspaces, instead of invokingyarn workspaces listtwice.Reviewed by Cursor Bugbot for commit 837df87. Bugbot is set up for automated code reviews on this repo. Configure here.