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

Optimize browser bundle for faster loading #105

Merged

Conversation

Ryoko619
Copy link
Contributor

I solved #92

@mhchia
Copy link
Member

mhchia commented Sep 22, 2023

Looks good, thanks for the contribution! Could you rebase to the main branch again? Lint CI failed and I just fixed it in the main branch

@mhchia
Copy link
Member

mhchia commented Sep 22, 2023

Also, could you help me to confirm how much size it has decreased, before and after using terser?

@Ryoko619
Copy link
Contributor Author

Thank you. Got it!
File size before the changes: 3.2MB
File size after the changes: 2.0MB

Copy link
Member

@mhchia mhchia left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Great work! :) I've left some comments. Please help me remove directories dist, examples/browser/dist, and examples/browser/public since they shouldn't be included in the codebase.

package.json Outdated
@@ -72,6 +72,7 @@
"ethers": "^6.4.0",
"ffjavascript": "0.2.55",
"poseidon-lite": "^0.0.2",
"rlnjs": "^3.2.3",
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
"rlnjs": "^3.2.3",

This shouldn't be required

package.json Outdated
@@ -97,6 +98,7 @@
"rollup-plugin-polyfill-node": "^0.12.0",
"rollup-plugin-typescript2": "^0.34.1",
"rollup-plugin-visualizer": "^5.9.0",
"rollup-plugin-terser": "*",
Copy link
Member

@mhchia mhchia Sep 25, 2023

Choose a reason for hiding this comment

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

I've just found rollup-plugin-terser is deprecated. Can we use @rollup/plugin-terser instead and pin the version ^0.4.3?

Suggested change
"rollup-plugin-terser": "*",
"@rollup/plugin-terser": "^0.4.3",

@mhchia mhchia linked an issue Sep 25, 2023 that may be closed by this pull request
@Ryoko619
Copy link
Contributor Author

Yes, I got it!

@mhchia
Copy link
Member

mhchia commented Sep 27, 2023

@Ryoko619 Can you also remove examples/browser/dist and rebase this branch onto the main branch? Feel free to let me know if there is anything I can help too. Thank you :)

@Ryoko619
Copy link
Contributor Author

I'm sorry for the repetition. Is it done?

@mhchia
Copy link
Member

mhchia commented Sep 28, 2023

@Ryoko619 Sorry, I didn't notice that we should add terser in rlnjs/rollup.config.mjs instead of rlnjs/examples/browser/rollup.config.mjs. So we have two things left that should be done:

  1. Use terser in rlnjs/rollup.config.mjs
  2. Rebase this branch onto the main branch, since there are conflicts between this branch and the main branch

To rebase, we can do something like this

# Under rlnjs project root
git fetch origin
git checkout feat/minimize_rlnjs_bundle
git rebase main
# Solve the conflicts
...
git push 

@mhchia
Copy link
Member

mhchia commented Sep 28, 2023

Can I fix it based on your contribution? Sorry for the inconvenience

@Ryoko619
Copy link
Contributor Author

Ryoko619 commented Oct 2, 2023

I apologize for any inconvenience caused. I rebased onto the main branch, but I couldn't resolve the issue. What should I do next?

@mhchia
Copy link
Member

mhchia commented Oct 2, 2023

Hey @Ryoko619 , no worries at all! It's just examples/browser/* are removed so your changes are not working now. Could you try the steps below? I think it may be easier to make new commits on top of the latest main branch instead of rebasing.

  1. Update the main branch in your local environment
git checkout main
git pull origin main
  1. Check out a new branch
git checkout -b feat/minimize_rlnjs_bundle_new
  1. Make your changes

Install terser and add terser in rlnjs/rollup.config.mjs.

  1. Commit and push your new branch to your remote repo as feat/minimize_rlnjs_bundle

You may need to do it with git push -f. Let me know if you encounter any issue :)

@Ryoko619
Copy link
Contributor Author

Ryoko619 commented Oct 3, 2023

Thank you very much once again.
I think I have successfully pushed 'feat/minimize_rlnjs_bundle_new' to the remote branch, but can you confirm if it was done correctly?

@mhchia
Copy link
Member

mhchia commented Oct 3, 2023

Ah and can you overwrite the branch feat/minimize_rlnjs_bundle#92 with your feat/minimize_rlnjs_bundle_new so that this pull request is updated with your latest branch? It should be done with the following command

git push -f origin feat/minimize_rlnjs_bundle_new:feat/minimize_rlnjs_bundle#92

@Ryoko619 Ryoko619 force-pushed the feat/minimize_rlnjs_bundle#92 branch from ecafc53 to d38dfff Compare October 3, 2023 08:39
@Ryoko619
Copy link
Contributor Author

Ryoko619 commented Oct 3, 2023

Sorry, another conflict has occurred.

@mhchia
Copy link
Member

mhchia commented Oct 3, 2023

@Ryoko619 No worries! I've rebased your branch onto the main branch. Check out this branch. Can you clone that branch ryoko619-minimize_bundle and push to your feat/minimize_rlnjs_bundle#92 again? and this PR should have been rebased correctly.

Get the rebased branch from RLNjs repo

# Fetch all branch from RLNjs repo
git remote add upstream [email protected]:Rate-Limiting-Nullifier/rlnjs.git
git fetch upstream
git checkout ryoko619-minimize_bundle-rebased

Push the rebased branch to your remote repo and thus update the pull request

# Assume origin is your remote repo. 
git push -f origin ryoko619-minimize_bundle-rebased:feat/minimize_rlnjs_bundle#92

@Ryoko619 Ryoko619 force-pushed the feat/minimize_rlnjs_bundle#92 branch from d38dfff to b905aa6 Compare October 4, 2023 13:25
@mhchia mhchia merged commit 4ed3496 into Rate-Limiting-Nullifier:main Oct 4, 2023
1 of 3 checks passed
@mhchia
Copy link
Member

mhchia commented Oct 4, 2023

@Ryoko619 Great work! Thanks a lot for your contribution 🙏

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.

Minimize RLNjs bundle
2 participants