Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: switch to Yarn v4 #4686

Merged
merged 4 commits into from
Dec 18, 2024
Merged

refactor: switch to Yarn v4 #4686

merged 4 commits into from
Dec 18, 2024

Conversation

compojoom
Copy link
Contributor

@compojoom compojoom commented Dec 18, 2024

What it solves

The first step to switching to a monorepo structure is to update yarn as newer versions offer:

  • improved speed
  • better monorepo management

We were stuck with yarn classic (which is deprecated for more than a couple of years now). Yarn 4 feels significantly faster and will lead to a better developer experience

How this PR fixes it

I've added a packagerManager field to the yarn.lock file. Had to dedupe some dependencies as they were wrong in yarn v1 and also had to remove @web3-onboard/keystone as it has one incorrectly defined dependency (the dependency version is not following semantic versioning and I couldn't find a way for yarn to ignore this). I have created a fix for it blocknative/web3-onboard#2322, but I doubt that it will be merged any time soon.

About github actions.
Our github actions were incorrectly placed in the workflows folder. I moved them to a separate github actions folder. This also made it possible to use tools such as act https://github.com/nektos/act to tests the flows locally.

The caching dependency action is a bit weird, but I had my reasons :). Using the actions/cache@v4 directly turned out to be very slow. I think that the main issue is the use of hashFiles in the key. For example restoring next.js build cache the key there is composed of hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') - we are dealing with a lot of files here and that apparently takes a lot of time. That's why I'm caching the key once it is generated by the restore action and then using it for the save action.

How to test it

Checkout the branch, make sure that you have run corepack enable and then just run yarn in the terminal. This should install the latest yarn v4 version and all necessary project dependencies.

Screenshots

Checklist

  • I've tested the branch on mobile 📱
  • I've documented how it affects the analytics (if at all) 📊
  • I've written a unit/e2e test for it (if applicable) 🧑‍💻

fix: github action crashing

.

fix: failing yarn v4 install due to incorrect 3rd party dependency

fix: remove Keystone pckg causing yarn v4 failure

fix: resolve merge conflict

fix: resolutions

fix: failing tests
Copy link

github-actions bot commented Dec 18, 2024

Copy link

github-actions bot commented Dec 18, 2024

📦 Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 1010.18 KB (🟢 -6.17 KB)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Eleven Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/apps 29.73 KB (🟢 -3.51 KB) 1.02 MB
/apps/custom 27.79 KB (🟢 -3.51 KB) 1.01 MB
/apps/open 50.12 KB (🟢 -3.51 KB) 1.04 MB
/home 55.19 KB (🟢 -3.51 KB) 1.04 MB
/settings/safe-apps 14.31 KB (🟢 -3.51 KB) 1 MB
/transactions 93.15 KB (🟢 -3.73 KB) 1.08 MB
/transactions/history 93.11 KB (🟢 -3.73 KB) 1.08 MB
/transactions/messages 54.88 KB (🟢 -3.51 KB) 1.04 MB
/transactions/msg 51.04 KB (🟢 -3.51 KB) 1.04 MB
/transactions/queue 44 KB (🟢 -3.51 KB) 1.03 MB
/transactions/tx 43.26 KB (🟢 -3.51 KB) 1.03 MB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

Copy link

github-actions bot commented Dec 18, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
73.91% (-0.01% 🔻)
14399/19483
🔴 Branches
51.44% (-0.01% 🔻)
3437/6681
🔴 Functions
56.86% (-0.02% 🔻)
2044/3595
🟡 Lines
75.44% (-0.01% 🔻)
13059/17311
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡
... / index.ts
65.14% (-0.32% 🔻)
49.02% 42.86%
66.67% (-0.34% 🔻)

Test suite run success

1712 tests passing in 232 suites.

Report generated by 🧪jest coverage report action from bdd5c7c

@compojoom compojoom marked this pull request as ready for review December 18, 2024 09:14
@compojoom compojoom requested a review from katspaugh December 18, 2024 09:14
Copy link
Member

@usame-algan usame-algan left a comment

Choose a reason for hiding this comment

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

Should we make an announcement that Keystone is going to be removed?

.github/actions/cache-deps/action.yml Outdated Show resolved Hide resolved
@@ -26,21 +26,21 @@
"cypress:canary": "cross-env TZ=UTC cypress open --e2e -b chrome:canary",
"cypress:run": "cypress run",
"cypress:ci": "yarn cypress:run --config baseUrl=http://localhost:8080 --spec cypress/e2e/smoke/*.cy.js",
"serve": "npx -y serve out -p ${REVERSE_PROXY_UI_PORT:=8080}",
"serve": "sh -c 'npx -y serve out -p ${REVERSE_PROXY_UI_PORT:=8080}'",
Copy link
Member

Choose a reason for hiding this comment

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

Why do you need this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because it was choking on the curly brackets. It seem that they are invalide in their Posix-like interpreter 🤷
https://yarnpkg.com/features/scripting#script-arguments

that's why I'm starting a shell and passign the command to it.

@@ -70,7 +70,6 @@
"@web3-onboard/coinbase": "^2.4.1",
"@web3-onboard/core": "^2.21.4",
"@web3-onboard/injected-wallets": "^2.11.2",
"@web3-onboard/keystone": "^2.3.7",
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we won't be migrating to AppKit until after Q1 2025, so we'll eventually have to find a way to restore this package.

Copy link
Member

@katspaugh katspaugh left a comment

Choose a reason for hiding this comment

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

🤘

Co-authored-by: Usame Algan <5880855+usame-algan@users.noreply.github.com>
@compojoom compojoom merged commit a2b98b1 into dev Dec 18, 2024
15 checks passed
@compojoom compojoom deleted the yarn-v4 branch December 18, 2024 10:14
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants