How andrecrjr/module-federation-explorer works
Main Components Identification
• VS Code Extension Host & Activation: At the heart of the extension is the activation process (see src/index.ts). This module bootstraps the extension once a workspace with the appropriate Module Federation configuration is opened.
• Configuration Detection & Extraction: The extension auto-detects configuration files using components such as src/configExtractors.ts. This is where it scans for files like webpack.config.js, vite.config.js, or module-federation.config.js and extracts settings.
• Output & Communication: With src/outputChannel.ts, the project establishes communication with the VS Code UI (for output logging and status indicators).
• Unified Tree Provider & UI Integration: The src/unifiedTreeProvider.ts, along with the media/styles.css, supports the construction of the visual tree view in the VS Code explorer sidebar, ensuring that module remotes and hosts are dynamically rendered.
• Root Configuration Management: Managed via src/rootConfigManager.ts, this component is responsible for persisting configuration data (e.g., in the .vscode/mf-explorer.roots.json file).
Architectural Relationships and Interactions
• The VS Code runtime environment triggers the activation (index.ts), which then initializes and coordinates the other components.
• The configuration extractor reads and interprets the workspace’s module federation configuration files and passes that data to both the unified tree provider and dependency graph modules.
• The unified tree provider updates the VS Code explorer view, allowing users to interact with hosts and remotes. In turn, UI actions (via context menus and commands) trigger operations in the configuration manager or output channel.
• The output channel module is used to relay status updates back to the user, ensuring feedback for operations like starting/stopping remotes or hosts.
• The dependencyGraph module interacts with the configuration extractor’s data to build a visual representation of dependencies via a directed graph.
Architectural Patterns and Design Principles
• Component Separation: The system is neatly divided into functional areas (configuration extraction, UI update, state management, and dependency visualization).
• Event-Driven / Command Pattern: The extension uses commands (as detailed in the README) to drive user interactions.
• Modularity: Each file in the /src folder represents a distinct functionality, making it easier to maintain or extend parts of the project independently.
• Integration with External VS Code APIs: The extension leverages VS Code’s APIs to embed its functionality (e.g., tree view and command contributions) fully within the editor.