From 752757c16f085f4dad8a43d61afe32d17b901151 Mon Sep 17 00:00:00 2001 From: Michal Kuklis Date: Tue, 25 Apr 2023 09:57:51 -0400 Subject: [PATCH 1/5] STRIPES-861: Setup federation --- lib/commands/federate.js | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lib/commands/federate.js diff --git a/lib/commands/federate.js b/lib/commands/federate.js new file mode 100644 index 0000000..7affbda --- /dev/null +++ b/lib/commands/federate.js @@ -0,0 +1,57 @@ +const importLazy = require('import-lazy')(require); + +const { contextMiddleware } = importLazy('../cli/context-middleware'); +const StripesCore = importLazy('../cli/stripes-core'); +const StripesPlatform = importLazy('../platform/stripes-platform'); +const { stripesConfigFile } = importLazy('./common-options'); + +let _stripesPlatform; +let _stripesCore; + +// stripesPlatform and stripesCore overrides primarily used as injection for unit tests +function stripesOverrides(stripesPlatform, stripesCore) { + _stripesPlatform = stripesPlatform; + _stripesCore = stripesCore; +} + +function federateCommand(argv) { + const context = argv.context; + // Default federate command to production env + if (!process.env.NODE_ENV) { + process.env.NODE_ENV = 'production'; + } + + const platform = _stripesPlatform || new StripesPlatform(argv.stripesConfig, context, argv); + const webpackOverrides = []; + + if (argv.analyze) { + const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; // eslint-disable-line + webpackOverrides.push((config) => { + config.plugins.push(new BundleAnalyzerPlugin()); + return config; + }); + } + + console.info('Federate module...'); + const stripes = _stripesCore || new StripesCore(context, platform.aliases); + stripes.api.federate(Object.assign({}, argv, { webpackOverrides })); +} + +module.exports = { + command: 'federate', + describe: 'federate single module', + builder: (yargs) => { + yargs + .middleware([ + contextMiddleware(), + ]) + .positional('configFile', stripesConfigFile.configFile) + .option('analyze', { + describe: 'Run the Webpack Bundle Analyzer after build (launches in browser)', + type: 'boolean', + }) + .example('$0 federate', 'federate a module'); + }, + handler: federateCommand, + stripesOverrides, +}; From 7259755492f67e29a164471db49b66f260f31af7 Mon Sep 17 00:00:00 2001 From: Michal Kuklis Date: Mon, 1 May 2023 13:43:59 -0400 Subject: [PATCH 2/5] Introduce port argument --- lib/commands/federate.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/commands/federate.js b/lib/commands/federate.js index 7affbda..c696adf 100644 --- a/lib/commands/federate.js +++ b/lib/commands/federate.js @@ -50,6 +50,10 @@ module.exports = { describe: 'Run the Webpack Bundle Analyzer after build (launches in browser)', type: 'boolean', }) + .option('port', { + describe: 'A port which will be used for the remote federated module', + type: 'number', + }) .example('$0 federate', 'federate a module'); }, handler: federateCommand, From f0b545977a2db39ef975e6cb24afba69f55419db Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 17 Dec 2025 15:05:35 -0600 Subject: [PATCH 3/5] log changes --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ab13478..a9293b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Populate module descriptor's `name` field with module-name if `description` is missing. Refs STCLI-272. * Use node-native glob functionality in `translate compile`. Refs STCLI-273. +* expose the `federate` command. Refs STRIPES-861. ## [4.0.0](https://github.com/folio-org/stripes-cli/tree/v4.0.0) (2025-02-24) [Full Changelog](https://github.com/folio-org/stripes-cli/compare/v3.2.0...v4.0.0) From 8c763f1045b15d5b3fbd477d584dfda0e5f15fe2 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 14 Jan 2026 09:17:40 -0600 Subject: [PATCH 4/5] remove federate command, move functionality to --federate flag on build and serve commands --- lib/commands/build.js | 5 ++++ lib/commands/federate.js | 61 ---------------------------------------- lib/commands/serve.js | 4 +++ lib/server.js | 3 ++ 4 files changed, 12 insertions(+), 61 deletions(-) delete mode 100644 lib/commands/federate.js diff --git a/lib/commands/build.js b/lib/commands/build.js index 69b4fee..bf839e1 100644 --- a/lib/commands/build.js +++ b/lib/commands/build.js @@ -92,6 +92,11 @@ module.exports = { implies: 'createDll', requiresArg: true }) + .option('federate', { + describe: 'Enables module-federation in build process', + type: 'boolean', + default: false + }) .option('skipStripesBuild', { describe: 'Bypass Stripes-specific steps in build (useful when building third-party Webpack DLLs).', type: 'boolean', diff --git a/lib/commands/federate.js b/lib/commands/federate.js deleted file mode 100644 index c696adf..0000000 --- a/lib/commands/federate.js +++ /dev/null @@ -1,61 +0,0 @@ -const importLazy = require('import-lazy')(require); - -const { contextMiddleware } = importLazy('../cli/context-middleware'); -const StripesCore = importLazy('../cli/stripes-core'); -const StripesPlatform = importLazy('../platform/stripes-platform'); -const { stripesConfigFile } = importLazy('./common-options'); - -let _stripesPlatform; -let _stripesCore; - -// stripesPlatform and stripesCore overrides primarily used as injection for unit tests -function stripesOverrides(stripesPlatform, stripesCore) { - _stripesPlatform = stripesPlatform; - _stripesCore = stripesCore; -} - -function federateCommand(argv) { - const context = argv.context; - // Default federate command to production env - if (!process.env.NODE_ENV) { - process.env.NODE_ENV = 'production'; - } - - const platform = _stripesPlatform || new StripesPlatform(argv.stripesConfig, context, argv); - const webpackOverrides = []; - - if (argv.analyze) { - const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; // eslint-disable-line - webpackOverrides.push((config) => { - config.plugins.push(new BundleAnalyzerPlugin()); - return config; - }); - } - - console.info('Federate module...'); - const stripes = _stripesCore || new StripesCore(context, platform.aliases); - stripes.api.federate(Object.assign({}, argv, { webpackOverrides })); -} - -module.exports = { - command: 'federate', - describe: 'federate single module', - builder: (yargs) => { - yargs - .middleware([ - contextMiddleware(), - ]) - .positional('configFile', stripesConfigFile.configFile) - .option('analyze', { - describe: 'Run the Webpack Bundle Analyzer after build (launches in browser)', - type: 'boolean', - }) - .option('port', { - describe: 'A port which will be used for the remote federated module', - type: 'number', - }) - .example('$0 federate', 'federate a module'); - }, - handler: federateCommand, - stripesOverrides, -}; diff --git a/lib/commands/serve.js b/lib/commands/serve.js index 5203616..bd7d7b1 100644 --- a/lib/commands/serve.js +++ b/lib/commands/serve.js @@ -103,6 +103,10 @@ module.exports = { stripesConfigMiddleware(), ]) .positional('configFile', stripesConfigFile.configFile) + .option('federate', { + describe: 'At platform level, serves an empty host platform, using configured entitlementUrl to procure a list or remote apps. At the module level, this registers/serves the app as a locally federated remote.', + type: 'boolean', + }) .option('existing-build', { describe: 'Serve an existing build from the supplied directory', type: 'string', diff --git a/lib/server.js b/lib/server.js index f6cb6a0..c22f765 100644 --- a/lib/server.js +++ b/lib/server.js @@ -2,6 +2,7 @@ const path = require('path'); const fs = require('fs'); const http = require('http'); const express = require('express'); +const cors = require('cors'); const logger = require('morgan'); const debug = require('debug'); @@ -48,6 +49,8 @@ function onListening(server) { function start(dir, options) { const app = express(); + app.use(express.json()); + app.use(cors()); app.use(express.static(dir, {})); app.use(logger('tiny')); From a2a227e7db112d40f8d83f0daad15d1157cae814 Mon Sep 17 00:00:00 2001 From: John Coburn Date: Wed, 14 Jan 2026 14:31:29 -0600 Subject: [PATCH 5/5] log changes --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e2616b..3c3fed3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ * Populate module descriptor's `name` field with module-name if `description` is missing. Refs STCLI-272. * Use node-native glob functionality in `translate compile`. Refs STCLI-273. * Populate module descriptor's `metadata` field with remaining `stripes` properties. Refs STCLI-274. -* expose the `federate` command. Refs STRIPES-861. +* Expose the `--federate` flag on `build` and `serve` command. Refs STRIPES-861. +* Build static federated ui-bundles, host app. Refs STRIPES-861. ## [4.0.0](https://github.com/folio-org/stripes-cli/tree/v4.0.0) (2025-02-24) [Full Changelog](https://github.com/folio-org/stripes-cli/compare/v3.2.0...v4.0.0)