Repository navigation
Closed
Labels
AutoAssignerAppLibraryReviewAuto assign someone to review a new library being added to AppAwaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2
Description
In order to properly evaluate if a new library can be added to package.json, please fill out this request form. It will be automatically assigned someone from our review team that will go through and vet the library.
In order to add any new production dependency, it must be approved by the App Deployer team. They will evaluate the library and decide if it's something we want to move forward with or if other alternatives should be explored.
Note: This is only for production dependencies. While we don't want people to add packages to dev-dependencies willy-nilly, we recognize that there isn't as great of a need there to secure them.
Name of library: Moize
Details
- Link to package: https://github.com/planttheidea/moize
- Problem solved by using this package: App as of now, does not have a standardized way of handling memoization outside of React. It boils down to using custom-made solutions like Maps or serialization. This is a problem because engineers implementing and reviewing solutions for memoization outside of React have to sink time into writing and creating a custom solution that may not be consistent with other places in the codebase. This leads to inconsistency, overhead, and at times sub-optimal solutions.
- Number of stars in GH: 880
- Number of monthly downloads: 222,725 weekly!
- Number of releases in the last year: 5
- Level of activity in the repo: 17 contributors, 313 deployments, 3 issues, 6 PRs
- Alternatives: List of alternatives and benchmarks
- Are security concerns brought up and addressed in the library's repo? No
- How many dependencies does this lib use that will be brought into our code? At most 1 (It uses 2 deps:
fast-equalsandmicro-memoizebutfast-equalsis already used, not sure aboutmicro-memoize) - What will the effect be on the bundle size of our code? Bundlephobia report of current moize version
Issue Owner
Current Issue Owner: @puneetlathReacted by Tim Golen
Metadata
Metadata
Labels
AutoAssignerAppLibraryReviewAuto assign someone to review a new library being added to AppAwaiting PaymentAuto-added when associated PR is deployed to productionDailyKSv2
Activity
melvin-bot commentedon May 15, 2024
Triggered auto assignment to @puneetlath (
AutoAssignerAppLibraryReview), see https://stackoverflowteams.com/c/expensify/questions/17737 for more details.melvin-bot commentedon May 15, 2024
New Library Review
Once these questions are answered, start a thread in #engineering-chat, ping the
@app_deployersgroup, and call for a vote to accept the new library. Once the vote is complete, update this issue with the outcome and procede accordingly. Here is a sample post:roryabraham commentedon May 15, 2024
After researching this, one of the things I like about moize is how the base API is extremely simple, but it's also configurable for just about any kind of memoization you might need.
puneetlath commentedon May 15, 2024
Can you give some examples of such scenarios and where we encounter this problem?
roryabraham commentedon May 15, 2024
Here are just a few examples of different caching solutions we've built ad-hoc:
App/src/libs/Localize/index.ts
Lines 68 to 73 in f5cf3fb
App/src/libs/PersonalDetailsUtils.ts
Lines 27 to 32 in 22f6d15
A case study I was involved with can be found in this PR. The diff in
src/libs/Localize/index.tscould have been reduced to this:and lots of discussion could have been avoided with this standardization.
janicduplessis commentedon May 16, 2024
Other case I added recently that could use this
App/src/components/ThumbnailImage.tsx
Line 19 in e8ae3c5
puneetlath commentedon May 20, 2024
@kacper-mikolajczak can you please post this in the #expensify-open-source channel in problem/solution format along with all the information provided in the OP? And cc @app-deployers on it. Thank you!
kacper-mikolajczak commentedon May 22, 2024
Sure thing @puneetlath! Here is a P/S post.
tgolen commentedon May 22, 2024
From looking at https://github.com/planttheidea/moize/releases, it looks like the last release was May 2023, last year. Correct?
puneetlath commentedon May 23, 2024
Looks like the discussion is ongoing.
kacper-mikolajczak commentedon Jun 4, 2024
Proposal
Intro
Goal of the proposal is to find API for a future memoization standard. By looking at the current use-cases in the codebase, we will try to distill minimal API surface which is going to be used for the implementation.
Examples
Lodash
memoizehelpersThere are two instances of lodash
memoizehelper in the app. Both of them are meant to be replaced with suggested solution.The
getEmojiUnicodehelper has simple API with just one input, so it is going to be straightforward to replace it. No extra requirements.App/src/libs/EmojiUtils.ts
Line 69 in 92a7b15
Same goes for second use-case which is
getLocaleDigits.App/src/libs/LocaleDigitUtils.ts
Line 16 in 92a7b15
Intl-like modules
Intlas a module needs to be memoized in order not to re-create new instances on every call (especially when used in a iteration with same configuration, e.g. rendering list of components).#40341
This use-case requires deep comparison of arguments, because options passed to Intl methods are possibly going to be the same across the app, but have different references.
Maps
Many samples of using Maps were provided, like ones below:
App/src/libs/Localize/index.ts
Line 67 in 92a7b15
Based on those examples we would need to employ value caching mechanism (instead of function caching) which could be achieved by overloading
memoizeAPI or creating a separate likeCache.Requirements
Here are additional concerns and requirements that were discovered either during discussion or exploration of similar solutions (moize, memoizee etc.):
Conclusion
Based on findings above and recent discussion, we can conclude that in simplest form the API could look like it:
In the next comment I will add information about possible implementation obstacles. Let me know what you think, thanks!
25 remaining items
[-]Moize - general purpose memoization tool[/-][+][HOLD for payment 2024-08-02] Moize - general purpose memoization tool[/+]melvin-bot commentedon Jul 26, 2024
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Jul 26, 2024
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.12-0 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2024-08-02. 🎊
For reference, here are some details about the assignees on this issue:
puneetlath commentedon Jul 26, 2024
Adding @mananjadhav as it looks like they were the C+ here.
melvin-bot commentedon Aug 2, 2024
Payment Summary
Upwork Job
BugZero Checklist (@puneetlath)
puneetlath commentedon Aug 2, 2024
Payment summary:
JmillsExpensify commentedon Aug 3, 2024
$250 approved for @mananjadhav