Skip to content

feat: import aliases#40695

Open
n3ps wants to merge 3 commits intomainfrom
n3ps/import-alias
Open

feat: import aliases#40695
n3ps wants to merge 3 commits intomainfrom
n3ps/import-alias

Conversation

@n3ps
Copy link
Contributor

@n3ps n3ps commented Mar 8, 2026

Description

Introduces import aliases to replace deep relative paths like ../../../some-directory/....

Why

  • Readability: import origin is obvious at a glance
  • Refactor-safe: moving files doesn't break imports
  • Enforces architecture: ~/shared and ~/ui make the dependency direction explicit
  • No breaking changes: old relative imports continue to work, adoption is gradual

For this first phase, adding these aliases:~/shared and ~/ui and updated the Activity components as reference example.

Once migrated circular dependencies are easier to spot because the import direction is explicit.

Configuration:

  • tsconfig.json - paths
  • webpack - resolve.alias
  • jest - moduleNameMapper
  • browserify - custom script
// Any file can now:

import { something } from '~/shared/constants/app';
import { Component } from '~/ui/components/some-component';

// Instead of

import { something } from '../../../../shared/constants/app';
import { Component } from '../../../components/some-component';

Changelog

CHANGELOG entry: feat: import aliases

Related issues

Fixes:

Manual testing steps

N/A

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

Note

Medium Risk
Touches module resolution across Babel/browserify, webpack, Storybook, TypeScript, and Jest; misconfiguration could break builds or tests in non-obvious ways despite being largely a path-rewrite/refactor change.

Overview
Adds first-class import aliases ~/ui and ~/shared across the toolchain (TypeScript paths, webpack + Storybook resolve.alias, Jest moduleNameMapper) and updates depcheck ignores for the ~ pseudo-package.

Introduces a custom Babel transform (development/build/transforms/import-alias.js + tests) to rewrite these aliases to relative paths for browserify, and migrates the multichain Activity v2 components/tests to use the new alias imports instead of deep relative paths.

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

@n3ps n3ps added the team-core-extension-ux Core Extension UX team label Mar 8, 2026
@socket-security
Copy link

socket-security bot commented Mar 8, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@github-actions github-actions bot added the size-M label Mar 8, 2026
@cursor cursor bot force-pushed the n3ps/import-alias branch 2 times, most recently from cecd222 to 2fedf47 Compare March 8, 2026 05:22
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 05:22 Inactive
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Mar 8, 2026

✨ Files requiring CODEOWNER review ✨

👨‍🔧 @MetaMask/core-extension-ux (12 files, +68 -68)
  • 📁 ui/
    • 📁 components/
      • 📁 multichain/
        • 📁 activity-v2/
          • 📄 activity-details-modal-adapter.tsx +12 -12
          • 📄 activity-list-item.tsx +4 -4
          • 📄 activity-list.tsx +10 -10
          • 📄 activity-tx-icon.tsx +2 -2
          • 📄 helpers.test.ts +6 -6
          • 📄 helpers.ts +3 -3
          • 📄 hooks.test.tsx +6 -6
          • 📄 hooks.ts +14 -14
          • 📄 local-activity-list-item.tsx +2 -2
          • 📄 non-evm-activity-list-item.tsx +6 -6
          • 📄 non-evm-details-modal.test.tsx +2 -2
          • 📄 non-evm-details-modal.tsx +1 -1

@cursor cursor bot force-pushed the n3ps/import-alias branch from 2fedf47 to dbf2339 Compare March 8, 2026 05:36
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 05:36 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from dbf2339 to 5d18c91 Compare March 8, 2026 06:09
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 06:09 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from 5d18c91 to d09256a Compare March 8, 2026 06:21
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 06:21 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from d09256a to cd2483e Compare March 8, 2026 06:43
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 06:43 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from cd2483e to dd9bd02 Compare March 8, 2026 06:50
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 06:50 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from dd9bd02 to fa20e9d Compare March 8, 2026 07:10
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 07:10 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from fa20e9d to 8ddb071 Compare March 8, 2026 07:16
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 07:16 Inactive
Configure all build systems to resolve ~/ui and ~/shared aliases:
- tsconfig.json: paths for ~/ui/* and ~/shared/*
- webpack: resolve.alias entries
- browserify: pathmodify plugin in build pipeline
- jest: moduleNameMapper in unit and integration configs
- storybook: resolve.alias in webpack config
- depcheck: ignore aliases in dependency check

No existing imports are changed. Both relative and aliased imports
work simultaneously, enabling gradual opt-in adoption.

Co-authored-by: Francis Nepomuceno <n3ps@users.noreply.github.com>
@cursor cursor bot force-pushed the n3ps/import-alias branch from 8ddb071 to 28db9a9 Compare March 8, 2026 07:29
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 07:29 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from 28db9a9 to 3e771b3 Compare March 8, 2026 07:35
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 07:35 Inactive
@cursor cursor bot temporarily deployed to pr-comment March 8, 2026 08:06 Inactive
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Mar 8, 2026

Builds ready [3e771b3]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account27626829511273295
total27626829511273295
Confirm Txconfirm_tx61246001626811562586268
total61246001626811562586268
Bridge User Actionsbridge_load_page24721030234270302
bridge_load_asset_picker20318022015210220
bridge_search_token7557437617758761
total1210111112685612541268
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14201236200411914461633
load11821006173010412111350
domContentLoaded117499616489912061342
domInteractive3017160232593
firstPaint1466950778187257
backgroundConnect21319438226210253
firstReactRender19135452027
initialActions106124
loadScripts98080314359610101146
setupStore1368891521
numNetworkReqs312290192281
Power User HomeuiStartup3012170612305225125468039
load12181055186215812201637
domContentLoaded12041047181315812011627
domInteractive36191612933108
firstPaint1947650898259408
backgroundConnect1114270971920074195488
firstReactRender25164872740
initialActions106113
loadScripts98282715651499861366
setupStore1665381731
numNetworkReqs883722946104190
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2202202210221221
srpButtonToSrpForm9996106498106
confirmSrpToPwForm22212312223
pwFormToMetricsScreen16151711617
metricsToWalletReadyScreen17171701717
doneButtonToHomeScreen78959210271829671027
openAccountMenuToAccountListLoaded2935292229511229512951
total40603911426613341114266
Onboarding New WalletcreateWalletToSocialScreen2172162181218218
srpButtonToPwForm1061011103109110
createPwToRecoveryScreen888088
skipBackupToMetricsScreen35333723737
agreeButtonToOnboardingSuccess16151601616
doneButtonToAssetList50747757035521570
total89185695637907956
Asset DetailsassetClickToPriceChart1261241303130130
total1261241303130130
Solana Asset DetailsassetClickToPriceChart73717527475
total73717527475
Import Srp HomeloginToHomeScreen1978189720275320262027
openAccountMenuAfterLogin613685208185
homeAfterImportWithNewWallet24432269264113524682641
total44754247466115045314661
Send TransactionsopenSendPageFromHome26204082940
selectTokenToSendFormLoaded21182522325
reviewTransactionToConfirmationPage86684889319874893
total90988693721923937
SwapopenSwapPageFromHome401959155459
fetchAndDisplaySwapQuotes269626882703627022703
total2729271327421027302742
🌐 Dapp Page Load Benchmarks

Current Commit: 3e771b3 | Date: 3/8/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±41ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 732ms (±39ms) 🟢 | historical mean value: 727ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 81ms (±9ms) 🟢 | historical mean value: 81ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 41ms 1.01s 1.34s 1.08s 1.34s
domContentLoaded 732ms 39ms 709ms 1.02s 760ms 1.02s
firstPaint 81ms 9ms 64ms 148ms 92ms 148ms
firstContentfulPaint 81ms 9ms 64ms 148ms 92ms 148ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 5.15 MiB (100%)
  • ui: 8.2 MiB (100%)
  • common: 10.99 MiB (100%)

@cursor cursor bot force-pushed the n3ps/import-alias branch from 3e771b3 to f468bef Compare March 9, 2026 02:10
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 02:10 Inactive
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 02:39 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from f468bef to bed6d2b Compare March 9, 2026 02:55
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 03:22 Inactive
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 04:44 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from bed6d2b to 883d750 Compare March 9, 2026 04:59
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 05:00 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from 883d750 to 2ff6735 Compare March 9, 2026 05:19
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 05:20 Inactive
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 05:45 Inactive
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Mar 9, 2026

Builds ready [2ff6735]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account32926248686355486
total32926248686355486
Confirm Txconfirm_tx6032601160451360446045
total6032601160451360446045
Bridge User Actionsbridge_load_page23019627330254273
bridge_load_asset_picker21018726029227260
bridge_search_token74071375616753756
total118911811196611961196
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup15081272179910215421717
load1257106314839512971432
domContentLoaded1249106014659212901418
domInteractive3119135212885
firstPaint179741279139224344
backgroundConnect23020339723237261
firstReactRender20146572134
initialActions107114
loadScripts103784912369110781209
setupStore1463561825
numNetworkReqs312290192283
Power User HomeuiStartup20211659246414021012280
load11861061189215511721556
domContentLoaded11671055179414511501546
domInteractive3720202253877
firstPaint197791812182255318
backgroundConnect30426136121319343
firstReactRender24164662634
initialActions107113
loadScripts94784715561409301331
setupStore1684971725
numNetworkReqs69361834657170
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2212192263223226
srpButtonToSrpForm106981188112118
confirmSrpToPwForm22222302323
pwFormToMetricsScreen16161701617
metricsToWalletReadyScreen18172111921
doneButtonToHomeScreen6096066123612612
openAccountMenuToAccountListLoaded30332947316410131493164
total4046392041669841454166
Onboarding New WalletcreateWalletToSocialScreen2182172191218219
srpButtonToPwForm1071061091109109
createPwToRecoveryScreen889099
skipBackupToMetricsScreen36353713637
agreeButtonToOnboardingSuccess17161911719
doneButtonToAssetList61056767138602671
total100095110573810011057
Asset DetailsassetClickToPriceChart14511818324144183
total14511818324144183
Solana Asset DetailsassetClickToPriceChart79728768387
total79728768387
Import Srp HomeloginToHomeScreen21211884242518921832425
openAccountMenuAfterLogin53406495864
homeAfterImportWithNewWallet24162255263313424862633
total4642459346733546734673
Send TransactionsopenSendPageFromHome24172952729
selectTokenToSendFormLoaded351860185360
reviewTransactionToConfirmationPage8508448617847861
total90488093522915935
SwapopenSwapPageFromHome35314143641
fetchAndDisplaySwapQuotes267926782680126802680
total2728271227581727342758
🌐 Dapp Page Load Benchmarks

Current Commit: 2ff6735 | Date: 3/9/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.08s (±128ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 763ms (±148ms) 🟢 | historical mean value: 727ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 104ms (±220ms) 🟢 | historical mean value: 81ms ⬆️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.08s 128ms 1.05s 2.32s 1.10s 2.32s
domContentLoaded 763ms 148ms 731ms 2.22s 772ms 2.22s
firstPaint 104ms 220ms 64ms 2.29s 96ms 2.29s
firstContentfulPaint 104ms 220ms 64ms 2.29s 96ms 2.29s
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 5.15 MiB (100%)
  • ui: 8.2 MiB (100%)
  • common: 10.99 MiB (100%)

@n3ps n3ps marked this pull request as ready for review March 9, 2026 05:53
@n3ps n3ps requested a review from a team as a code owner March 9, 2026 05:53
Configure all build systems to resolve ~/ui and ~/shared aliases:
- tsconfig.json: paths for ~/ui/* and ~/shared/*
- webpack: resolve.alias entries
- browserify: custom babel plugin (development/build/transforms/import-alias.js)
- jest: moduleNameMapper in unit and integration configs
- storybook: resolve.alias in webpack config
- depcheck: ignore alias prefix in dependency check

The babel plugin rewrites ~/ui/foo and ~/shared/foo to relative paths
during transpilation. No fs access needed, so LavaMoat is unaffected.

No existing imports are changed. Both relative and aliased imports
work simultaneously, enabling gradual opt-in adoption.

Co-authored-by: Francis Nepomuceno <n3ps@users.noreply.github.com>
@cursor cursor bot force-pushed the n3ps/import-alias branch from 2ff6735 to 8f6a7c8 Compare March 9, 2026 06:01
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 06:01 Inactive
@cursor cursor bot force-pushed the n3ps/import-alias branch from 8f6a7c8 to 6980d20 Compare March 9, 2026 06:03
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 06:03 Inactive
Convert 47 deep relative imports to aliases across all 12 activity-v2
files. Sibling/parent imports remain relative.

Co-authored-by: Francis Nepomuceno <n3ps@users.noreply.github.com>
@cursor cursor bot force-pushed the n3ps/import-alias branch from 6980d20 to 14be0c3 Compare March 9, 2026 06:25
@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 06:25 Inactive
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 9, 2026

@cursor cursor bot temporarily deployed to pr-comment March 9, 2026 06:54 Inactive
@metamaskbotv2
Copy link
Contributor

metamaskbotv2 bot commented Mar 9, 2026

Builds ready [14be0c3]
⚡ Performance Benchmarks
👆 Interaction Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Load New Accountload_new_account27626429713277297
total27626429713277297
Confirm Txconfirm_tx604160326051760456051
total604160326051760456051
Bridge User Actionsbridge_load_page2192112318220231
bridge_load_asset_picker20914824337235243
bridge_search_token73370277727741777
total1169110212325312071232
🔌 Startup Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Standard HomeuiStartup14151210169810114451619
load1181100414538812161360
domContentLoaded117498813858512081352
domInteractive2817107162668
firstPaint170701263164204283
backgroundConnect21219526613213238
firstReactRender19134662030
initialActions107124
loadScripts97878712008510151148
setupStore1364561522
numNetworkReqs322292202285
Power User HomeuiStartup21251604664952621362532
load11951043181717311891655
domContentLoaded11791035177716711771596
domInteractive3919229303598
firstPaint1887954293243384
backgroundConnect3562593149347324376
firstReactRender25165592649
initialActions105113
loadScripts96082715501569621349
setupStore1774371831
numNetworkReqs74352134679171
🧭 User Journey Benchmarks
BenchmarkMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P75 (ms)P95 (ms)
Onboarding Import WalletimportWalletToSocialScreen2202202200220220
srpButtonToSrpForm95949619596
confirmSrpToPwForm22222202222
pwFormToMetricsScreen15151601616
metricsToWalletReadyScreen16151611616
doneButtonToHomeScreen64759072451661724
openAccountMenuToAccountListLoaded2925290029743429742974
total40333863425014541154250
Onboarding New WalletcreateWalletToSocialScreen2212202210221221
srpButtonToPwForm1061041081107108
createPwToRecoveryScreen889089
skipBackupToMetricsScreen37363703737
agreeButtonToOnboardingSuccess16161701717
doneButtonToAssetList56248063864619638
total95987510236410151023
Asset DetailsassetClickToPriceChart803013340103133
total803013340103133
Solana Asset DetailsassetClickToPriceChart78777917879
total78777917879
Import Srp HomeloginToHomeScreen20381910220213121942202
openAccountMenuAfterLogin523765116165
homeAfterImportWithNewWallet24192251269916524952699
total45094244495426546434954
Send TransactionsopenSendPageFromHome26252812828
selectTokenToSendFormLoaded281843124243
reviewTransactionToConfirmationPage8508458554853855
total90989093918921939
SwapopenSwapPageFromHome34304043440
fetchAndDisplaySwapQuotes2695268427161226982716
total2740272127731827462773
🌐 Dapp Page Load Benchmarks

Current Commit: 14be0c3 | Date: 3/9/2026

📄 Localhost MetaMask Test Dapp

Samples: 100

Summary

  • pageLoadTime-> current mean value: 1.04s (±40ms) 🟡 | historical mean value: 1.04s ⬆️ (historical data)
  • domContentLoaded-> current mean value: 730ms (±37ms) 🟢 | historical mean value: 727ms ⬆️ (historical data)
  • firstContentfulPaint-> current mean value: 80ms (±10ms) 🟢 | historical mean value: 81ms ⬇️ (historical data)

📈 Detailed Results

Metric Mean Std Dev Min Max P95 P99
pageLoadTime 1.04s 40ms 1.01s 1.33s 1.08s 1.33s
domContentLoaded 730ms 37ms 708ms 1.01s 767ms 1.01s
firstPaint 80ms 10ms 60ms 164ms 88ms 164ms
firstContentfulPaint 80ms 10ms 60ms 164ms 88ms 164ms
largestContentfulPaint 0ms 0ms 0ms 0ms 0ms 0ms
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 5.15 MiB (100%)
  • ui: 8.2 MiB (100%)
  • common: 10.99 MiB (100%)

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

Labels

size-M team-core-extension-ux Core Extension UX team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants