|
| 1 | +--- |
| 2 | +description: |
| 3 | +globs: |
| 4 | +alwaysApply: true |
| 5 | +--- |
| 6 | +# Module Federation Runtime Core Implementation |
| 7 | + |
| 8 | +## Source Code Structure |
| 9 | + |
| 10 | +The implementation is organized into several key modules in [src/](mdc:packages/runtime-core/src/): |
| 11 | + |
| 12 | +### Core Runtime |
| 13 | + |
| 14 | +- [core.ts](mdc:packages/runtime-core/src/core.ts): Core runtime implementation |
| 15 | +- [global.ts](mdc:packages/runtime-core/src/global.ts): Global state management |
| 16 | +- [index.ts](mdc:packages/runtime-core/src/index.ts): Public API exports |
| 17 | +- [helpers.ts](mdc:packages/runtime-core/src/helpers.ts): Utility functions |
| 18 | + |
| 19 | +### Module System |
| 20 | + |
| 21 | +- [module/](mdc:packages/runtime-core/src/module/): Module management |
| 22 | +- [remote/](mdc:packages/runtime-core/src/remote/): Remote module handling |
| 23 | +- [shared/](mdc:packages/runtime-core/src/shared/): Shared module system |
| 24 | + |
| 25 | +### Plugin System |
| 26 | + |
| 27 | +- [plugins/](mdc:packages/runtime-core/src/plugins/): Plugin architecture |
| 28 | +- [type/](mdc:packages/runtime-core/src/type/): Type definitions |
| 29 | +- [utils/](mdc:packages/runtime-core/src/utils/): Utility functions |
| 30 | + |
| 31 | +## Implementation Guidelines |
| 32 | + |
| 33 | +When working with this codebase: |
| 34 | + |
| 35 | +1. **Core Runtime** |
| 36 | + - Maintain backward compatibility |
| 37 | + - Handle global state carefully |
| 38 | + - Follow error handling patterns |
| 39 | + - Document runtime behaviors |
| 40 | + |
| 41 | +2. **Module Management** |
| 42 | + - Implement proper module loading |
| 43 | + - Handle circular dependencies |
| 44 | + - Manage module lifecycle |
| 45 | + - Support hot reloading |
| 46 | + |
| 47 | +3. **Plugin System** |
| 48 | + - Follow plugin interface |
| 49 | + - Maintain extensibility |
| 50 | + - Document plugin hooks |
| 51 | + - Handle plugin errors |
| 52 | + |
| 53 | +4. **Testing Requirements** |
| 54 | + - Test core runtime features |
| 55 | + - Cover plugin scenarios |
| 56 | + - Test module loading |
| 57 | + - Verify error handling |
| 58 | + |
| 59 | +## Architecture Principles |
| 60 | + |
| 61 | +1. **Modularity** |
| 62 | + - Keep components isolated |
| 63 | + - Use clear interfaces |
| 64 | + - Follow single responsibility |
| 65 | + |
| 66 | +2. **Performance** |
| 67 | + - Optimize module loading |
| 68 | + - Minimize runtime overhead |
| 69 | + - Efficient dependency sharing |
| 70 | + |
| 71 | +3. **Reliability** |
| 72 | + - Handle edge cases |
| 73 | + - Proper error recovery |
| 74 | + - Maintain stability |
0 commit comments