fix(manifest,managers): support Rspack layered shared metadata - #5039
fix(manifest,managers): support Rspack layered shared metadata#5039ScriptedAlchemy wants to merge 7 commits into
Conversation
Rspack's layer-aware Module Federation stack (web-infra-dev/rspack#12977, #14912, #14913) changes what the public v2 wrapper receives: - ContainerManager.containerPluginExposesOptions rebuilt exposes from import/name only and dropped exposes.*.layer, so a layered expose was silently built unlayered. Preserve layer, including the empty string. - The manifest reader extracted the shared package/version from a fixed space-delimited position, which the structural identifiers (provide shared module [<key>]@<version> = ...) move; it also cast the container-entry bracket payload to an expose-pair array, which the layered [exposes, layers] tuple breaks with a TypeError. Decode the structural key by its length-prefixed components and validate both container payload generations (and array share-scope prefixes), keeping the legacy formats working. Shared records are still aggregated by package name only; representing concrete provider variants is coordinated separately with the native manifest producer.
🦋 Changeset detectedLatest commit: a5aa440 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 Report10 package(s) changed, 33 unchanged. Package dist + ESM entry
Bundle targets
Consumer scenarios
Total dist (raw): 36.19 MB (+26.6 kB (+0.1%)) Bundle sizes are generated with rslib (Rspack). Package-root metrics preserve the historical report. Tracked subpath exports such as |
…ayers Rspack's layer-aware stack now emits the same identifier layouts as webpack's enhanced plugin: shared modules insert a ' (layer)' segment after the '(scope)' segment and keep 'name@version' at its legacy token position; container entries keep the '[[key, options]]' payload with a 'layer' inside the expose options when present. Drop the structural-key and tuple decoding that the earlier draft anticipated and parse the layer segment instead (for webpack provide identifiers too). Add a compatibility suite that runs the last published reader (@module-federation/manifest@2.8.2, aliased as a dev dependency) and the current source against the same Rspack-shaped identifiers: unlayered shares and containers (with or without a layered expose) read identically, layered shares are skipped by the old reader without failing, and the superseded structural/tuple shapes are documented as breaking it.
Summary
Preserve layer-aware shared and exposed module metadata from Rspack and webpack through stats collection and manifest generation. Public expose aliases retain their imports, requirements, layers, and assets, including multi-import exposes and disabled asset analysis. The wrapper forwards
exposes.*.layer, including an empty string.Shared rows keep their existing unlayered fields. An optional
providersarray records multiple concrete version/import pairs and their assets; single-provider and consumer-only rows omit it. Layered and ordered-scope identities remain separate. The reader handles the existing webpack identifier layout, Rspack's structural suffix, nullable expose names, and webpack's omitted-layer sentinels.The SDK types and manifest regeneration preserve optional provider, layer, scope, identity, and expose-requirement metadata. A patch changeset covers the affected packages.
Related links
Companion to the Rspack layers stack: #12977 → #14911 → #14912 → #14913.
Compatibility
Unlayered applications remain compatible with older Federation readers in both directions. Tests compare the published
@module-federation/manifest@2.8.2reader with current source, including exact legacy shared fields and manifests without provider metadata. Layer-aware metadata requires this companion support.Fresh Rspack output was checked through both readers: legacy fields agree, and the new reader's provider versions, resolved imports, and assets match the native manifest. Actual webpack compilations cover multiple providers and expose aliases. Tests also instantiate enhanced webpack's consume module to distinguish omitted layers from explicit empty layers.
Testing
The manifest package pins the Rspack layers preview at
843bab005bas a development dependency. One real compiler test covers two named exposes of the same source in different layers, distinct assets/shared identities, ordered scopes, andrequiredSharedthrough stats-to-manifest conversion. The root compiler and unrelated lockfile entries are unchanged. Frozen install and the manifest build passed.