Skip to content

chore: moving dependencies to peer and dev dependencies#729

Merged
brianacnguyen merged 9 commits into
mainfrom
fix/dependencies
Jun 10, 2025
Merged

chore: moving dependencies to peer and dev dependencies#729
brianacnguyen merged 9 commits into
mainfrom
fix/dependencies

Conversation

@georgewrmarshall

@georgewrmarshall georgewrmarshall commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

Description

This PR aligns dependency versions across the design system with MetaMask extension and mobile codebases to ensure compatibility

Key changes:

  1. Downgraded bitcoin-address-validation from ^3.0.0 to >=2.0.0 to avoid ESM-only modules that break compatibility with browser extensions and React Native
  2. Standardized dependency versions to use minimum major versions:
    • @metamask/utils: ^11.4.0^11.0.0
    • @solana/addresses: ^2.1.0^2.0.0
  3. Added custom TypeScript declarations for bitcoin-address-validation v2.0.0 since it lacks built-in types
  4. Reorganized dependencies by moving shared dependencies to devDependencies and peerDependencies where appropriate
  5. Updated yarn constraints to allow flexible version ranges for bitcoin-address-validation across library vs application packages

The >=2.0.0 version range for bitcoin-address-validation allows v2.x.x, v3.x.x, and future versions while maintaining compatibility with CommonJS environments used by MetaMask extension and mobile.

Related issues

Fixes: #690

Manual testing steps

  1. Run yarn constraints --fix - should pass without violations
  2. Run yarn build - all packages should build successfully
  3. Run yarn lint - should pass with only expected warnings
  4. Verify TypeScript compilation works for bitcoin-address-validation imports
  5. Test that Jazzicon and Maskicon components still function correctly with Bitcoin address validation

Text published preview packages in mobile PR

  1. Run mobile locally
  2. See Login page works as expected with all Avatars

Screenshots/Recordings

Before

After

Latest publish preview (8a24c64) working in mobile and extension

after.mov
after.extension.mov

Pre-merge author checklist

  • I've followed MetaMask Contributor Docs
  • I've completed the PR template to the best of my ability
  • I've included tests if applicable
  • I've documented my code using JSDoc format if applicable
  • I've applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

"autoprefixer": "^10.4.20",
"axe-playwright": "^2.1.0",
"bitcoin-address-validation": "^3.0.0",
"playwright": "^1.52.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These dependencies have been moved to peerDependencies in design-system-react, so they now need to be explicitly added as devDependencies in storybook-react

Comment on lines -46 to +50
"react-native-gesture-handler": "^1.10.3",
"react-native-jazzicon": "^0.1.2",
"react-native-reanimated": "3.3.0"
"react-native-jazzicon": "^0.1.2"

@georgewrmarshall georgewrmarshall Jun 9, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are keeping react-native-jazzicon as a regular dependency because it should only be used internally by AccountAvatar within design-system-react-native, not directly by consuming applications.

Comment on lines -54 to -57
"@metamask/utils": "^11.4.0",
"@radix-ui/react-slot": "^1.1.0",
"@solana/addresses": "^2.1.0",
"bitcoin-address-validation": "^3.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These dependencies have been moved to peerDependencies because they are used by the extension and portfolio outside of the design system’s UI components, so moving them to peerDependencies allows the consuming app to specify the version, reducing the overall bundle size and avoiding duplicate dependencies. We are keeping @metamask/jazzicon as a regular dependency because it should only be used internally by AccountAvatar within design-system-react, not directly by consuming applications.

"deepmerge": "^4.2.2",
"jest": "^29.7.0",
"metro-react-native-babel-preset": "^0.77.0",
"react": "^18.2.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixing build issue by moving react to devDependencies, not actually sure how it passed CI without it being here 🤔

@georgewrmarshall

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
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/design-system-react": "0.0.0-preview.0a959b0",
  "@metamask-previews/design-system-react-native": "0.0.0-preview.0a959b0",
  "@metamask-previews/design-system-tailwind-preset": "0.4.0-preview.0a959b0",
  "@metamask-previews/design-system-twrnc-preset": "0.0.0-preview.0a959b0",
  "@metamask-previews/design-tokens": "7.1.0-preview.0a959b0"
}

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@georgewrmarshall

georgewrmarshall commented Jun 9, 2025

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
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/design-system-react": "0.0.0-preview.0317b81",
  "@metamask-previews/design-system-react-native": "0.0.0-preview.0317b81",
  "@metamask-previews/design-system-tailwind-preset": "0.4.0-preview.0317b81",
  "@metamask-previews/design-system-twrnc-preset": "0.0.0-preview.0317b81",
  "@metamask-previews/design-tokens": "7.1.0-preview.0317b81"
}

@georgewrmarshall georgewrmarshall changed the title chore: fixing dependencies chore: moving dependencies to peer and dev dependencies Jun 9, 2025
@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

"@metamask/design-tokens": "^7.0.0",
"@metamask/utils": "^11.0.0",
"@solana/addresses": "^2.0.0",
"bitcoin-address-validation": "2.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Previously tried 2|3 as the only update is to convert to esm modules but are restricted because of yarn constraints. We can just fast follow an upgrade when extension and mobile do https://github.com/ruigomeseu/bitcoin-address-validation/blob/master/CHANGELOG.md

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@georgewrmarshall

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

Comment on lines +19 to +21
"@metamask/utils": "^11.0.0",
"@solana/addresses": "^2.0.0",
"bitcoin-address-validation": "2.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These dependencies have been moved to peerDependencies in design-system-react-native, so they now need to be explicitly added as dependencies in storybook-react-native

@github-actions

github-actions Bot commented Jun 9, 2025

Copy link
Copy Markdown
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/design-system-react": "0.0.0-preview.ff8ed96",
  "@metamask-previews/design-system-react-native": "0.0.0-preview.ff8ed96",
  "@metamask-previews/design-system-tailwind-preset": "0.4.0-preview.ff8ed96",
  "@metamask-previews/design-system-twrnc-preset": "0.0.0-preview.ff8ed96",
  "@metamask-previews/design-tokens": "7.1.0-preview.ff8ed96"
}

Comment thread package.json
"@metamask/eslint-config-nodejs": "^14.0.0",
"@metamask/eslint-config-typescript": "^14.0.0",
"@metamask/utils": "^11.4.0",
"@metamask/utils": "^11.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yarn constraints update

"bitcoin-address-validation": "^3.0.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-jazzicon": "^0.1.2",
"react-native-reanimated": "3.3.0"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These dependencies have been moved to either peerDependencies or devDependencies based on their usage. Packages like testing-library are only needed for development and testing, so they are now devDependencies. The other packages are used by mobile outside of the design system’s UI components, so moving them to peerDependencies allows the consuming app to specify the version, reducing the overall bundle size and avoiding duplicate dependencies.

"@metamask/auto-changelog": "^5.0.2",
"@metamask/design-system-twrnc-preset": "workspace:^",
"@metamask/design-tokens": "workspace:^",
"@metamask/utils": "^11.0.0",

@georgewrmarshall georgewrmarshall Jun 10, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are pinning @metamask/utils to major version ^11.0.0 to maintain compatibility with MetaMask Mobile, which uses ^11.2.0 (see metamask-mobile/package.json#L246). Any 11.x version will work across both projects.

"@metamask/design-system-twrnc-preset": "workspace:^",
"@metamask/design-tokens": "workspace:^",
"@metamask/utils": "^11.0.0",
"@solana/addresses": "^2.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are pinning @solana/addresses to major version ^2.0.0 to maintain compatibility with MetaMask Mobile, which uses 2.0.0 (see metamask-mobile/package.json#L280).

"@types/react": "^18.2.0",
"@types/react-test-renderer": "^18",
"babel-jest": "^29.7.0",
"bitcoin-address-validation": "2.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We are pinning bitcoin-address-validation to major version ^2.0.0 to maintain compatibility with MetaMask Mobile, which uses 2.0.0 (see metamask-mobile/package.json#L295).

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@georgewrmarshall

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

Comment on lines +19 to +21
"@metamask/utils": "^11.0.0",
"@solana/addresses": "^2.0.0",
"bitcoin-address-validation": ">=2.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

These dependencies have been moved to peerDependencies in design-system-react-native, so they now need to be explicitly added as devDependencies in storybook-react-native

@github-actions

Copy link
Copy Markdown
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/design-system-react": "0.0.0-preview.d4c6643",
  "@metamask-previews/design-system-react-native": "0.0.0-preview.d4c6643",
  "@metamask-previews/design-system-tailwind-preset": "0.4.0-preview.d4c6643",
  "@metamask-previews/design-system-twrnc-preset": "0.0.0-preview.d4c6643",
  "@metamask-previews/design-tokens": "7.1.0-preview.d4c6643"
}

"@types/react": "^18.2.0",
"@types/react-test-renderer": "^18",
"babel-jest": "^29.7.0",
"bitcoin-address-validation": ">=2.0.0",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We specify bitcoin-address-validation with the version constraint >=2.0.0 to ensure compatibility with MetaMask Mobile, which currently uses version 2.0.0 (reference). This range also permits upgrades to future major versions, including 3.x.x, since both v2 and v3 are compatible with design system libraries. Notably, v3.0.0 introduces ESM (ECMAScript Modules) support, which this project fully supports, as reflected in the CHANGELOG.

"metro-react-native-babel-preset": "^0.77.0",
"react": "^18.2.0",
"react-native": "^0.72.15",
"react-native-gesture-handler": "^1.10.3",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"expo-system-ui": "~2.4.0",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "3.3.0",
"react-native-reanimated": "^3.17.2",

@georgewrmarshall georgewrmarshall Jun 10, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Aligning react-native-reanimated version with mobile https://github.com/MetaMask/metamask-mobile/blob/main/package.json#L389

"react": "^18.2.0",
"react-native": "^0.72.15",
"react-native-gesture-handler": "^1.10.3",
"react-native-reanimated": "^3.17.2",

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@socket-security

socket-security Bot commented Jun 10, 2025

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedreact-native-gesture-handler@​1.10.3 ⏵ 2.12.19910091 +389100
Updatedreact-native-gesture-handler@​1.10.3 ⏵ 2.25.09910094 +689100
Addedreact-native-reanimated@​3.18.09810091100100

View full report

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

* @returns True if the address is valid, false otherwise
*/
export function validate(address: string, network?: Network): boolean;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed because we downgraded our version of bitcoin-address-validation to match mobile

* @returns True if the address is valid, false otherwise
*/
export function validate(address: string, network?: Network): boolean;
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed because we downgraded our version of bitcoin-address-validation to match extension can be removed when we upgrade to v3

@georgewrmarshall

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
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/design-system-react": "0.0.0-preview.8a24c64",
  "@metamask-previews/design-system-react-native": "0.0.0-preview.8a24c64",
  "@metamask-previews/design-system-tailwind-preset": "0.4.0-preview.8a24c64",
  "@metamask-previews/design-system-twrnc-preset": "0.0.0-preview.8a24c64",
  "@metamask-previews/design-tokens": "7.1.0-preview.8a24c64"
}

@georgewrmarshall georgewrmarshall marked this pull request as ready for review June 10, 2025 03:18
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner June 10, 2025 03:18
cursor[bot]

This comment was marked as outdated.

@github-actions

Copy link
Copy Markdown
Contributor

📖 Storybook Preview

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ BugBot reviewed your changes and found no bugs!


Was this report helpful? Give feedback by reacting with 👍 or 👎

Comment on lines +88 to +96
"@metamask/design-system-twrnc-preset": "^0.0.0",
"@metamask/design-tokens": "^7.0.0",
"@metamask/utils": "^11.0.0",
"@solana/addresses": "^2.0.0",
"bitcoin-address-validation": ">=2.0.0",
"react": ">=18.2.0",
"react-native": ">=0.72.0"
"react-native": ">=0.72.0",
"react-native-gesture-handler": ">=1.10.3",
"react-native-reanimated": ">=3.3.0"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Broadened peer dependency version ranges to support major upgrades for react-native, react-native-gesture-handler, and react-native-reanimated, enabling forward compatibility. Other key dependencies have been explicitly versioned to ensure stability and prevent breaking changes.

@georgewrmarshall

Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
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/design-system-react": "0.0.0-preview.5f5c97a",
  "@metamask-previews/design-system-react-native": "0.0.0-preview.5f5c97a",
  "@metamask-previews/design-system-tailwind-preset": "0.4.0-preview.5f5c97a",
  "@metamask-previews/design-system-twrnc-preset": "0.0.0-preview.5f5c97a",
  "@metamask-previews/design-tokens": "7.1.0-preview.5f5c97a"
}

@brianacnguyen brianacnguyen merged commit 5971669 into main Jun 10, 2025
37 checks passed
@brianacnguyen brianacnguyen deleted the fix/dependencies branch June 10, 2025 16:22
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.

Align react native, expo, metro versions with mobile

2 participants