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

fix: Implement a working version of React Flagpack #72

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

zoeyfrisart
Copy link
Member

@zoeyfrisart zoeyfrisart commented Mar 29, 2024

This version implements a CLI that will auto-inject the flags into the static folder of a given project.
(Could be improved in the future to auto-detect the framework/static folder of a project)

This rework works by removing the dynamic required implementation that was not only causing issues but was also not tree-shaking correctly when looking at the resulting bundle.

This new implementation should work properly in:

  • NextJS (App and page router)
  • Create-react-app
  • Gatsby
  • Remix

Other frameworks have yet to be tested.

Also, I took the time to refactor the build process to vote instead of the roll-up.
Also exports the props interface to make the component easier to use with TypeScript

CLOSES: #69 #70 #58 #55 #47 #40
Possibly fixes: #45 & #46 but that needs more testing


This change is a breaking change that would also require changes to the flatpack website documentation (and requires changes on the user's part). I have marked this as a breaking change, which means the version will increase to 2.0.0

@zoeyfrisart zoeyfrisart added the bug Something isn't working label Mar 29, 2024
@zoeyfrisart zoeyfrisart self-assigned this Mar 29, 2024
@Yummygum Yummygum deleted a comment from CodiumAI-Agent Apr 3, 2024
@zoeyfrisart
Copy link
Member Author

@CodiumAI-Agent /review

@CodiumAI-Agent
Copy link

PR Review

⏱️ Estimated effort to review [1-5]

4, due to the extensive changes across multiple frameworks and the introduction of new functionality that requires thorough testing across different environments.

🧪 Relevant tests

No

🔍 Possible issues

Performance Concern: The implementation iterates through multiple arrays using nested loops which could lead to performance issues on pages with a large number of flags.

Code Duplication: Similar flag rendering logic is repeated across different files and frameworks (React, Next.js, Remix, Gatsby), which could be centralized to improve maintainability.

🔒 Security concerns

No

Code feedback:
relevant filetest-applications/create-react-app/src/App.js
suggestion      

Consider using React's useMemo hook to memoize the flags array to avoid recalculating it on every render, enhancing performance. [important]

relevant lineconst flags = [

relevant filetest-applications/remix/app/routes/_index.tsx
suggestion      

Extract the flag rendering logic into a separate component or custom hook to reduce code duplication and improve readability. [important]

relevant lineconst flags: Flags[] = [

relevant filetest-applications/next-app-router/src/app/page.tsx
suggestion      

Use a configuration file for flags data to simplify updates and maintenance. Import this configuration instead of hardcoding the flags array in multiple files. [medium]

relevant lineconst flags: Flags[] = [

relevant filetest-applications/test-gatsby/src/pages/index.tsx
suggestion      

Implement error handling for the Flag component rendering to gracefully handle any potential issues with flag data or rendering. [medium]

relevant line


✨ Review tool usage guide:

Overview:
The review tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be added by configuring the tool.

The tool can be triggered automatically every time a new PR is opened, or can be invoked manually by commenting on any PR.

  • When commenting, to edit configurations related to the review tool (pr_reviewer section), use the following template:
/review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=...
[pr_reviewer]
some_config1=...
some_config2=...

See the review usage page for a comprehensive guide on using this tool.

@tnmdynamiq
Copy link

Is this going to be merged at some point in the near future?🤞 @zoeyfrisart

@zoeyfrisart
Copy link
Member Author

@tnmdynamiq I certainly hope so, but it needs a review from the rest of our dev team.
I'll see if I can push for some time in the upcoming week(s) to review this pull request.

@tnmdynamiq
Copy link

@tnmdynamiq I certainly hope so, but it needs a review from the rest of our dev team. I'll see if I can push for some time in the upcoming week(s) to review this pull request.

Thank you very much for clarifying! Much appreciated, I will keep my eye out for it.

@arush
Copy link

arush commented Apr 30, 2024

would love for this to be merged soon

@zoeyfrisart zoeyfrisart requested a review from Evi-2003 May 3, 2024 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
4 participants