feat: enhance HoistContainerReferencesPlugin for better module hoisting#3903
Merged
ScriptedAlchemy merged 33 commits intomainfrom Jul 18, 2025
Merged
feat: enhance HoistContainerReferencesPlugin for better module hoisting#3903ScriptedAlchemy merged 33 commits intomainfrom
ScriptedAlchemy merged 33 commits intomainfrom
Conversation
- Separate handling for container, federation, and remote dependencies - Improved support for runtimeChunk: 'single' configuration - Proper remote module hoisting using the new addRemoteDependency hook - Simplified cleanup logic for better performance - Changed runtime chunk detection to include all chunks with runtime - Added comprehensive unit tests
🦋 Changeset detectedLatest commit: 2cf38f1 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 |
…oist-container-refs
2heal1
approved these changes
Jul 15, 2025
✅ Deploy Preview for module-federation-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
- Add browser caching for Playwright and Cypress - Add explicit Cypress installation step - Add PLAYWRIGHT_CACHE_HIT environment variable - Add warm Nx cache step - Use --parallel=4 for faster builds - Align with build-and-test workflow strategy
- Add addRemoteDependency hook calls in RemoteModule.ts build method - Ensures HoistContainerReferencesPlugin can properly track remote dependencies - Calls hook for both RemoteToExternalDependency and FallbackDependency - Brings current branch in sync with share-filter branch hook implementations
- Update tsconfig.json to use TypeScript project references structure - Create missing tsconfig.lib.json and tsconfig.spec.json files - Update project.json to use tsconfig.lib.json and add external dependencies - Fix missing return statement in isStoryBook function - Fix NODE_ENV access to use bracket notation for strict mode - Brings rsbuild-plugin build configuration in line with other rollup packages
The main entry was pointing to the wrong path (packages/rsbuild-plugin/cli/src/index.ts) when it should be packages/rsbuild-plugin/src/cli/index.ts. This was causing TypeScript compilation errors during the build process.
…nfig Similar to how SDK and other packages handle it, explicitly set the external array in rollup config to ensure proper handling of workspace dependencies during TypeScript compilation.
- Add missing "types" field to package.json (like rspack and sdk have) - Add "noImplicitAny": false to tsconfig.json to match rspack's config - This should help TypeScript resolve workspace dependencies correctly
Use path.resolve with process.cwd() to create absolute paths for the input files, matching how other packages like rspack handle their rollup configuration.
Match the path format used by other packages like data-prefetch which use 'packages/package-name/src/...' relative paths.
…lution The root cause was manually overriding rollupConfig.external which broke nx's automatic workspace dependency resolution mechanism. By removing this override and letting nx handle externals via project.json, TypeScript can now properly resolve workspace dependencies during the rollup build. This aligns rsbuild-plugin with working packages like cli and data-prefetch that don't manually override external configuration.
Remove dep-graph.json and deps.json files that were accidentally committed during the investigation process.
Add explicit TypeScript path mappings in tsconfig.json to help the TypeScript compiler resolve workspace dependencies during CI builds. This should resolve the module resolution issues in stricter CI environments.
- Build SDK with skip cache first to ensure workspace dependencies are available - Then build all packages with normal caching to resolve TypeScript module resolution issues - This ensures workspace packages are properly built and available for dependent packages
Update the RemoteModule test build describe block to properly mock the FederationModulesPlugin.getCompilationHooks method to match the implementation on share-filter branch. This resolves the TypeError about compilation argument validation.
Add comment to force CI to rebuild modernjs package which was missing files.
4 tasks
Ensure proper cleanup of module mocks between test runs to prevent compilation instance validation errors.
Replace instance-level mocking with module-level mocking to avoid webpack Compilation instance validation errors.
Fix the mock to directly export the plugin instead of wrapping it in a default property, matching the actual default import pattern.
Trigger another build attempt to resolve missing dist files in CI.
Reduce parallel build workers in devtools workflow to prevent race conditions and improve build reliability.
Allow the warm cache step to use cache for better performance while keeping skip cache only for the main build step.
- Resolved conflict in .github/workflows/build-and-test.yml - Kept main branch version as requested
- Remove Warm Nx Cache step - Keep Run Affected Build with --skip-nx-cache flag - Maintain all other cache configurations
- Remove CI fix comment from packages/modernjs/src/constant.ts - Remove added comments from packages/rsbuild-plugin/rollup.config.js - Reset packages/rsbuild-plugin/tsconfig.json paths to match main branch - Keep extends and references in tsconfig.json
6ae92a4 to
787ba92
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
runtimeChunk: 'single'configurationaddRemoteDependencyhookKey Improvements
addRemoteDependencyhookFiles Changed
packages/enhanced/src/lib/container/HoistContainerReferencesPlugin.ts- Enhanced implementationpackages/enhanced/test/compiler-unit/container/HoistContainerReferencesPlugin.test.ts- New unit tests