Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
804192f
feat(mf): initialize ordered share scopes at runtime
ScriptedAlchemy Jul 22, 2026
cd409d2
Merge remote-tracking branch 'origin/feat/mf-layers' into codex/work-…
ScriptedAlchemy Jul 27, 2026
2a348f9
Merge commit '36a38613a7' into codex/work-pr14911
ScriptedAlchemy Jul 27, 2026
e0a975f
Merge commit '56fc0cab28' into codex/work-pr14911
ScriptedAlchemy Jul 27, 2026
223f6e8
Merge commit '654ac804b1' into codex/work-pr14911
ScriptedAlchemy Jul 27, 2026
3e4af0c
Merge commit '6dab88a7d0' into codex/work-pr14911
ScriptedAlchemy Jul 27, 2026
679b9b2
Merge commit '999506904d' into codex/work-pr14911
ScriptedAlchemy Jul 27, 2026
9392c3b
Merge commit '73242f4105' into codex/work-pr14911
ScriptedAlchemy Jul 27, 2026
ffd6b71
Merge commit 'c58d0a8c16' into codex/work-pr14911
ScriptedAlchemy Jul 28, 2026
72c9492
Merge commit '81d616bcfe' into codex/work-pr14911
ScriptedAlchemy Jul 28, 2026
cbaca67
Merge commit '0a1d09fb45' into codex/work-pr14911
ScriptedAlchemy Jul 28, 2026
fefd61d
perf(mf): compact enhanced remote metadata
ScriptedAlchemy Jul 28, 2026
2119bde
perf(mf): trim remote metadata serialization
ScriptedAlchemy Jul 29, 2026
2c2c830
Merge commit 'daeae0a3f3' into codex/work-pr14911
ScriptedAlchemy Jul 29, 2026
2c0d2b7
fix(mf): scope remote init deduplication
ScriptedAlchemy Jul 29, 2026
4216733
Merge commit '997e40f46e' into codex/work-pr14911
ScriptedAlchemy Jul 29, 2026
982bd52
fix(mf): initialize scopes for eager consumes
ScriptedAlchemy Jul 29, 2026
fb01cba
Merge commit 'edc5abfcee' into codex/work-pr14911
ScriptedAlchemy Jul 29, 2026
6917dd6
fix(mf): satisfy serialization lint
ScriptedAlchemy Jul 29, 2026
46a22cb
Merge commit '1617fe6275' into codex/work-pr14911
ScriptedAlchemy Jul 29, 2026
f1c1d56
Merge commit '335020f25d' into codex/work-pr14911
ScriptedAlchemy Jul 29, 2026
d540607
fix(mf): await initial consume scopes
ScriptedAlchemy Jul 29, 2026
69fce9f
Merge commit '17ef222973' into codex/work-pr14911
ScriptedAlchemy Jul 29, 2026
4aad05b
fix(mf): gate ordered eager startup
ScriptedAlchemy Jul 29, 2026
1656d1b
fix(mf): gate all ordered consume startups
ScriptedAlchemy Jul 29, 2026
a7dbfba
Merge remote-tracking branch 'origin/feat/mf-layers' into codex/work-…
ScriptedAlchemy Jul 29, 2026
8546df8
Merge remote-tracking branch 'origin/feat/mf-layers' into codex/work-…
ScriptedAlchemy Jul 29, 2026
635aa40
Merge remote-tracking branch 'origin/feat/mf-layers' into codex/work-…
ScriptedAlchemy Sep 7, 2026
8f1fa56
Merge remote-tracking branch 'origin/feat/mf-layers' into codex/work-…
ScriptedAlchemy Sep 8, 2026
e2d534c
fix(mf): keep scalar initial consumes synchronous
ScriptedAlchemy Sep 8, 2026
a8ea59e
fix(mf): keep the container primary scope bound when adding scopes
ScriptedAlchemy Sep 8, 2026
0a411d4
fix(mf): derive async startup from the runtime's actual initial consumes
ScriptedAlchemy Sep 8, 2026
451b6f3
fix(mf): address startup and scope-binding review findings
ScriptedAlchemy Sep 8, 2026
7213cc1
Merge remote-tracking branch 'origin/feat/mf-layers' into codex/work-…
ScriptedAlchemy Sep 8, 2026
7d90b41
fix(mf): decide startup per runtime and initialize scopes per consume…
ScriptedAlchemy Sep 8, 2026
03726e7
fix(mf): derive container async mode and preserve lazy sharing
ScriptedAlchemy Sep 8, 2026
5c0bf44
Merge branch 'codex/work-pr12977' into codex/work-pr14911
ScriptedAlchemy Sep 8, 2026
ca09e3d
fix(mf): register additional providers for ordered host scopes
ScriptedAlchemy Sep 8, 2026
9681097
Merge branch 'codex/work-pr12977' into codex/work-pr14911
ScriptedAlchemy Sep 8, 2026
2a958b0
Merge branch 'codex/work-pr12977' into codex/work-pr14911
ScriptedAlchemy Sep 8, 2026
43de580
chore(mf): format runtime startup hook
ScriptedAlchemy Sep 8, 2026
700f603
chore: sync mf runtime with layers base
ScriptedAlchemy Sep 9, 2026
8e01c76
chore: sync mf runtime with prefix matching fix
ScriptedAlchemy Sep 9, 2026
01ab850
chore: sync mf runtime with layers formatting
ScriptedAlchemy Sep 9, 2026
b27879b
chore: sync mf runtime with layers base
ScriptedAlchemy Sep 9, 2026
3c2da7d
docs(mf): explain ordered share scope initialization
ScriptedAlchemy Sep 8, 2026
ec919f5
test(mf): run runtime adapter cases in the compiler harness
ScriptedAlchemy Sep 8, 2026
f2348a5
Merge branch 'feat/mf-layers' into codex/mf-share-scope-runtime
ScriptedAlchemy Sep 9, 2026
4c19d81
fix(mf): preserve configured scalar scope initialization
ScriptedAlchemy Sep 9, 2026
258fcbb
Merge branch 'feat/mf-layers' into codex/mf-share-scope-runtime
ScriptedAlchemy Sep 10, 2026
c4c8a93
Merge branch 'feat/mf-layers' into codex/mf-share-scope-runtime
ScriptedAlchemy Sep 10, 2026
a7c7947
fix(mf): initialize shared scopes for fallback remotes
ScriptedAlchemy Sep 10, 2026
4288b2f
Merge branch 'feat/mf-layers' into codex/mf-share-scope-runtime
ScriptedAlchemy Sep 11, 2026
d178241
fix(mf): satisfy fallback metadata clippy check
ScriptedAlchemy Sep 11, 2026
c1deb73
Merge branch 'stack-refresh/12977' into stack-refresh/14911
ScriptedAlchemy Sep 14, 2026
2b5c05a
Merge branch 'stack-refresh2/12977' into stack-refresh2/14911
ScriptedAlchemy Sep 15, 2026
2d26a5d
Merge branch 'stack-refresh2/12977' into stack-refresh2/14911
ScriptedAlchemy Sep 15, 2026
a8abb09
refactor(mf): reuse json_stringify in the remote runtime module
ScriptedAlchemy Sep 15, 2026
f74f613
Merge branch 'stack-refresh2/12977' into stack-refresh2/14911
ScriptedAlchemy Sep 16, 2026
6d63ed3
chore(mf): drop the unused validateShareScope, a stale experiments.ou…
ScriptedAlchemy Sep 16, 2026
36f6da9
Merge branch 'stack-refresh2/12977' into stack-refresh2/14911
ScriptedAlchemy Sep 16, 2026
2150ebc
Merge branch 'stack-refresh2/12977' into stack-refresh2/14911
ScriptedAlchemy Sep 22, 2026
f9cea98
style(mf): format remote runtime mapping arguments
ScriptedAlchemy Sep 22, 2026
c60342a
Merge feat/mf-layers into ordered share scope runtime
ScriptedAlchemy Sep 29, 2026
1d7a363
Merge corrected workspace lockfile into ordered share scope runtime
ScriptedAlchemy Sep 29, 2026
0fe49a4
fix(mf): isolate remote scope initialization and alias contracts
ScriptedAlchemy Sep 30, 2026
43ff30e
Merge updated MF layers base into share-scope runtime
ScriptedAlchemy Sep 30, 2026
ad3577d
fix(mf): keep serialized runtime self-contained and preserve scalar f…
ScriptedAlchemy Sep 30, 2026
acd77d4
Merge branch 'api-compat' into api-compat-runtime
ScriptedAlchemy Sep 30, 2026
6b32aa9
Merge branch 'api-compat' into api-compat-runtime
ScriptedAlchemy Sep 30, 2026
0f34845
Merge branch 'api-compat' into api-compat-runtime
ScriptedAlchemy Sep 30, 2026
3e8fdea
Merge branch 'api-compat' into api-compat-runtime
ScriptedAlchemy Sep 30, 2026
27789f6
chore: update ordered-scope stack base
ScriptedAlchemy Oct 22, 2026
f303ce7
chore: propagate federation lockfile fix
ScriptedAlchemy Oct 22, 2026
5b1e45a
chore: propagate combined preview build
ScriptedAlchemy Oct 22, 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ static RUNTIME_MODULE_VARIABLES: LazyLock<Vec<&'static str>> = LazyLock::new(||
EMBED_FEDERATION_RUNTIME_SYNC_TEMPLATE,
])
});

#[cacheable]
#[derive(Debug, Default, Clone, Hash, PartialEq, Eq)]
pub struct EmbedFederationRuntimeModuleOptions {
Expand Down Expand Up @@ -133,7 +132,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
4 changes: 2 additions & 2 deletions crates/rspack_plugin_mf/src/container/remote_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ impl RemoteModule {
blocks: Default::default(),
dependencies: Default::default(),
identifier: ModuleIdentifier::from(format!(
"remote ({}) {} {}",
share_scope.key(),
"remote {} {} {}",
share_scope.identifier_fragment(),
external_requests.join(" "),
internal_request
)),
Expand Down
36 changes: 33 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, RuntimeModuleRuntimeRequirements, RuntimeModuleStage,
RuntimeTemplate, SourceType, impl_runtime_module,
ChunkGraph, Compilation, DependenciesBlock, ExternalModule, ModuleId, RuntimeGlobals,
RuntimeModule, RuntimeModuleGenerateContext, RuntimeModuleRuntimeRequirements,
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 @@ -102,6 +102,26 @@ impl RuntimeModule for RemoteRuntimeModule {
let external_module = module_graph
.get_module_by_dependency_id(&dep)
.expect("should have module");
let remote_info = self
.enhanced
.then(|| {
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_or("", |url_and_global| url_and_global.global)
} else {
""
};
RemoteInfo {
external_type,
name,
}
})
})
.flatten();
let external_module_id = ChunkGraph::get_module_id(
&compilation.module_ids_artifact,
external_module.identifier(),
Expand All @@ -115,6 +135,7 @@ impl RuntimeModule for RemoteRuntimeModule {
name,
external_module_id,
remote_name: &m.remote_key,
remote_info,
},
);
}
Expand Down Expand Up @@ -162,6 +183,15 @@ struct RemoteData<'a> {
name: &'a str,
external_module_id: &'a ModuleId,
remote_name: &'a str,
#[serde(skip_serializing_if = "Option::is_none")]
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
9 changes: 6 additions & 3 deletions packages/rspack/src/container/ContainerPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import type { Compiler } from '../Compiler';
import type { EntryRuntime, FilenameTemplate, LibraryOptions } from '../config';
import { parseOptions } from '../container/options';
import { type ShareScope, validateShareScope } from '../sharing/SharePlugin';
import { normalizeShareScope, type ShareScope } from '../sharing/SharePlugin';
import { ShareRuntimePlugin } from '../sharing/ShareRuntimePlugin';

export type ContainerPluginOptions = {
Expand Down Expand Up @@ -39,9 +39,12 @@ export class ContainerPlugin extends RspackBuiltinPlugin {

constructor(options: ContainerPluginOptions) {
super();
const shareScope = options.shareScope || 'default';
const enhanced = options.enhanced ?? false;
validateShareScope(shareScope, enhanced, 'ContainerPlugin');
const shareScope = normalizeShareScope(
options.shareScope || 'default',
enhanced,
'ContainerPlugin',
);
this._options = {
name: options.name,
shareScope,
Expand Down
31 changes: 14 additions & 17 deletions packages/rspack/src/container/ContainerReferencePlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
import { ExternalsPlugin } from '../builtin-plugin/ExternalsPlugin';
import type { Compiler } from '../Compiler';
import type { ExternalsType } from '../config';
import { type ShareScope, validateShareScope } from '../sharing/SharePlugin';
import { normalizeShareScope, type ShareScope } from '../sharing/SharePlugin';
import { ShareRuntimePlugin } from '../sharing/ShareRuntimePlugin';
import { parseOptions } from './options';

Expand Down Expand Up @@ -38,33 +38,30 @@ export class ContainerReferencePlugin extends RspackBuiltinPlugin {
constructor(options: ContainerReferencePluginOptions) {
super();
const enhanced = options.enhanced ?? false;
if (options.shareScope) {
validateShareScope(
options.shareScope,
enhanced,
'ContainerReferencePlugin',
);
}
const shareScope = options.shareScope
? normalizeShareScope(
options.shareScope,
enhanced,
'ContainerReferencePlugin',
)
: undefined;
const remotes = parseOptions(
options.remotes,
(item) => ({
external: Array.isArray(item) ? item : [item],
shareScope: options.shareScope || 'default',
shareScope: shareScope || 'default',
}),
(item) => ({
external: Array.isArray(item.external)
? item.external
: [item.external],
shareScope: item.shareScope || options.shareScope || 'default',
shareScope: normalizeShareScope(
item.shareScope || shareScope || 'default',
enhanced,
'ContainerReferencePlugin',
),
}),
);
for (const [, config] of remotes) {
validateShareScope(
config.shareScope,
enhanced,
'ContainerReferencePlugin',
);
}
this._options = {
remoteType: options.remoteType,
remotes,
Expand Down
29 changes: 26 additions & 3 deletions packages/rspack/src/container/ModuleFederationPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { resolve } from 'node:path';
import type { Compiler } from '../Compiler';
import { createCompilerRuntimeGlobals } from '../RuntimeGlobals';
import type { ExternalsType } from '../config';
import type { ShareFallback } from '../sharing/IndependentSharedPlugin';
import type {
ShareFallback,
ShareFallbackVariants,
} from '../sharing/IndependentSharedPlugin';
import type { SharedConfig, ShareScope } from '../sharing/SharePlugin';
import { TreeShakingSharedPlugin } from '../sharing/TreeShakingSharedPlugin';
import { isRequiredVersion } from '../sharing/utils';
Expand Down Expand Up @@ -71,17 +74,31 @@ export class ModuleFederationPlugin {
})
: undefined;
runtimeVirtualPlugin?.apply(compiler);
const updateRuntimeShareFallbacks = (buildAssets: ShareFallback) => {
const updateRuntimeShareFallbacks = (
_buildAssets: ShareFallback,
variants: ShareFallbackVariants,
) => {
if (!runtimeVirtualPath || !runtimeVirtualPlugin) {
return;
}
const runtimeBuildAssets = Object.fromEntries(
Object.entries(variants).map(([shareKey, entries]) => [
shareKey,
entries.map(({ entry, version, globalName }) => [
entry,
version,
globalName,
]),
]),
) as ShareFallback;
runtimeVirtualPlugin.writeModule(
runtimeVirtualPath,
getDefaultEntryRuntimeSource(
paths,
this._options,
compiler,
buildAssets,
runtimeBuildAssets,
variants,
),
);
};
Expand Down Expand Up @@ -340,6 +357,7 @@ function getDefaultEntryRuntimeSource(
options: ModuleFederationPluginOptions,
compiler: Compiler,
treeShakingShareFallbacks?: ShareFallback,
treeShakingShareFallbackVariants?: ShareFallbackVariants,
) {
const runtimePlugins = getRuntimePlugins(options);
const remoteInfos = getRemoteInfos(options);
Expand Down Expand Up @@ -408,6 +426,9 @@ function getDefaultEntryRuntimeSource(
`const __module_federation_share_fallbacks__ = ${JSON.stringify(
treeShakingShareFallbacks,
)}`,
`const __module_federation_share_fallback_variants__ = ${JSON.stringify(
treeShakingShareFallbackVariants,
)}`,
`const __module_federation_library_type__ = ${JSON.stringify(libraryType)}`,
runtimeSource,
].join(';');
Expand Down Expand Up @@ -437,13 +458,15 @@ function getDefaultEntryRuntime(
options: ModuleFederationPluginOptions,
compiler: Compiler,
treeShakingShareFallbacks?: ShareFallback,
treeShakingShareFallbackVariants?: ShareFallbackVariants,
) {
return `${MF_RUNTIME_LOADER}!=!data:text/javascript,${encodeURIComponent(
getDefaultEntryRuntimeSource(
paths,
options,
compiler,
treeShakingShareFallbacks,
treeShakingShareFallbackVariants,
),
)}`;
}
Loading
Loading