fix(runtime-core): cache synchronous shared factories - #4998
Conversation
🦋 Changeset detectedLatest commit: fd3a32e The changes in this PR will be included in the next version bump. This PR includes changesets to release 48 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 |
@module-federation/devtools
@module-federation/cli
create-module-federation
@module-federation/dts-plugin
@module-federation/enhanced
@module-federation/error-codes
@module-federation/esbuild
@module-federation/managers
@module-federation/manifest
@module-federation/metro
@module-federation/metro-plugin-rnc-cli
@module-federation/metro-plugin-rnef
@module-federation/metro-plugin-rock
@module-federation/modern-js
@module-federation/modern-js-v3
@module-federation/native-federation-tests
@module-federation/native-federation-typescript
@module-federation/nextjs-mf
@module-federation/node
@module-federation/observability-plugin
@module-federation/playground
@module-federation/retry-plugin
@module-federation/rsbuild-plugin
@module-federation/rspack
@module-federation/rspress-plugin
@module-federation/rstest
@module-federation/runtime
@module-federation/runtime-core
@module-federation/runtime-tools
@module-federation/sdk
@module-federation/storybook-addon
@module-federation/third-party-dts-extractor
@module-federation/treeshake-frontend
@module-federation/treeshake-server
@module-federation/typescript
@module-federation/utilities
@module-federation/webpack-bundler-runtime
@module-federation/bridge-react
@module-federation/bridge-react-webpack-plugin
@module-federation/bridge-shared
@module-federation/bridge-vue3
@module-federation/inject-external-runtime-core-plugin
commit: |
Bundle Size Report11 package(s) changed, 32 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 35.90 MB (-421 B (-0.0%)) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
Cache factories returned by synchronous shared getters in the registered share record so subsequent
loadShareSynccalls reuse the loaded factory.The existing behavior dates back to the v1 implementation, where
setSharedreturned immediately for an existing version. In the current runtime this leaves the share marked as loaded without alib, causing later synchronous loads to invokegetagain. The merge now fillslibonly when the registered share does not already have one, preserving the existing provider and factory precedence.A regression test verifies that the getter runs once and that the factory is stored in the share scope.
Validation:
pnpm exec turbo run test --filter=@module-federation/runtime-core --force(12 test files, 97 tests passed)pnpm run ci:local --only=build-and-test(44 package builds and 60 affected test tasks passed)@module-federation/runtime-corepatchpnpm exec prettier --check .reports the unchanged baseline filepackages/playground/src/generated/bridgeRuntimeFiles.ts; the CI changed-file format check passes for all files in this PR