Add CLI --module-federation flag to build frontend plugins as remotes

Signed-off-by: David Festal <dfestal@redhat.com>
Assisted-by: Cursor
This commit is contained in:
David Festal
2025-11-05 16:52:42 +01:00
parent c324bf71be
commit 1a656db530
3 changed files with 19 additions and 2 deletions
+1
View File
@@ -260,6 +260,7 @@ Usage: program [options]
Options:
--config <path>
--minify
--module-federation
--role <name>
--skip-build-dependencies
--stats
@@ -55,18 +55,26 @@ export async function command(opts: OptionValues): Promise<void> {
});
}
// experimental
let isModuleFederationRemote: boolean | undefined = undefined;
if ((role as string) === 'frontend-dynamic-container') {
console.log(
chalk.yellow(
`⚠️ WARNING: The 'frontend-dynamic-container' package role is experimental and will receive immediate breaking changes in the future.`,
),
);
isModuleFederationRemote = true;
}
if (opts.moduleFederation) {
isModuleFederationRemote = true;
}
if (isModuleFederationRemote) {
console.log('Building package as a module federation remote');
return buildFrontend({
targetDir: paths.targetDir,
configPaths: [],
writeStats: Boolean(opts.stats),
isModuleFederationRemote: true,
isModuleFederationRemote,
webpack,
});
}
+8
View File
@@ -42,6 +42,10 @@ export function registerPackageCommands(command: Command) {
(opt: string, opts: string[]) => (opts ? [...opts, opt] : [opt]),
Array<string>(),
)
.option(
'--module-federation',
'Build a package as a module federation remote. Applies to frontend plugin packages only.',
)
.action(lazy(() => import('./commands/package/build'), 'command'));
}
@@ -77,6 +81,10 @@ export const buildPlugin = createCliPlugin({
(opt: string, opts: string[]) => (opts ? [...opts, opt] : [opt]),
Array<string>(),
)
.option(
'--module-federation',
'Build a package as a module federation remote. Applies to frontend plugin packages only.',
)
.action(lazy(() => import('./commands/package/build'), 'command'));
await defaultCommand.parseAsync(args, { from: 'user' });
},