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

Tree Shaking [1000 USDC Reward!] #2566

Open
MaxMillington opened this issue Dec 15, 2023 · 13 comments
Open

Tree Shaking [1000 USDC Reward!] #2566

MaxMillington opened this issue Dec 15, 2023 · 13 comments
Labels
Bounty Anyone who can ship a fix to these issues will be awarded OSMO as a thank you!

Comments

@MaxMillington
Copy link
Collaborator

MaxMillington commented Dec 15, 2023

πŸ› Bug Bounty: Tree Shaking Optimization Needed! πŸ› οΈ
Reward: πŸ† 1000 USDC πŸ†

We are thrilled to announce a special bug bounty for proficient third-party developers! This is an opportunity to showcase your expertise, make a significant impact, and earn a substantial reward.

Issue Description πŸ“„
Inefficient Tree Shaking in Next.js Application

Current Behavior ❌
Our Next.js application is currently importing libraries that are not in use due to ineffective tree shaking. This results in an unnecessarily large bundle size, affecting performance and efficiency.

Expected Behavior πŸ’‘
Implement an optimized tree shaking process to ensure only the necessary libraries are included in the final bundle. The goal is to significantly reduce the bundle size without compromising functionality.

Requirements for the Bounty 🏁

Submit a pull request with a verified solution to optimize tree shaking.
Demonstrate a measurable decrease in the bundle size as a result of your optimization.
Ensure the fix does not introduce any new bugs or vulnerabilities.
Adhere to our project's coding style and contribution guidelines.
Your solution will undergo a thorough review by our team, and the bounty will be awarded upon approval.

How to Claim Your Bounty πŸ’°

Fork our repository.
Create a new branch dedicated to your optimization fix.
Submit a pull request to our main branch with comprehensive details of your optimization strategy and evidence of the reduced bundle size.

Upon review and approval, the 1000 USDC will be transferred to your wallet.

Please Note: All bounty claimants must undergo a KYC (Know Your Customer) process with our finance team to receive the reward. This is a mandatory step to ensure compliance with financial regulations.

We eagerly await your innovative solutions and thank you for contributing to the efficiency and performance of our project!

@MaxMillington MaxMillington added the Bounty Anyone who can ship a fix to these issues will be awarded OSMO as a thank you! label Dec 15, 2023
@isreallee82
Copy link

for some reason I couldn't build the project @MaxMillington here is a screenshot
Screenshot 2023-12-18 at 1 58 48 AM

I dont know if I am doing something wrong

@MaxMillington
Copy link
Collaborator Author

@isreallee82 give it another try. should be able to build and run from stage branch

@isreallee82
Copy link

yes thanks @MaxMillington I guess there was an issue with my enviroment worked on codespace

@BrianCraig
Copy link

Hi!

Analyzing the Next.js application's performance and bundle size, I've identified a critical aspect that seems to heavily influence the initial load and bundle size. Upon reviewing the application's loading metrics, I've noticed a significant portion of the bundle size attributed to the _app.tsx file, which appears to be highly coupled with multiple dependencies.

Considering the statistics below:

Route (pages) Size First Load JS
β”Œ ● / 923 B 2.09 MB
β”œ /_app 0 B 2.09 MB
β”œ β—‹ /404 (582 ms)                                       448 B          2.09 MB
β”œ β—‹ /500 (550 ms)                                       444 B          2.09 MB
β”œ Ξ» /api/active-gauges                                  0 B            2.09 MB
β”œ Ξ» /api/bridge-transfer/quotes                         0 B            2.09 MB
β”œ Ξ» /api/bridge-transfer/quotes/[bridge]                0 B            2.09 MB
β”œ Ξ» /api/bridge-transfer/transaction-requests/[bridge]  0 B            2.09 MB
β”œ Ξ» /api/broadcast-transaction                          0 B            2.09 MB
β”œ ℇ /api/edge-trpc/[trpc]                               0 B            2.09 MB
β”œ ℇ /api/pools                                          0 B            2.09 MB
β”œ ℇ /api/pools/[id]                                     0 B            2.09 MB
β”œ Ξ» /api/router/token-out-given-in                      0 B            2.09 MB
β”œ Ξ» /api/simulate-transaction                           0 B            2.09 MB
β”œ Ξ» /api/trpc/[trpc]                                    0 B            2.09 MB
β”œ ● /apps (ISR: 86400 Seconds) (554 ms)                 186 B          2.09 MB
... (other routes omitted for brevity)

  First Load JS shared by all 2.11 MB
  β”œ chunks/7056-995831a93aefcb61.js 82.6 kB
  β”œ chunks/7101-1b1047194f005759.js 2 MB
  ... (other chunks omitted for brevity)

The _app.tsx file seems to contribute significantly to the overall bundle size, making the initial load substantial and potentially impacting performance. I'm considering a strategy that involves decoupling _app.tsx from unnecessary dependencies and optimizing its structure to facilitate more effective tree shaking.

Before proceeding further with this approach, I wanted to seek confirmation if such solution would be considered as enough to solve the bounty.

Thank you, Brian.

@MaxMillington
Copy link
Collaborator Author

Hi Brian!

Apologies for the slow reply, we were out last week!

Your approach is reasonable. We are aiming to reduce the bundle size by at least 30%

@Nightrider0098
Copy link

Is this issue still open? @MaxMillington

@MaxMillington
Copy link
Collaborator Author

@Nightrider0098 Yes.

@Nightrider0098
Copy link

Will try to work on this. And try to remove or load library dynamically.

@Nightrider0098
Copy link

The first load file is about 2.12 MB(/static/chunks/_app-*.js). Bundle analyser show this data
image

Can we declare our own type definitions and make our libraries like [proto-codecs] tree shakable ?

@MaxMillington
Copy link
Collaborator Author

@Nightrider0098 yes, one strategy would to be replace some of these with our own smaller bundles

@Nightrider0098
Copy link

What is the expected size for the final initial-load file?

@MaxMillington
Copy link
Collaborator Author

@Nightrider0098 we are aiming to reduce the bundle size by at least 30%

@jonator
Copy link
Member

jonator commented Mar 29, 2024

We believe tree shaking is now working from server and stores package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bounty Anyone who can ship a fix to these issues will be awarded OSMO as a thank you!
Projects
None yet
Development

No branches or pull requests

5 participants