Repository navigation
Conversation
📦 Binary Size-limit
❌ Size increased by 28.00KB from 68.58MB to 68.61MB (⬆️0.04%) |
Merging this PR will improve performance by 2.18%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | rust@create_named_chunk_ids |
2.9 ms | 2.9 ms | +2.18% |
Tip
Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/mf-ssr-clear-cache (8e63776) with main (59e2544)
Footnotes
-
47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
b342f63 to
241134f
Compare
Rsdoctor Bundle Diff AnalysisFound 5 projects in monorepo, 0 projects with changes. 📊 Quick Summary
Generated by Rsdoctor GitHub Action |
dbf6a50 to
cb6bd31
Compare
3b1a219 to
1f63da4
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99709aee70
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (consumer_module_identifier, consumer_module_id) in &consumer_modules { | ||
| add_to_mapping( | ||
| &mut consumer_module_id_to_parent_module_ids, | ||
| consumer_module_id.clone(), | ||
| get_parent_module_ids(compilation, module_graph, consumer_module_identifier), |
There was a problem hiding this comment.
Populate parent metadata transitively
When a remote is consumed through more than one synchronous local layer, this only records parents for the direct remote consumers returned by get_consumer_modules. For a chain like entry -> route -> page -> remoteA, the metadata can expose page -> route but never route -> entry, so a clear-cache walk cannot invalidate the already-executed upper module and subsequent SSR can keep serving closures that still reference the old remote exports.
Useful? React with 👍 / 👎.
99709ae to
e65fa31
Compare
Deploying rspack with
|
| Latest commit: |
ba52386
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://907fb725.rspack-v2.pages.dev |
| Branch Preview URL: | https://feat-mf-ssr-clear-cache.rspack-v2.pages.dev |
Summary
Add Module Federation cache clearing for Node SSR. After a remote is updated, the MF runtime can invalidate the remote and the host modules whose cached exports would otherwise keep serving the old remote, without restarting the SSR process.
This PR requires the matching
@module-federation/runtime-toolspre-release because that package owns the publicclearCache/ forced remote registration flow.Implementation
Compile-time dependency metadata
RemoteRuntimeModulenow emits reverse dependency metadata alongside the existing remote-loading data:remoteKeyToRemoteModuleIds: remote key -> remote module IDs.remoteKeyToExternalModuleIds: remote key -> external/container-entry module IDs.remoteModuleIdToConsumerModuleIds: remote module -> direct host consumers.consumerModuleIdToParentModuleIds: consumer -> its direct importers.remoteKeyToChunkIds: remote key -> chunks that load it.The metadata is generated from the compilation
ModuleGraphandChunkGraph, rather than from HMR state:RemoteModule, obtain itsremote_key, module ID, and external dependency module ID.original_module_identifieris a direct consumer.Using the normal module graph means this works in production SSR builds where HMR's
module.parentsis unavailable.Runtime invalidation
The runtime-tools cache-clear flow uses those indexes to identify the smallest invalidation set:
remoteModuleIdToConsumerModuleIds.consumerModuleIdToParentModuleIdsupward, invalidating cached host-module exports so a later SSR request re-executes the consumer chain and reloads the remote.This is necessary because clearing only the remote module is insufficient: a previously executed page/route module can remain in
__webpack_require__.cand return old exports without touching the remote loading path.Node chunk safety
Node
requireandreadFileVmchunk runtimes expose controlledchunkCacheControls:installedChunks;require.cachecleanup for affected filesystem chunks;A clear invalidates the target chunk generation before clearing it. An older async chunk load checks that generation before installing factories or marking the chunk loaded, so it cannot repopulate the cache after a newer request has begun.
Provider-side cleanup
Container entries expose
__webpack_clear_cache__, which clears the provider bundle's module cache. This ensures a reloaded remote does not reuse its own cached exposed-module exports.Behavior and limits
Tests
get, stale async chunk completion, repeated clearing, CommonJS cache cleanup, large payload release, and shared-module retention.pnpm run build:cli:dev:wasmpnpm run test -t "serialCases/container/mf-ssr-clear-cache"pnpm run lint:js