Skip to content

STRWEB-139 Use non-webpack module federation plugin.#176

Merged
JohnC-80 merged 60 commits intomainfrom
STRWEB-139
Mar 31, 2026
Merged

STRWEB-139 Use non-webpack module federation plugin.#176
JohnC-80 merged 60 commits intomainfrom
STRWEB-139

Conversation

@JohnC-80
Copy link
Copy Markdown
Contributor

@JohnC-80 JohnC-80 commented Feb 9, 2026

This non-webpack version of module federation is maintained by the original implementor of the technology.

@module-federation/enhanced implements runtime hooks that can be used to affect module-federation logic for resolving shares, working with remotes, debugging, etc. You can learn more at module-federation documentation.

Changes in this PR:

  • Singleton dependencies (react, react-dom, stripes-core, stripes-components) are only loaded in the host app. They are not included in remote app bundles.
  • Module-federation configurations are consolidated to a single file for easier adjustment of configuration for both remotes and the host app.
  • Implement a runtime plugin for remotes that injects a runtime plugin from the host app. This keeps us from having to rebuild ALL of the apps any time a runtime plugin is added/updated.
  • Other bundle-size saving measures for remotes: excluding the mod-fed runtime logic from their code and setting their optimizations for the "web" target (vs a node target) to reduce bundle size.
  • stripes serve --federate:
    • can be used w/o a config file at the ui-module level (defaults to localhost:3001/registry)
    • for host app serving, the --federate flag will spin up the local registry. A config will still be necessary for reaching out to a hosted environment's okapi.

mkuklis and others added 26 commits October 28, 2024 16:30
* map the `sounds` directory for remote applications, analogous to how
  translations and icons are served
* provide `/code` to make the registry human-readable
* catch and display startup errors in case humans make stupid coding
  mistakes and need help finding them
Icons in stripes-components are imported as components whereas those in
applications are just resources, so we need to load them differently.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 9, 2026

Jest Unit Test Results

0 tests  ±0   0 ✅ ±0   0s ⏱️ ±0s
0 suites ±0   0 💤 ±0 
0 files   ±0   0 ❌ ±0 

Results for commit f6100ce. ± Comparison against base commit c50db54.

♻️ This comment has been updated with latest results.

@JohnC-80 JohnC-80 marked this pull request as ready for review February 24, 2026 20:07
@JohnC-80 JohnC-80 requested a review from a team as a code owner February 24, 2026 20:07
Copy link
Copy Markdown
Member

@zburke zburke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description says federation now works "without a config file", but that did not work for me. Maybe some config/documentation details are missing?

In a platform, yarn stripes [build|serve] --federate still complains

Warning: Building a platform without a stripes configuration. Did you forget to include "stripes.config.js"?

Since building without a stripes configuration is **exactly the point of this work we should suppress that warning when --federate is present.

Running yarn stripes serve --federate (i.e. without the positional for stripes.config.js) does not start the local registry.

I really appreciate the comments in module-federation-config.js explaining both what it does and why specific config flags are in place. Our code, specifically our config code, needs more documentation like this!

Comment thread webpack.config.cli.prod.js Outdated
Comment thread module-federation-config.js
Comment thread module-federation-config.js Outdated
Comment thread module-federation-config.js Outdated
Comment thread webpack.config.cli.dev.js Outdated
@JohnC-80
Copy link
Copy Markdown
Contributor Author

JohnC-80 commented Mar 4, 2026

@zburke The no-config messaging resides in stripes-cli I'll open a PR there to clean that up. I've updated the description here and the code for the host app to truly lean on the federate flag alone for serving the host app and local registry.

@JohnC-80
Copy link
Copy Markdown
Contributor Author

JohnC-80 commented Mar 4, 2026

STCLI PR: folio-org/stripes-cli#394

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Copy Markdown
Member

@zburke zburke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is working for me now 🎉 . Code changes look great. We should consider lifting some of the new comments (THANK YOU for the comments!) up into documentation, maybe in the README here, most probably in stripes-cli (where there is extensive documentation about dev-hosting already), and possibly in stripes-hub as well.

Comment thread webpack.config.base.js
}),
new webpack.EnvironmentPlugin(['NODE_ENV']),
new RemoveEmptyScriptsPlugin(),
new webpack.ManifestPlugin({ entrypoints: true }),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment explaining why we need this plugin? If it's self-evident and I'm just uninformed when it comes to webpack-foo, I totally accept that.

Comment on lines +68 to +72
// runtime plugins of the host are not automatically shared with remotes, so we
// inject them via another plugin.
// Without this, the remotes would all have to be rebuilt to pick up changes
// to runtime plugins. With this, we only have to rebuild the host app.
runtimePlugins: [path.resolve(__dirname, 'webpack', './remote-runtime-plugin')],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I understand this comment, but an example and a link to documentation would be helpful.

} else {
// in development mode, setup the devserver...
config.devtool = 'inline-source-map';
// turning off hot reloading and overlay since we're using the dev server for hosting static files rather than actual dev work.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment feels super important. Maybe it belongs in the README here or in stripes-cli or stripes-hub?

Comment on lines +62 to +64
exposes: {
'./MainEntry': mainEntry,
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we need a "Warning! Lark's Vomit!" comment here to call out this link between stripes-core's EntitlementLoader and the configuration here in stripes-webpack. Either that, or we need a way to export the config here and consume it there, i.e. anything that reduces the chance that somebody will decide "Oh, let's call this main-entry.js" and not realize the consequences.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file name can be named whatever they like, so long as it is referenced correctly in the ui-module's package.json as their main entry. MainEntry is like a named export that stripes-webpack sets up here to catch on the EntitlementLoader side. Writing up the comment for clarification. If the main entry in their package.json doesn't line up, the ui-module build will fail.

@JohnC-80 JohnC-80 merged commit df74d81 into main Mar 31, 2026
14 of 15 checks passed
@JohnC-80 JohnC-80 deleted the STRWEB-139 branch March 31, 2026 19:24
JohnC-80 added a commit that referenced this pull request Apr 17, 2026
* STRIPES-861: Setup module federation

* Cleanup

* Cleanup

* cleanup

* Use shutdown hook

* Cleanup

* Cleanup

* Cleanup

* Add required version to shared singletons

* Start remotes automatically

* Expose icons via public endpoint

* react-query provides a context, so must be a singleton

* STCOR-726 map sounds directory for remote applications

* map the `sounds` directory for remote applications, analogous to how
  translations and icons are served
* provide `/code` to make the registry human-readable
* catch and display startup errors in case humans make stupid coding
  mistakes and need help finding them

* current versions

* separate handling of stripes-components and application icons

Icons in stripes-components are imported as components whereas those in
applications are just resources, so we need to load them differently.

* provide registry url in stripes-config

* collect translations from 'StripesDeps' modules in built translations

* get the app's main entry from package.json

* ensure there are aliases before member access

* expand the singletons for the platform

* migrate  mf plugin/libraries to @module-federation/enhanced

* bump webpack-dev-server version

* restore stripes-config-plugin from main

* turn off hot reloading in module-level dev server

* turn off hot reloading in devtools for now

* use default discoveryUrl for local

* fussing with attempting to override shares with host dependencies

* re-add test folder

* sync with STCOR STRWEB-139 changes

* add runtimePlugin for host override

* remove auto version from modules

* single runtime from host

* set external runtime to true for modules

* exclude host-shares from module bundle

* add further optimization to module bundle, remove runtime plugins

* add remote runtime plugin to absorb plugins of host at runtime

* push host plugins to remote runtime

* collect debug info, cleanup logging in runtime plugins

* rename stripes runtime host plugin, tests

* remove the junky test artifacts

* consolidate modfed configs to a single file. Add semver to runtime plugin dep check

* tweak comments, remove the axios dep

* prefer spread syntax in cli configs. Alphabetize config values in mod-fed-config

* shore up the runtime logic with some optional chaining

* use default discoveryUrl for platform host app 'serve' command

* add console messaging for build command

* re-add manifest plugin

* address sonar-dad concerns

* minor: whtspace

* rework no-config discoverUrl use in serve.js

* remove all references to defaultTenant entry

* config: concatenateModules: false

* if no config discoveryUrl provided in config file, inject the default discoveryConfig if the --federate flag is used.

* re-add splitChunks to bundle in order to include dayJS chunks in main bundles

* resolve failures with mf-runtime-plugin tests

---------

Co-authored-by: Michal Kuklis <michal.kuklis@gmail.com>
Co-authored-by: Zak Burke <zburke@ebsco.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants