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:
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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' });
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user