-
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
Merge release/v1.1.0
to develop
#4971
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe changes in this pull request involve the addition of multiple import statements from the Changes
Possibly related PRs
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.
Actionable comments posted: 1
📜 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 (2)
app/packages/plugins/src/externalize.ts (2)
1-9
: LGTM! Import statements follow consistent patternsThe new imports maintain consistency with the existing codebase pattern of using namespace imports.
33-41
: Verify security implications of global module exposureWhile the type declarations are correct, exposing these modules globally increases the application's attack surface. Please ensure that:
- Only necessary modules are exposed globally
- These modules don't expose sensitive functionality
- The exposed API surface is intentionally limited
✅ Verification successful
Let me check the content of these vite.config.ts files to understand how these modules are being used.
Let me check where these modules are actually defined and how they're being exposed to understand the security implications better.
Let me check how these modules are being used in the plugin system to understand if this global exposure is necessary for the plugin architecture.
Global module exposure is necessary and properly implemented for plugin architecture
The global exposure of these modules is an intentional and necessary part of the plugin architecture:
- The exposure is handled in a controlled manner within the plugins package (
app/packages/plugins/src/externalize.ts
)- The naming convention with double underscores is consistently applied to prevent naming collisions
- The modules are only exposed when used as part of the plugin system, as evidenced by:
- Usage in vite.config.ts files for plugin builds only (
isPluginBuild
condition)- Proper TypeScript declarations ensuring type safety
- Modules are exposed to ensure plugins use the same instance of dependencies
The implementation follows plugin architecture best practices by sharing core dependencies to avoid duplicate instances and maintain consistency across plugins.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check if these modules are only used by plugins # If they're used directly in the main application, they shouldn't be exposed globally echo "Checking usage of exposed modules in non-plugin code..." rg -g '!app/packages/plugins/**' -l '__fo[a|core|e|l|m|pb|sl|f|l3d]__'Length of output: 337
Script:
#!/bin/bash # Check the context of usage in vite config files echo "Content of vite.config.ts files:" for file in app/packages/spaces/vite.config.ts app/packages/map/vite.config.ts app/packages/embeddings/vite.config.ts app/packages/looker-3d/vite.config.ts; do echo -e "\n=== $file ===\n" cat "$file" doneLength of output: 5038
Script:
#!/bin/bash # Check for the module definitions and their exposure echo "Searching for module definitions and exposure..." rg -g '!*.{json,md}' -C 2 "window\.__fo[a|core|e|l|m|pb|sl|f|l3d]__"Length of output: 1423
Script:
#!/bin/bash # Check the plugin system's usage of these modules echo "Checking plugin system architecture..." rg -g 'app/packages/plugins/**' -C 3 "import.*@fiftyone/" # Also check the main plugin file echo -e "\nChecking main plugin file content:" cat app/packages/plugins/src/externalize.tsLength of output: 4756
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 refactoring global assignments for better maintainability
While the implementation is correct, maintaining parallel lists of imports, interface declarations, and assignments can be error-prone. Consider creating a mapping object to reduce duplication:
const moduleMap = {
__foa__: foa,
__focore__: focore,
// ... other modules
} as const;
declare global {
interface Window {
// Use the moduleMap to generate types
[K in keyof typeof moduleMap]: typeof moduleMap[K]
}
}
if (typeof window !== "undefined") {
Object.assign(window, moduleMap);
}
This approach would:
- Reduce maintenance overhead
- Ensure consistency between types and runtime
- Make it easier to add/remove exposed modules
Merge
release/v1.1.0
todevelop
Summary by CodeRabbit
New Features
@fiftyone
library, enhancing functionality in the browser environment.Bug Fixes