-
-
Notifications
You must be signed in to change notification settings - Fork 349
feat(enhanced): add include/exclude filtering support for shared modules #3949
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
Conversation
Implements basic share filtering functionality for ConsumeSharedPlugin and ProvideSharedPlugin, allowing fine-grained control over which shared modules are consumed or provided based on version requirements and request patterns. Features: - Version filtering with semver version requirements - Request filtering with string/RegExp patterns - Singleton warnings for filtered singleton modules - Comprehensive unit tests and config test cases 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Fixes webpack import patterns in utils.ts: - Import types directly from webpack - Import runtime values using normalizeWebpackPath 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 387a5a5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…nto feat/enhanced-share-filtering
Previously, the version filtering logic incorrectly compared version ranges against other version ranges (e.g., "^1.2.0" vs "^1.0.0") instead of reading actual module versions from package.json files. **Changes:** - Replace synchronous version range comparison with async module resolution - Use getDescriptionFile() to read actual module versions from package.json - Implement proper semver filtering: satisfy(actualVersion, filterVersion) - Add comprehensive error handling for missing package.json or version fields - Update test expectations to reflect the corrected behavior - Add extensive unit test coverage for filtering functionality **Technical Implementation:** - Use path.dirname(importResolved) to locate module directory - Read data['version'] from resolved package.json for actual version - Maintain proper async Promise chains for module resolution - Preserve all existing functionality while fixing the core bug **Results:** - ✅ All 385 tests passing (including 7 consume-filters integration tests) - ✅ Version filtering now works correctly with actual module versions - ✅ No breaking changes to existing API or behavior - ✅ Implementation aligns with share-filter branch design Fixes the version filtering bug documented in consume-filters test warnings. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
…ucture - Add node_modules structure to provide-filters test for package.json version resolution testing - Update consume-filters test configuration to handle expected warnings/errors - Fix inject-external-runtime-core-plugin rollup config to use modern TypeScript plugin - Ensure both consume-filters and provide-filters tests can validate version filtering functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix consume-filters test warnings.js to expect correct warning patterns - Fix consume-filters test errors.js to match actual webpack error format - Add missing warnings.js and errors.js files for provide-filters test - All enhanced package tests now pass (262/262) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Enhanced Share Filtering ArchitectureThis diagram illustrates the architectural components and relationships for the enhanced shared module filtering feature. Architecture Graphgraph TB
subgraph "Module Federation Enhanced Plugin"
MFP[ModuleFederationPlugin]
MFP --> CSP[ConsumeSharedPlugin]
MFP --> PSP[ProvideSharedPlugin]
end
subgraph "Consume Side (ConsumeSharedPlugin)"
CSP --> CSM[ConsumeSharedModule]
CSP --> CSD[ConsumeSharedDependency]
CSP --> CSRF[ConsumeSharedRuntimeModule]
CSM --> VF[Version Filtering Logic]
CSM --> RF[Request Filtering Logic]
VF --> IVF[Include Version Filter]
VF --> EVF[Exclude Version Filter]
RF --> IRF[Include Request Filter]
RF --> ERF[Exclude Request Filter]
IVF --> SATISFY[satisfy function]
EVF --> SATISFY
CSM --> GDF[getDescriptionFile]
GDF --> PKG[package.json]
end
subgraph "Provide Side (ProvideSharedPlugin)"
PSP --> PSD[ProvideSharedDependency]
PSP --> PSM[ProvideSharedModule]
PSP --> PSMF[ProvideSharedModuleFactory]
PSP --> PVF[Provider Version Filter]
PSP --> PRF[Provider Request Filter]
end
subgraph "Shared Utilities"
SATISFY --> SEMVER[Semver Comparison]
UTILS[utils.ts] --> SATISFY
UTILS --> WARN[addSingletonFilterWarning]
UTILS --> MATCH[matchesFilter]
end
subgraph "Configuration"
CONFIG[Shared Config] --> FILTER[Filter Options]
FILTER --> INCLUDE[include - version and request]
FILTER --> EXCLUDE[exclude - version and request]
FILTER --> SINGLETON[singleton boolean]
end
subgraph "Runtime Behavior"
CSM --> FALLBACK[Fallback Module]
CSM --> SHARED[Shared Module]
CSM --> WARNING[Webpack Warning]
CSM --> ERROR[Module Not Found Error]
FALLBACK --> MODULE[Loaded Module]
SHARED --> MODULE
end
subgraph "Test Infrastructure"
TEST[Config Test Cases] --> CF[consume-filters]
TEST --> PF[provide-filters]
CF --> NM1[node_modules]
PF --> NM2[node_modules]
NM1 --> MOCK1[Mock Packages with package.json]
NM2 --> MOCK2[Mock Packages with package.json]
end
CONFIG --> CSP
CONFIG --> PSP
WARNING --> WARN
PKG --> VF
style MFP fill:#e3f2fd
style CSP fill:#e8f5e9
style PSP fill:#e8f5e9
style SATISFY fill:#fff3e0
style WARNING fill:#fff9c4
style ERROR fill:#ffebee
style MODULE fill:#e8f5e9
style TEST fill:#f3e5f5
Component RelationshipsCore Components
Filtering Components
Data Flowgraph LR
subgraph "Configuration Input"
A[webpack.config.js] --> B[shared config]
B --> C[Module with Filters]
end
subgraph "Processing"
C --> D[Plugin Initialization]
D --> E[Module Resolution]
E --> F[Filter Evaluation]
F --> G[Version Check]
F --> H[Request Check]
end
subgraph "Output"
G --> I{Pass}
H --> I
I -->|Yes| J[Use Shared Module]
I -->|No| K[Use Fallback or Error]
K --> L[Generate Warning]
end
style A fill:#e3f2fd
style J fill:#c8e6c9
style K fill:#ffcdd2
style L fill:#fff9c4
Key Interactions
File Structure
|
…ing feature 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Perfect, i want it for a long time ! |
Sorry it took so long, it was stuck in the other branch, but in fairness - i found a few bugs in the process. So probbably better i didnt split it into its own PR from the start. |
- Resolved changeset file conflicts by accepting deletions from main - Updated package versions and changelogs from latest main branch - Preserved enhanced share filtering feature changes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
Implements basic share filtering functionality for ConsumeSharedPlugin and ProvideSharedPlugin, allowing fine-grained control over which shared modules are consumed or provided based on version requirements and request patterns.
Extracted from PR #3904 - focusing only on the enhanced package changes
Features Added
Technical Implementation
ConsumeSharedPlugin
with version and request filtering logicProvideSharedPlugin
with version and request filtering logictestRequestFilters
utility for request pattern matchingaddSingletonFilterWarning
utility for singleton filter warningsTest Plan
Files Changed
🤖 Generated with Claude Code