Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
f7afc46
Port enhanced layers tests to rspack
ScriptedAlchemy Feb 7, 2026
34067b4
Document RSC architecture
ScriptedAlchemy Feb 7, 2026
d0c5134
Document module federation flow
ScriptedAlchemy Feb 7, 2026
973d606
feat(mf): add layer-aware sharing and scope-array runtime support
ScriptedAlchemy Feb 7, 2026
73579ad
chore(api): update core API extractor snapshot for federation layer t…
ScriptedAlchemy Feb 7, 2026
695dcec
docs(mf): update MF deep map for layered sharing and scope arrays
ScriptedAlchemy Feb 7, 2026
d4d6c2b
fix: address mf-layers ci formatting and clippy issues
ScriptedAlchemy Feb 7, 2026
1030e0e
fix(mf): restore sharing runtime compatibility for non-enhanced flows
ScriptedAlchemy Feb 7, 2026
6059add
fix(mf): format rust files for CI
ScriptedAlchemy Feb 7, 2026
f762b6d
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Feb 8, 2026
f56cb0e
Merge remote-tracking branch 'origin/main' into feat/mf-layers
ScriptedAlchemy Feb 9, 2026
12fdb20
Merge remote-tracking branch 'origin/feat/mf-layers' into feat/mf-layers
ScriptedAlchemy Feb 9, 2026
75af9c2
chore: fix test failures on mf-layers (#12992)
ScriptedAlchemy Feb 9, 2026
a0bb7f3
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Feb 28, 2026
6ae03fc
feat(mf): cherry-pick layer expose plumbing and legacy scope validation
ScriptedAlchemy Mar 3, 2026
c2bdb34
Port enhanced layers tests to rspack
ScriptedAlchemy Feb 7, 2026
65a0e4c
Document RSC architecture
ScriptedAlchemy Feb 7, 2026
b651744
Document module federation flow
ScriptedAlchemy Feb 7, 2026
eb8cc84
feat(mf): add layer-aware sharing and scope-array runtime support
ScriptedAlchemy Feb 7, 2026
8d765e9
docs(mf): update MF deep map for layered sharing and scope arrays
ScriptedAlchemy Feb 7, 2026
77308ef
fix: address mf-layers ci formatting and clippy issues
ScriptedAlchemy Feb 7, 2026
5fc25b9
fix(mf): restore sharing runtime compatibility for non-enhanced flows
ScriptedAlchemy Feb 7, 2026
3569738
fix(mf): format rust files for CI
ScriptedAlchemy Feb 7, 2026
6376498
chore: fix test failures on mf-layers (#12992)
ScriptedAlchemy Feb 9, 2026
c6980a9
feat(mf): cherry-pick layer expose plumbing and legacy scope validation
ScriptedAlchemy Mar 3, 2026
a74d3f7
fix(mf): serialize share_scope vectors correctly
ScriptedAlchemy Mar 5, 2026
40df8b6
docs: fix heading-case in MF and RSC docs
ScriptedAlchemy Mar 5, 2026
649d953
fix(stats): avoid panic on stale module graph entries
ScriptedAlchemy Mar 5, 2026
42b9549
fix(mf): validate legacy share-scope arrays consistently
ScriptedAlchemy Mar 6, 2026
ac74d78
fix(mf): restore legacy v1 single share scope
ScriptedAlchemy Mar 6, 2026
8a2385f
Merge remote-tracking branch 'origin/main' into feat/mf-layers
ScriptedAlchemy Mar 7, 2026
d875250
fix(mf): wrap runtime init share scopes
ScriptedAlchemy Mar 7, 2026
3fd5af6
fix(mf): restore legacy share-scope validation messaging
ScriptedAlchemy Mar 7, 2026
365c874
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Mar 8, 2026
0cf57a5
refactor(mf): dedupe sharing lookup helpers
ScriptedAlchemy Mar 8, 2026
646a072
chore(docs): drop ad hoc mf and rsc notes
ScriptedAlchemy Mar 8, 2026
a6f893b
refactor(mf): reuse shared option fallback helpers
ScriptedAlchemy Mar 8, 2026
c4882a2
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Mar 9, 2026
ec97815
Merge remote-tracking branch 'origin/main' into feat/mf-layers
ScriptedAlchemy Mar 11, 2026
1e7b8f8
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Mar 11, 2026
e62ddd8
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Mar 11, 2026
81f9f62
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Mar 12, 2026
e9116c2
fix(mf): trim wrapper runtime changes
ScriptedAlchemy Mar 12, 2026
bd5426a
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Mar 12, 2026
6a20443
fix(ci): format sftrace skill doc
ScriptedAlchemy Mar 12, 2026
57f380b
fix(module-federation): align enhanced share init for module remotes
ScriptedAlchemy Mar 12, 2026
6ab4004
fix(module-federation): memoize enhanced external share init
ScriptedAlchemy Mar 12, 2026
9480e6b
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Mar 13, 2026
96e7c01
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Mar 13, 2026
2fbaad3
fix(mf): preserve share scope shape for layers
ScriptedAlchemy Mar 13, 2026
100611e
chore(mf): trim branch scope drift
ScriptedAlchemy Mar 13, 2026
6bf7052
Merge remote-tracking branch 'origin/feat/mf-layers' into feat/mf-layers
ScriptedAlchemy Mar 13, 2026
f15c27b
Merge branch 'main' into feat/mf-layers
ScriptedAlchemy Mar 13, 2026
226452c
fix(mf): align container share scope emitters
ScriptedAlchemy Mar 13, 2026
1eb2a18
fix(mf): align layer scope handling with core
ScriptedAlchemy Mar 13, 2026
492d8a4
Merge remote-tracking branch 'origin/main' into feat/mf-layers
ScriptedAlchemy Mar 13, 2026
b555530
fix(mf): restore enhanced layer sharing runtime
ScriptedAlchemy Mar 13, 2026
a77dd3d
fix(mf): drop unrelated stats module change
ScriptedAlchemy Mar 13, 2026
5853d77
fix(manifest): restore consume shared identifier parsing
ScriptedAlchemy Mar 13, 2026
6e12116
fix(manifest): include expose layer metadata
ScriptedAlchemy Mar 13, 2026
95cb638
Merge remote-tracking branch 'origin/main' into feat/mf-layers
ScriptedAlchemy Mar 13, 2026
dbf821c
fix(mf): address review feedback
ScriptedAlchemy Mar 13, 2026
ca2cac9
fix(mf): revert consume fallback factory
ScriptedAlchemy Mar 13, 2026
e4e588e
fix(mf): restore shared tree-shaking key parsing
ScriptedAlchemy Mar 13, 2026
0a5dfad
fix(mf): trim runtime scope handling
ScriptedAlchemy Mar 13, 2026
01b7015
fix(mf): revert unrelated v1 and cargo churn
ScriptedAlchemy Mar 13, 2026
211d598
fix(mf): preserve consume share scope arrays
ScriptedAlchemy Mar 13, 2026
13875e3
test(mf): remove legacy share scope remotes validation case
ScriptedAlchemy Mar 13, 2026
7b80d28
fix(mf): remove share scope normalization workaround
ScriptedAlchemy Mar 13, 2026
feab32c
refactor(mf): delegate consumes to bundler runtime
ScriptedAlchemy Mar 13, 2026
f7ff936
fix(mf): narrow enhanced layer parity work
ScriptedAlchemy Mar 14, 2026
b90f83b
fix(mf): preserve enhanced layer runtime metadata
ScriptedAlchemy Mar 14, 2026
eef09ad
fix(mf): preserve enhanced share registration scope
ScriptedAlchemy Mar 14, 2026
04e1c3b
refactor(mf): restore sharing runtime data shape
ScriptedAlchemy Mar 14, 2026
0fe891e
refactor(mf): restore consume runtime emit shape
ScriptedAlchemy Mar 14, 2026
61bd287
fix(mf): preserve consume fallback source emission
ScriptedAlchemy Mar 14, 2026
b241619
feat(mf): add layers support for module federation
ScriptedAlchemy Mar 14, 2026
91abbcd
fix(mf): initialize share scopes before consume loading
ScriptedAlchemy Mar 14, 2026
8d0c4a9
chore(mf): remove local runtime investigation notes
ScriptedAlchemy Mar 14, 2026
8e82836
fix(mf): restore layer runtime validation and remote wiring
ScriptedAlchemy Mar 14, 2026
1540f0e
fix(mf): harden layered manifest and optimizer metadata
ScriptedAlchemy Mar 14, 2026
dbf3131
fix(mf): restore consume runtime parity across scopes
ScriptedAlchemy Mar 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/node_binding/napi-binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1941,6 +1941,9 @@ export interface RawCompilerPlatform {

export interface RawConsumeOptions {
key: string
request?: string
issuerLayer?: string
layer?: string
import?: string
importResolved?: string
shareKey: string
Expand Down Expand Up @@ -2237,6 +2240,7 @@ export interface RawExperiments {
export interface RawExposeOptions {
key: string
name?: string
layer?: string
import: Array<string>
}

Expand Down Expand Up @@ -2544,6 +2548,7 @@ export interface RawManifestSharedOption {
name: string
version?: string
requiredVersion?: string
layer?: string
singleton?: boolean
}

Expand Down Expand Up @@ -2686,6 +2691,7 @@ export interface RawOptimizeSharedConfig {
shareKey: string
treeShaking: boolean
usedExports?: Array<string>
layer?: string
}

export interface RawOptions {
Expand Down Expand Up @@ -2787,6 +2793,8 @@ export interface RawProgressPluginOptions {

export interface RawProvideOptions {
key: string
request?: string
layer?: string
shareKey: string
shareScope: string | Array<string>
version?: string | false | undefined
Expand Down
16 changes: 16 additions & 0 deletions crates/rspack_binding_api/src/raw_options/raw_builtins/raw_mf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ impl From<RawContainerPluginOptions> for ContainerPluginOptions {
pub struct RawExposeOptions {
pub key: String,
pub name: Option<String>,
pub layer: Option<String>,
pub import: Vec<String>,
}

Expand All @@ -67,6 +68,7 @@ impl From<RawExposeOptions> for (String, ExposeOptions) {
value.key,
ExposeOptions {
name: value.name,
layer: value.layer,
import: value.import,
},
)
Expand Down Expand Up @@ -118,6 +120,8 @@ impl From<RawRemoteOptions> for (String, RemoteOptions) {
#[napi(object)]
pub struct RawProvideOptions {
pub key: String,
pub request: Option<String>,
pub layer: Option<String>,
pub share_key: String,
pub share_scope: Either<String, Vec<String>>,
#[napi(ts_type = "string | false | undefined")]
Expand All @@ -135,6 +139,8 @@ impl From<RawProvideOptions> for (String, ProvideOptions) {
(
value.key,
ProvideOptions {
request: value.request,
layer: value.layer,
share_key: value.share_key,
share_scope: into_share_scope(value.share_scope),
version: value.version.map(|v| RawVersionWrapper(v).into()),
Expand Down Expand Up @@ -220,6 +226,7 @@ pub struct RawOptimizeSharedConfig {
pub share_key: String,
pub tree_shaking: bool,
pub used_exports: Option<Vec<String>>,
pub layer: Option<String>,
}

impl From<RawOptimizeSharedConfig> for OptimizeSharedConfig {
Expand All @@ -228,6 +235,7 @@ impl From<RawOptimizeSharedConfig> for OptimizeSharedConfig {
share_key: value.share_key,
tree_shaking: value.tree_shaking,
used_exports: value.used_exports.unwrap_or_default(),
layer: value.layer,
}
}
}
Expand Down Expand Up @@ -264,6 +272,9 @@ impl From<RawSharedUsedExportsOptimizerPluginOptions> for SharedUsedExportsOptim
#[napi(object)]
pub struct RawConsumeOptions {
pub key: String,
pub request: Option<String>,
pub issuer_layer: Option<String>,
pub layer: Option<String>,
pub import: Option<String>,
pub import_resolved: Option<String>,
pub share_key: String,
Expand All @@ -282,6 +293,9 @@ impl From<RawConsumeOptions> for (String, ConsumeOptions) {
(
value.key,
ConsumeOptions {
request: value.request,
issuer_layer: value.issuer_layer,
layer: value.layer,
import: value.import,
import_resolved: value.import_resolved,
share_key: value.share_key,
Expand Down Expand Up @@ -373,6 +387,7 @@ pub struct RawManifestSharedOption {
pub name: String,
pub version: Option<String>,
pub required_version: Option<String>,
pub layer: Option<String>,
pub singleton: Option<bool>,
}

Expand Down Expand Up @@ -441,6 +456,7 @@ impl From<RawModuleFederationManifestPluginOptions> for ModuleFederationManifest
name: shared.name,
version: shared.version,
required_version: shared.required_version,
layer: shared.layer,
singleton: shared.singleton,
})
.collect(),
Expand Down
2 changes: 1 addition & 1 deletion crates/rspack_plugin_javascript/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ rspack_regex = { workspace = true }
rspack_util = { workspace = true }
rustc-hash = { workspace = true }
serde_json = { workspace = true }
smallvec = { workspace = true }
slotmap = { workspace = true }
smallvec = { workspace = true }
sugar_path = { workspace = true }
swc_core = { workspace = true, features = [
"__parser",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ impl Module for ContainerEntryModule {
Box::new(ContainerExposedDependency::new(
name.clone(),
request.clone(),
options.layer.clone(),
)) as Box<dyn Dependency>
})
.collect(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use rspack_cacheable::{cacheable, cacheable_dyn};
use rspack_core::{
AsContextDependency, AsDependencyCodeGeneration, Dependency, DependencyCategory, DependencyId,
DependencyType, FactorizeInfo, ModuleDependency, ResourceIdentifier,
DependencyType, FactorizeInfo, ModuleDependency, ModuleLayer, ResourceIdentifier,
};

#[cacheable]
Expand All @@ -10,18 +10,24 @@ pub struct ContainerExposedDependency {
id: DependencyId,
request: String,
pub exposed_name: String,
layer: Option<ModuleLayer>,
resource_identifier: ResourceIdentifier,
dependency_type: DependencyType,
factorize_info: FactorizeInfo,
}

impl ContainerExposedDependency {
pub fn new(exposed_name: String, request: String) -> Self {
let resource_identifier = format!("exposed dependency {exposed_name}={request}").into();
pub fn new(exposed_name: String, request: String, layer: Option<ModuleLayer>) -> Self {
let resource_identifier = if let Some(layer) = &layer {
format!("exposed dependency {exposed_name}={request}|layer={layer}").into()
} else {
format!("exposed dependency {exposed_name}={request}").into()
};
Self {
id: DependencyId::new(),
request,
exposed_name,
layer,
resource_identifier,
dependency_type: DependencyType::ContainerExposed,
factorize_info: Default::default(),
Expand All @@ -34,6 +40,7 @@ impl ContainerExposedDependency {
id: DependencyId::new(),
request,
exposed_name: String::new(),
layer: None,
resource_identifier,
dependency_type: DependencyType::ShareContainerFallback,
factorize_info: Default::default(),
Expand All @@ -55,6 +62,10 @@ impl Dependency for ContainerExposedDependency {
&self.dependency_type
}

fn get_layer(&self) -> Option<&ModuleLayer> {
self.layer.as_ref()
}

fn resource_identifier(&self) -> Option<&str> {
Some(&self.resource_identifier)
}
Expand Down
5 changes: 3 additions & 2 deletions crates/rspack_plugin_mf/src/container/container_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::sync::Arc;
use rspack_core::{
ChunkUkey, Compilation, CompilationAdditionalTreeRuntimeRequirements, CompilationParams,
CompilationRuntimeRequirementInTree, CompilerCompilation, CompilerMake, DependencyType,
EntryOptions, EntryRuntime, Filename, LibraryOptions, Plugin, RuntimeGlobals, RuntimeModule,
SourceType,
EntryOptions, EntryRuntime, Filename, LibraryOptions, ModuleLayer, Plugin, RuntimeGlobals,
RuntimeModule, SourceType,
};
use rspack_error::Result;
use rspack_hook::{plugin, plugin_hook};
Expand Down Expand Up @@ -32,6 +32,7 @@ pub struct ContainerPluginOptions {
#[derive(Debug, Clone, Serialize)]
pub struct ExposeOptions {
pub name: Option<String>,
pub layer: Option<ModuleLayer>,
pub import: Vec<String>,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use rspack_core::{
use rspack_error::Result;

use super::module_federation_runtime_plugin::ModuleFederationRuntimeExperimentsOptions;

#[cacheable]
#[derive(Debug, Default, Clone, Hash, PartialEq, Eq)]
pub struct EmbedFederationRuntimeModuleOptions {
Expand Down Expand Up @@ -100,7 +99,6 @@ impl RuntimeModule for EmbedFederationRuntimeModule {
module_executions.push_str(&module_str);
module_executions.push('\n');
}

if self.options.experiments.async_startup {
let entry_chunk_ids = compilation
.build_chunk_graph_artifact
Expand Down
31 changes: 28 additions & 3 deletions crates/rspack_plugin_mf/src/container/remote_runtime_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use std::sync::LazyLock;

use rspack_collections::Identifiable;
use rspack_core::{
ChunkGraph, Compilation, DependenciesBlock, ModuleId, RuntimeGlobals, RuntimeModule,
RuntimeModuleGenerateContext, RuntimeModuleStage, RuntimeTemplate, SourceType,
impl_runtime_module,
ChunkGraph, Compilation, DependenciesBlock, ExternalModule, ModuleId, RuntimeGlobals,
RuntimeModule, RuntimeModuleGenerateContext, RuntimeModuleStage, RuntimeTemplate, SourceType,
extract_url_and_global, impl_runtime_module,
};
use rspack_plugin_runtime::extract_runtime_globals_from_ejs;
use rustc_hash::FxHashMap;
Expand Down Expand Up @@ -79,6 +79,22 @@ impl RuntimeModule for RemoteRuntimeModule {
let external_module = module_graph
.get_module_by_dependency_id(&dep)
.expect("should have module");
let remote_info = external_module
.downcast_ref::<ExternalModule>()
.map(|external_module| {
let external_type = external_module.get_external_type().as_str();
let name = if external_type == "script" {
extract_url_and_global(external_module.get_request().primary())
.map(|url_and_global| url_and_global.global)
.unwrap_or("")
} else {
""
};
RemoteInfo {
external_type,
name,
}
});
let external_module_id = ChunkGraph::get_module_id(
&compilation.module_ids_artifact,
external_module.identifier(),
Expand All @@ -92,6 +108,7 @@ impl RuntimeModule for RemoteRuntimeModule {
name,
external_module_id,
remote_name: &m.remote_key,
remote_info,
},
);
}
Expand Down Expand Up @@ -143,6 +160,14 @@ struct RemoteData<'a> {
name: &'a str,
external_module_id: &'a ModuleId,
remote_name: &'a str,
remote_info: Option<RemoteInfo<'a>>,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
struct RemoteInfo<'a> {
external_type: &'a str,
name: &'a str,
}

#[derive(Debug, Serialize)]
Expand Down
8 changes: 8 additions & 0 deletions crates/rspack_plugin_mf/src/manifest/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ pub struct StatsExpose {
pub file: String,
pub id: String,
pub name: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub layer: Option<String>,
#[serde(default)]
pub requires: Vec<String>,
#[serde(default)]
Expand All @@ -48,6 +50,8 @@ pub struct StatsShared {
pub version: String,
#[serde(default)]
pub requiredVersion: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub layer: Option<String>,
#[serde(default)]
pub singleton: Option<bool>,
#[serde(default)]
Expand Down Expand Up @@ -112,6 +116,8 @@ pub struct ManifestExpose {
pub id: String,
pub name: String,
pub path: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub layer: Option<String>,
pub assets: StatsAssetsGroup,
}

Expand All @@ -122,6 +128,8 @@ pub struct ManifestShared {
pub version: String,
#[serde(default)]
pub requiredVersion: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub layer: Option<String>,
#[serde(default)]
pub singleton: Option<bool>,
#[serde(default)]
Expand Down
Loading
Loading