diff --git a/packages/cli/cli-report.md b/packages/cli/cli-report.md index 8979e91a82..0948954ff7 100644 --- a/packages/cli/cli-report.md +++ b/packages/cli/cli-report.md @@ -260,6 +260,7 @@ Usage: program [options] Options: --config --minify + --module-federation --role --skip-build-dependencies --stats diff --git a/packages/cli/src/modules/build/commands/package/build/command.ts b/packages/cli/src/modules/build/commands/package/build/command.ts index 378fd31896..101e91ad42 100644 --- a/packages/cli/src/modules/build/commands/package/build/command.ts +++ b/packages/cli/src/modules/build/commands/package/build/command.ts @@ -55,18 +55,26 @@ export async function command(opts: OptionValues): Promise { }); } - // 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, }); } diff --git a/packages/cli/src/modules/build/index.ts b/packages/cli/src/modules/build/index.ts index 5382adfec9..9b37efaa8b 100644 --- a/packages/cli/src/modules/build/index.ts +++ b/packages/cli/src/modules/build/index.ts @@ -42,6 +42,10 @@ export function registerPackageCommands(command: Command) { (opt: string, opts: string[]) => (opts ? [...opts, opt] : [opt]), Array(), ) + .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(), ) + .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' }); },