-
Notifications
You must be signed in to change notification settings - Fork 557
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
externalize all fo pacakges #4970
Conversation
WalkthroughThe changes in this pull request involve adding multiple import statements for modules from the Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (1)
app/packages/plugins/src/externalize.ts (1)
Line range hint
1-68
: Consider a more scalable approach to package externalizationAs the number of externalized packages grows, maintaining individual global assignments might become cumbersome. Consider implementing a more maintainable approach:
- Use a single global namespace object (e.g.,
__fiftyone__
)- Implement a package registry pattern
- Add package versioning support
This would make it easier to manage package dependencies and avoid global namespace pollution.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (1)
- app/packages/plugins/src/externalize.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/packages/plugins/src/externalize.ts (1)
Pattern
**/*.{ts,tsx}
: Review the Typescript and React code for conformity with best practices in React, Recoil, Graphql, and Typescript. Highlight any deviations.
🔇 Additional comments (1)
app/packages/plugins/src/externalize.ts (1)
1-9
: LGTM! Import statements follow consistent patternsThe new imports maintain the established naming conventions and import patterns used throughout the codebase.
window.__foa__ = foa; | ||
window.__focore__ = focore; | ||
window.__foe__ = foe; | ||
window.__fol__ = fol; | ||
window.__fom__ = fom; | ||
window.__fopb__ = fopb; | ||
window.__fosl__ = fosl; | ||
window.__fof__ = fof; | ||
window.__fol3d__ = fol3d; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding error handling for package loading
While the assignments are correct, consider wrapping them in a try-catch block to handle potential module loading failures gracefully. This would help plugin developers diagnose issues more easily.
Here's a suggested implementation:
if (typeof window !== "undefined") {
+ try {
window.__foa__ = foa;
window.__focore__ = focore;
window.__foe__ = foe;
window.__fol__ = fol;
window.__fom__ = fom;
window.__fopb__ = fopb;
window.__fosl__ = fosl;
window.__fof__ = fof;
window.__fol3d__ = fol3d;
+ } catch (error) {
+ console.error("Failed to initialize FiftyOne packages:", error);
+ throw error;
+ }
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
window.__foa__ = foa; | |
window.__focore__ = focore; | |
window.__foe__ = foe; | |
window.__fol__ = fol; | |
window.__fom__ = fom; | |
window.__fopb__ = fopb; | |
window.__fosl__ = fosl; | |
window.__fof__ = fof; | |
window.__fol3d__ = fol3d; | |
if (typeof window !== "undefined") { | |
try { | |
window.__foa__ = foa; | |
window.__focore__ = focore; | |
window.__foe__ = foe; | |
window.__fol__ = fol; | |
window.__fom__ = fom; | |
window.__fopb__ = fopb; | |
window.__fosl__ = fosl; | |
window.__fof__ = fof; | |
window.__fol3d__ = fol3d; | |
} catch (error) { | |
console.error("Failed to initialize FiftyOne packages:", error); | |
throw error; | |
} | |
} |
__foa__: typeof foa; | ||
__focore__: typeof focore; | ||
__foe__: typeof foe; | ||
__fol__: typeof fol; | ||
__fom__: typeof fom; | ||
__fopb__: typeof fopb; | ||
__fosl__: typeof fosl; | ||
__fof__: typeof fof; | ||
__fol3d__: typeof fol3d; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codebase verification
Based on the gathered information, I can now provide the final response:
Documentation needed for window globals in plugin system
The __fo*__
naming pattern is part of the plugin system's implementation but lacks documentation in the codebase. While there's a plugins package with basic documentation, it doesn't explain the window globals pattern. Specific areas needing documentation:
- The purpose of the
__fo*__
naming convention inexternalize.ts
- How these window globals are used in the plugin system
- Why this approach was chosen for plugin development
This documentation would be valuable since these globals are a core part of the plugin architecture, as evidenced by their extensive use in externalize.ts
and the plugin registry in index.ts
.
🔗 Analysis chain
Consider documenting the global namespace pattern
While the implementation is correct, consider adding a comment explaining the __fo*__
naming convention and its purpose for plugin development. This would help future maintainers understand the reasoning behind global namespace usage.
Let's verify if the naming pattern is consistently documented:
Let me search more specifically for any documentation related to these global window properties.
Let me check if there's any documentation in the plugins package or related README files.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for any existing documentation about the __fo*__ pattern
rg -i "naming|pattern|convention.*__fo" --type md
Length of output: 663
Script:
#!/bin/bash
# Search for documentation about window properties or globals
rg -i "(window\.|global).*__fo" -A 2 -B 2
# Also check TypeScript files for any comments explaining this pattern
rg -i "(window\.|global).*__fo.*\n.*\/\/" -A 2 -B 2 --type ts
Length of output: 1981
Script:
#!/bin/bash
# Check for documentation in plugins package
cat app/packages/plugins/README.md 2>/dev/null || echo "No README found"
# Search for any documentation about plugins or window globals
rg -i "plugin|window global" --type md -A 3 -B 3
Length of output: 2853
This PR adds to the list of externalized FO packages. This is relevant in JS plugin build.
Summary by CodeRabbit
Window
interface, providing access to functionalities from the@fiftyone
library.