Skip to content

fix: add workspace resolutions for preview builds#8035

Merged
cryptodev-2s merged 3 commits intomainfrom
chore/add-workspace-resolutions-preview-builds
Feb 25, 2026
Merged

fix: add workspace resolutions for preview builds#8035
cryptodev-2s merged 3 commits intomainfrom
chore/add-workspace-resolutions-preview-builds

Conversation

@cryptodev-2s
Copy link
Contributor

@cryptodev-2s cryptodev-2s commented Feb 24, 2026

Explanation

During preview builds, packages are renamed from @metamask/* to a preview scope. Without explicit resolutions, yarn resolves @metamask/* imports from the npm registry instead of the local workspace, causing build failures when packages contain unpublished type changes.

This adds workspace resolutions to the root package.json in prepare-preview-builds.sh so that @metamask/* imports continue to resolve locally.

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

Note

Low Risk
Build-script-only change that adjusts dependency resolution for preview builds; risk is limited to potentially overriding existing resolutions behavior in CI/preview pipelines.

Overview
Preview-build preparation now injects Yarn resolutions into the root package.json before rewriting workspace manifests, mapping each workspace package name to a local portal: path.

This prevents @metamask/* dependencies from being pulled from the npm registry after packages are renamed to the preview scope, avoiding build failures when unpublished workspace changes (e.g., types) exist.

Written by Cursor Bugbot for commit 702bd39. This will update automatically on new commits. Configure here.

Ensure @metamask/* imports resolve from local workspace after
packages are renamed to the preview scope, preventing build
failures from unpublished type changes.
@mcmire
Copy link
Contributor

mcmire commented Feb 24, 2026

@cryptodev-2s Does this change mean that all internal dependencies will resolve to preview builds now?

@cryptodev-2s
Copy link
Contributor Author

@cryptodev-2s Does this change mean that all internal dependencies will resolve to preview builds now?

No the resolutions ensure internal dependencies resolve from the checked-out workspace on CI, not from preview builds or the npm registry.

Comment on lines 38 to 41
resolutions="{}"
while IFS=$'\t' read -r location name; do
resolutions=$(echo "$resolutions" | jq --arg orig "$name" --arg loc "$location" '. + {($orig): ("portal:./" + $loc)}')
done < <(yarn workspaces list --no-private --json | jq --slurp --raw-output 'map(select(.location != ".")) | map([.location, .name]) | map(@tsv) | .[]')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be a simpler way of doing the same thing:

Suggested change
resolutions="{}"
while IFS=$'\t' read -r location name; do
resolutions=$(echo "$resolutions" | jq --arg orig "$name" --arg loc "$location" '. + {($orig): ("portal:./" + $loc)}')
done < <(yarn workspaces list --no-private --json | jq --slurp --raw-output 'map(select(.location != ".")) | map([.location, .name]) | map(@tsv) | .[]')
resolutions="$(yarn workspaces list --no-private --json | jq --slurp --raw-output 'reduce .[] as $entry ({}; .[$entry.name] = "portal:./" + $entry.location)')"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes much cleaner, fixed here 1e855a9
However is there a reason you used --raw-output the result passed the jq is a JSON object ?

Copy link
Member

@Gudahtt Gudahtt Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, the --raw-output flag seems unnecessary. I didn't mean to include it

Comment on lines 38 to 41
resolutions="{}"
while IFS=$'\t' read -r location name; do
resolutions=$(echo "$resolutions" | jq --arg orig "$name" --arg loc "$location" '. + {($orig): ("portal:./" + $loc)}')
done < <(yarn workspaces list --no-private --json | jq --slurp --raw-output 'map(select(.location != ".")) | map([.location, .name]) | map(@tsv) | .[]')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strategy of using package name resolutions could still cause a build failure in cases where two different major versions of a monorepo package are used in the dependency tree. We do try to avoid that though. And at least it's certainly less broken (or less likely to cause a build failure) with this approach

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For this to be more accurate, we'd have to use something like this as the resolution instead:

"@metamask/<PACKAGE_NAME>@<VERSION_RANGE>": "@metamask-previews/<PACKAGE_NAME>@<VERSION_RANGE>"

or

"@metamask/<PACKAGE_NAME>@<VERSION_RANGE>": "portal:./[location]"

(they should be equivalent).

But it would take a bit of extra work to grab the version from each package manifest

@cryptodev-2s
Copy link
Contributor Author

@metamaskbot publish-preview

@cryptodev-2s
Copy link
Contributor Author

@metamaskbot publish-preview

Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@cryptodev-2s cryptodev-2s added this pull request to the merge queue Feb 25, 2026
Merged via the queue into main with commit f8001a6 Feb 25, 2026
313 checks passed
@cryptodev-2s cryptodev-2s deleted the chore/add-workspace-resolutions-preview-builds branch February 25, 2026 17:54
@github-actions
Copy link
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/account-tree-controller": "4.1.1-preview-702bd3940",
  "@metamask-previews/accounts-controller": "36.0.1-preview-702bd3940",
  "@metamask-previews/address-book-controller": "7.0.1-preview-702bd3940",
  "@metamask-previews/ai-controllers": "0.1.0-preview-702bd3940",
  "@metamask-previews/analytics-controller": "1.0.0-preview-702bd3940",
  "@metamask-previews/analytics-data-regulation-controller": "0.0.0-preview-702bd3940",
  "@metamask-previews/announcement-controller": "8.0.0-preview-702bd3940",
  "@metamask-previews/app-metadata-controller": "2.0.0-preview-702bd3940",
  "@metamask-previews/approval-controller": "8.0.0-preview-702bd3940",
  "@metamask-previews/assets-controller": "2.0.2-preview-702bd3940",
  "@metamask-previews/assets-controllers": "100.0.3-preview-702bd3940",
  "@metamask-previews/base-controller": "9.0.0-preview-702bd3940",
  "@metamask-previews/base-data-service": "0.0.0-preview-702bd3940",
  "@metamask-previews/bridge-controller": "67.2.0-preview-702bd3940",
  "@metamask-previews/bridge-status-controller": "67.0.1-preview-702bd3940",
  "@metamask-previews/build-utils": "3.0.4-preview-702bd3940",
  "@metamask-previews/chain-agnostic-permission": "1.4.0-preview-702bd3940",
  "@metamask-previews/claims-controller": "0.4.2-preview-702bd3940",
  "@metamask-previews/client-controller": "1.0.0-preview-702bd3940",
  "@metamask-previews/compliance-controller": "1.0.1-preview-702bd3940",
  "@metamask-previews/composable-controller": "12.0.0-preview-702bd3940",
  "@metamask-previews/connectivity-controller": "0.1.0-preview-702bd3940",
  "@metamask-previews/controller-utils": "11.19.0-preview-702bd3940",
  "@metamask-previews/core-backend": "6.0.0-preview-702bd3940",
  "@metamask-previews/delegation-controller": "2.0.1-preview-702bd3940",
  "@metamask-previews/earn-controller": "11.1.1-preview-702bd3940",
  "@metamask-previews/eip-5792-middleware": "2.1.0-preview-702bd3940",
  "@metamask-previews/eip-7702-internal-rpc-middleware": "0.1.0-preview-702bd3940",
  "@metamask-previews/eip1193-permission-middleware": "1.0.3-preview-702bd3940",
  "@metamask-previews/ens-controller": "19.0.3-preview-702bd3940",
  "@metamask-previews/error-reporting-service": "3.0.1-preview-702bd3940",
  "@metamask-previews/eth-block-tracker": "15.0.1-preview-702bd3940",
  "@metamask-previews/eth-json-rpc-middleware": "23.1.0-preview-702bd3940",
  "@metamask-previews/eth-json-rpc-provider": "6.0.0-preview-702bd3940",
  "@metamask-previews/foundryup": "1.0.1-preview-702bd3940",
  "@metamask-previews/gas-fee-controller": "26.0.3-preview-702bd3940",
  "@metamask-previews/gator-permissions-controller": "2.0.0-preview-702bd3940",
  "@metamask-previews/json-rpc-engine": "10.2.2-preview-702bd3940",
  "@metamask-previews/json-rpc-middleware-stream": "8.0.8-preview-702bd3940",
  "@metamask-previews/keyring-controller": "25.1.0-preview-702bd3940",
  "@metamask-previews/logging-controller": "7.0.1-preview-702bd3940",
  "@metamask-previews/message-manager": "14.1.0-preview-702bd3940",
  "@metamask-previews/messenger": "0.3.0-preview-702bd3940",
  "@metamask-previews/multichain-account-service": "7.0.0-preview-702bd3940",
  "@metamask-previews/multichain-api-middleware": "1.2.7-preview-702bd3940",
  "@metamask-previews/multichain-network-controller": "3.0.4-preview-702bd3940",
  "@metamask-previews/multichain-transactions-controller": "7.0.1-preview-702bd3940",
  "@metamask-previews/name-controller": "9.0.0-preview-702bd3940",
  "@metamask-previews/network-controller": "30.0.0-preview-702bd3940",
  "@metamask-previews/network-enablement-controller": "4.1.2-preview-702bd3940",
  "@metamask-previews/notification-services-controller": "22.0.0-preview-702bd3940",
  "@metamask-previews/permission-controller": "12.2.0-preview-702bd3940",
  "@metamask-previews/permission-log-controller": "5.0.0-preview-702bd3940",
  "@metamask-previews/perps-controller": "0.0.0-preview-702bd3940",
  "@metamask-previews/phishing-controller": "16.3.0-preview-702bd3940",
  "@metamask-previews/polling-controller": "16.0.3-preview-702bd3940",
  "@metamask-previews/preferences-controller": "22.1.0-preview-702bd3940",
  "@metamask-previews/profile-metrics-controller": "3.0.1-preview-702bd3940",
  "@metamask-previews/profile-sync-controller": "27.1.0-preview-702bd3940",
  "@metamask-previews/ramps-controller": "10.0.0-preview-702bd3940",
  "@metamask-previews/rate-limit-controller": "7.0.0-preview-702bd3940",
  "@metamask-previews/remote-feature-flag-controller": "4.1.0-preview-702bd3940",
  "@metamask-previews/sample-controllers": "4.0.3-preview-702bd3940",
  "@metamask-previews/seedless-onboarding-controller": "8.1.0-preview-702bd3940",
  "@metamask-previews/selected-network-controller": "26.0.3-preview-702bd3940",
  "@metamask-previews/shield-controller": "5.0.1-preview-702bd3940",
  "@metamask-previews/signature-controller": "39.0.4-preview-702bd3940",
  "@metamask-previews/storage-service": "1.0.0-preview-702bd3940",
  "@metamask-previews/subscription-controller": "6.0.0-preview-702bd3940",
  "@metamask-previews/transaction-controller": "62.19.0-preview-702bd3940",
  "@metamask-previews/transaction-pay-controller": "16.1.0-preview-702bd3940",
  "@metamask-previews/user-operation-controller": "41.0.3-preview-702bd3940"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants